tty and login patch

From: Lars Pensjo <lars_at_nospam.org>
Date: Thu May 19 1994 - 01:20:56 PDT

Two patches:

1. Patch login program so as to not ask for password if the user doesn't
        have any.

2. Patch for libc/tty.c so as to make ONLCR work. This means that NL
        is replaced with CR/NL if OPOST and ONLCR are enabled.

===================================================================
RCS file: /usr/local/src/cvs.master/lars/vsta/bin.src/login/login.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 login.c
--- 1.1.1.1 1994/05/05 23:23:16
+++ login.c 1994/05/17 07:51:44
@@ -241,11 +241,13 @@
                 printf("That account is disabled.\n");
                 return;
         }
- printf("password: "); fflush(stdout);
- get_str(passwd, sizeof(passwd), 0);
- if (strcmp(uinfo.u_passwd, passwd)) {
- printf("Incorrect password.\n");
- return;
+ if (uinfo.u_passwd[0] != '\0') {
+ printf("password: "); fflush(stdout);
+ get_str(passwd, sizeof(passwd), 0);
+ if (strcmp(uinfo.u_passwd, passwd)) {
+ printf("Incorrect password.\n");
+ return;
+ }
         }
         login(&uinfo);
 }
===================================================================
RCS file: /usr/local/src/cvs.master/lars/vsta/libc/tty.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 tty.c
--- 1.1.1.1 1994/05/05 23:23:36
+++ tty.c 1994/05/07 11:38:50
@@ -318,18 +318,57 @@
  * __tty_write()
  * Flush buffers to a TTY-type device
  *
- * XXX add the needed CRNL conversion and such.
+ * XXX This should be rewritten so as to use several segments.
  */
 __tty_write(struct port *port, void *buf, uint nbyte)
 {
         struct msg m;
-
+ int start;
+ int offset;
+ char *p;
+
+ p = buf;
         m.m_op = FS_WRITE;
- m.m_buf = buf;
- m.m_arg = m.m_buflen = nbyte;
         m.m_nseg = 1;
         m.m_arg1 = 0;
- return(msg_send(port->p_port, &m));
+ /*
+ * If no post outprocessing is done, or if NLs are not translated
+ * into LF-CR, then output all data immediately.
+ */
+ if ((tty_state.c_oflag & (ONLCR|OPOST)) != (ONLCR|OPOST)) {
+ m.m_buf = buf;
+ m.m_arg = m.m_buflen = nbyte;
+ return(msg_send(port->p_port, &m));
+ }
+ for (start=0, offset=0; start+offset < nbyte; offset++) {
+ if (p[start+offset] != '\n')
+ continue;
+
+ m.m_buf = p+start;
+ m.m_arg = m.m_buflen = offset + 1;
+ if (msg_send(port->p_port, &m) == -1)
+ return start;
+ /*
+ * Now append a CR to the last NL.
+ */
+ m.m_buf = "\r";
+ m.m_arg = m.m_buflen = 1;
+ if (msg_send(port->p_port, &m) == -1)
+ return start+offset+1;
+ start += offset+1;
+ offset = -1;
+ }
+ /*
+ * Any remaining characters to be output ?
+ */
+ if (start != nbyte) {
+ m.m_buf = buf + start;
+ m.m_arg = m.m_buflen = offset;
+ if (msg_send(port->p_port, &m) == -1) {
+ return start;
+ }
+ }
+ return nbyte;
 }
 
 /*
Received on Wed May 18 23:52:08 1994

This archive was generated by hypermail 2.1.8 : Wed Sep 21 2005 - 21:04:28 PDT