Many fixes. 1) Use the cc_t typedef from termios.h
authorPaul Borman <borman@ucbvax.Berkeley.EDU>
Thu, 1 Mar 1990 07:36:08 +0000 (23:36 -0800)
committerPaul Borman <borman@ucbvax.Berkeley.EDU>
Thu, 1 Mar 1990 07:36:08 +0000 (23:36 -0800)
2) Fix for SYSV VEOF/VMIN overlap
3) Add two missing "break" statements
4) Add SLC_FORW[12] support
5) start of TOS support
6) Make sure things get initialized properly
7) Don't send Urgent mode data, since some clients go into infinate loops...

SCCS-vsn: libexec/telnetd/defs.h 5.4
SCCS-vsn: libexec/telnetd/ext.h 5.4
SCCS-vsn: libexec/telnetd/slc.c 5.2
SCCS-vsn: libexec/telnetd/state.c 5.5
SCCS-vsn: libexec/telnetd/sys_term.c 5.5
SCCS-vsn: libexec/telnetd/telnetd.c 5.42
SCCS-vsn: libexec/telnetd/termstat.c 5.4
SCCS-vsn: libexec/telnetd/Makefile 5.7

usr/src/libexec/telnetd/Makefile
usr/src/libexec/telnetd/defs.h
usr/src/libexec/telnetd/ext.h
usr/src/libexec/telnetd/slc.c
usr/src/libexec/telnetd/state.c
usr/src/libexec/telnetd/sys_term.c
usr/src/libexec/telnetd/telnetd.c
usr/src/libexec/telnetd/termstat.c

index 8d311ec..d8bcd4a 100644 (file)
 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-#      @(#)Makefile    5.6 (Berkeley) %G%
+#      @(#)Makefile    5.7 (Berkeley) %G%
 #
 
 #
 
-DEFINES=
+DEFINES= -DNEED_GETTOS
 LIBC=  /lib/libc.a
 # 4.4BSD
 #              LIBS= -lutil -ltermcap
 LIBC=  /lib/libc.a
 # 4.4BSD
 #              LIBS= -lutil -ltermcap
index 23ca3cb..4e3a0e3 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)defs.h      5.3 (Berkeley) %G%
+ *     @(#)defs.h      5.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #include <errno.h>
 #include <netdb.h>
 #include <syslog.h>
 #include <errno.h>
 #include <netdb.h>
 #include <syslog.h>
+#ifndef        LOG_DAEMON
+#define        LOG_DAEMON      0
+#endif
+#ifndef        LOG_ODELAY
+#define        LOG_ODELAY      0
+#endif
 #include <ctype.h>
 #include <strings.h>
 
 #ifndef        USE_TERMIO
 #include <sgtty.h>
 #include <ctype.h>
 #include <strings.h>
 
 #ifndef        USE_TERMIO
 #include <sgtty.h>
+typedef unsigned char cc_t;
 #else
 # ifdef        SYSV_TERMIO
 # include <termio.h>
 #else
 # ifdef        SYSV_TERMIO
 # include <termio.h>
@@ -91,7 +98,9 @@
 #endif
 
 #ifndef        FD_SET
 #endif
 
 #ifndef        FD_SET
+#ifndef        HAVE_fd_set
 typedef struct fd_set { int fds_bits[1]; } fd_set;
 typedef struct fd_set { int fds_bits[1]; } fd_set;
+#endif
 
 #define        FD_SET(n, p)    ((p)->fds_bits[0] |= (1<<(n)))
 #define        FD_CLR(n, p)    ((p)->fds_bits[0] &= ~(1<<(n)))
 
 #define        FD_SET(n, p)    ((p)->fds_bits[0] |= (1<<(n)))
 #define        FD_CLR(n, p)    ((p)->fds_bits[0] &= ~(1<<(n)))
@@ -133,12 +142,12 @@ typedef struct fd_set { int fds_bits[1]; } fd_set;
  */
 typedef struct {
        unsigned char   flag;           /* the flags for this function */
  */
 typedef struct {
        unsigned char   flag;           /* the flags for this function */
-       unsigned char   val;            /* the value of the special character */
+       cc_t            val;            /* the value of the special character */
 } slcent, *Slcent;
 
 typedef struct {
        slcent          defset;         /* the default settings */
        slcent          current;        /* the current settings */
 } slcent, *Slcent;
 
 typedef struct {
        slcent          defset;         /* the default settings */
        slcent          current;        /* the current settings */
-       unsigned char   *sptr;          /* a pointer to the char in */
+       cc_t            *sptr;          /* a pointer to the char in */
                                        /* system data structures */
 } slcfun, *Slcfun;
                                        /* system data structures */
 } slcfun, *Slcfun;
index f7b7854..48fad28 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ext.h       5.3 (Berkeley) %G%
+ *     @(#)ext.h       5.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -54,7 +54,7 @@ extern char   *neturg;                /* one past last bye of urgent data */
 
 extern int     pcc, ncc;
 
 
 extern int     pcc, ncc;
 
-#ifdef CRAY2
+#if defined(CRAY2) && defined(UNICOS5)
 extern int unpcc;  /* characters left unprocessed by CRAY-2 terminal routine */
 extern char *unptyip;  /* pointer to remaining characters in buffer */
 #endif
 extern int unpcc;  /* characters left unprocessed by CRAY-2 terminal routine */
 extern char *unptyip;  /* pointer to remaining characters in buffer */
 #endif
@@ -81,7 +81,7 @@ extern struct {
 } clocks;
 
 
 } clocks;
 
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
 extern int     needtermstat;
 #endif
 
 extern int     needtermstat;
 #endif
 
index ed82727..e9c0d81 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)slc.c      5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)slc.c      5.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)slc.c     5.1 (Berkeley) %G%";
 /*
  * local varibles
  */
 /*
  * local varibles
  */
-static char    *def_slcbuf = (char *)0;;
+static char    *def_slcbuf = (char *)0;
 static int     def_slclen = 0;
 static int     slcchange;      /* change to slc is requested */
 static char    *slcptr;        /* pointer into slc buffer */
 static int     def_slclen = 0;
 static int     slcchange;      /* change to slc is requested */
 static char    *slcptr;        /* pointer into slc buffer */
@@ -102,20 +102,18 @@ get_slc_defaults()
  * Add an slc triplet to the slc buffer.
  */
 add_slc(func, flag, val)
  * Add an slc triplet to the slc buffer.
  */
 add_slc(func, flag, val)
-       register unsigned char func, flag, val;
+       register unsigned char func, flag;
+       cc_t val;
 {
 
 {
 
-       if (func == 0xff)
+       if ((*slcptr++ = func) == 0xff)
                *slcptr++ = 0xff;
                *slcptr++ = 0xff;
-       *slcptr++ = func;
 
 
-       if (flag == 0xff)
+       if ((*slcptr++ = flag) == 0xff)
                *slcptr++ = 0xff;
                *slcptr++ = 0xff;
-       *slcptr++ = flag;
 
 
-       if (val == 0xff)
+       if ((*slcptr++ = (unsigned char)val) == 0xff)
                *slcptr++ = 0xff;
                *slcptr++ = 0xff;
-       *slcptr++ = val;
 
 }  /* end of add_slc */
 
 
 }  /* end of add_slc */
 
@@ -189,7 +187,8 @@ register char **bufp;
  * Figure out what to do about the client's slc
  */
 process_slc(func, flag, val)
  * Figure out what to do about the client's slc
  */
 process_slc(func, flag, val)
-       register unsigned char func, flag, val;
+       register unsigned char func, flag;
+       cc_t val;
 {
        register int hislevel, mylevel, ack;
 
 {
        register int hislevel, mylevel, ack;
 
@@ -244,7 +243,8 @@ process_slc(func, flag, val)
  * Compare client's request with what we are capable of supporting.
  */
 change_slc(func, flag, val)
  * Compare client's request with what we are capable of supporting.
  */
 change_slc(func, flag, val)
-       register unsigned char func, flag, val;
+       register unsigned char func, flag;
+       cc_t val;
 {
        register int hislevel, mylevel;
        
 {
        register int hislevel, mylevel;
        
@@ -340,6 +340,10 @@ change_slc(func, flag, val)
 
 }  /* end of change_slc */
 
 
 }  /* end of change_slc */
 
+#if    defined(USE_TERMIO) && defined(SYSV_TERMIO)
+cc_t oldeofc = '\004';
+#endif
+
 /*
  * check_slc
  *
 /*
  * check_slc
  *
@@ -361,8 +365,12 @@ check_slc()
                 * ICANON is off, because it is not representing
                 * a special character.
                 */
                 * ICANON is off, because it is not representing
                 * a special character.
                 */
-               if (!tty_isediting() && i == SLC_EOF)
-                       continue;
+               if (i == SLC_EOF) {
+                       if (!tty_isediting())
+                               continue;
+                       else if (slctab[i].sptr)
+                               oldeofc = *(slctab[i].sptr);
+               }
 #endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
                if (slctab[i].sptr &&
                                (*(slctab[i].sptr) != slctab[i].current.val)) {
 #endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
                if (slctab[i].sptr &&
                                (*(slctab[i].sptr) != slctab[i].current.val)) {
@@ -388,7 +396,8 @@ do_opt_slc(ptr, len)
 register char *ptr;
 register int len;
 {
 register char *ptr;
 register int len;
 {
-       register unsigned char func, flag, val;
+       register unsigned char func, flag;
+       cc_t val;
        register char *end = (char *)(ptr + len);
        char *malloc();
 
        register char *end = (char *)(ptr + len);
        char *malloc();
 
@@ -398,7 +407,7 @@ register int len;
                        if (ptr >= end) break;
                        flag = *ptr++;
                        if (ptr >= end) break;
                        if (ptr >= end) break;
                        flag = *ptr++;
                        if (ptr >= end) break;
-                       val = *ptr++;
+                       val = (cc_t)*ptr++;
 
                        process_slc(func, flag, val);
 
 
                        process_slc(func, flag, val);
 
index edb6436..a5aa065 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)state.c    5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)state.c    5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -60,7 +60,7 @@ telrcv()
 {
        register int c;
        static int state = TS_DATA;
 {
        register int c;
        static int state = TS_DATA;
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
        char *opfrontp = pfrontp;
 #endif
 
        char *opfrontp = pfrontp;
 #endif
 
@@ -142,8 +142,9 @@ gotiac:                     switch (c) {
                                init_termbuf();
 
                                if (slctab[SLC_AO].sptr &&
                                init_termbuf();
 
                                if (slctab[SLC_AO].sptr &&
-                                   *slctab[SLC_AO].sptr != '\377') {
-                                       *pfrontp++ = *slctab[SLC_AO].sptr;
+                                   *slctab[SLC_AO].sptr != (cc_t)-1) {
+                                   *pfrontp++ =
+                                       (unsigned char)*slctab[SLC_AO].sptr;
                                }
 
                                netclear();     /* clear buffer back */
                                }
 
                                netclear();     /* clear buffer back */
@@ -160,14 +161,14 @@ gotiac:                   switch (c) {
                        case EC:
                        case EL:
                            {
                        case EC:
                        case EL:
                            {
-                               unsigned char ch;
+                               cc_t ch;
 
                                ptyflush();     /* half-hearted */
                                init_termbuf();
                                ch = (c == EC) ? *slctab[SLC_EC].sptr :
                                                 *slctab[SLC_EL].sptr;
 
                                ptyflush();     /* half-hearted */
                                init_termbuf();
                                ch = (c == EC) ? *slctab[SLC_EC].sptr :
                                                 *slctab[SLC_EL].sptr;
-                               if (ch != '\377')
-                                       *pfrontp++ = ch;
+                               if (ch != (cc_t)-1)
+                                       *pfrontp++ = (unsigned char)ch;
                                break;
                            }
 
                                break;
                            }
 
@@ -290,7 +291,7 @@ gotiac:                     switch (c) {
                        exit(1);
                }
        }
                        exit(1);
                }
        }
-#if    CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
        if (!linemode) {
                char    xptyobuf[BUFSIZ+NETSLOP];
                char    xbuf2[BUFSIZ];
        if (!linemode) {
                char    xptyobuf[BUFSIZ+NETSLOP];
                char    xbuf2[BUFSIZ];
@@ -304,7 +305,7 @@ gotiac:                     switch (c) {
                        if ((*nfrontp++ = *cp++) == IAC)
                                *nfrontp++ = IAC;
        }
                        if ((*nfrontp++ = *cp++) == IAC)
                                *nfrontp++ = IAC;
        }
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
 }  /* end of telrcv */
 
 /*
 }  /* end of telrcv */
 
 /*
@@ -370,9 +371,6 @@ gotiac:                     switch (c) {
  * peer probably should be buffering until this option state negotiation
  * is complete.
  *
  * peer probably should be buffering until this option state negotiation
  * is complete.
  *
- * In processing options, request signifies whether this is a request
- * to send or a response.  request is true if this is a request to 
- * send generated locally.
  */
 send_do(option, init)
        int option, init;
  */
 send_do(option, init)
        int option, init;
@@ -772,6 +770,7 @@ dontoption(option)
        /*
         * Process client input.
         */
        /*
         * Process client input.
         */
+
        if (will_wont_resp[option]) {
                will_wont_resp[option]--;
                if (will_wont_resp[option] && myopts[option] == OPT_NO)
        if (will_wont_resp[option]) {
                will_wont_resp[option]--;
                if (will_wont_resp[option] && myopts[option] == OPT_NO)
@@ -962,7 +961,7 @@ suboption()
        default:
                break;
        }
        default:
                break;
        }
-
+       break;
     }  /* end of case TELOPT_LINEMODE */
 #endif
     case TELOPT_STATUS: {
     }  /* end of case TELOPT_LINEMODE */
 #endif
     case TELOPT_STATUS: {
@@ -981,7 +980,8 @@ suboption()
        default:
            break;
        }
        default:
            break;
        }
-    }
+       break;
+    }  /* end of case TELOPT_STATUS */
 
     default:
        break;
 
     default:
        break;
index 107b936..4dde141 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sys_term.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_term.c 5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -135,7 +135,7 @@ set_termbuf()
 #else  /* USE_TERMIO */
        if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
                (void) ioctl(pty, TCSETA, (char *)&termbuf);
 #else  /* USE_TERMIO */
        if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
                (void) ioctl(pty, TCSETA, (char *)&termbuf);
-# ifdef        CRAY2
+# if   defined(CRAY2) && defined(UNCIOS5)
        needtermstat = 1;
 # endif
 #endif /* USE_TERMIO */
        needtermstat = 1;
 # endif
 #endif /* USE_TERMIO */
@@ -156,68 +156,72 @@ set_termbuf()
 #ifndef        USE_TERMIO
 spcset(func, valp, valpp)
 int func;
 #ifndef        USE_TERMIO
 spcset(func, valp, valpp)
 int func;
-unsigned char *valp;
-unsigned char **valpp;
+cc_t *valp;
+cc_t **valpp;
 {
        switch(func) {
        case SLC_EOF:
                *valp = termbuf.tc.t_eofc;
 {
        switch(func) {
        case SLC_EOF:
                *valp = termbuf.tc.t_eofc;
-               *valpp = (unsigned char *)&termbuf.tc.t_eofc;
+               *valpp = (cc_t *)&termbuf.tc.t_eofc;
                return(SLC_VARIABLE);
        case SLC_EC:
                *valp = termbuf.sg.sg_erase;
                return(SLC_VARIABLE);
        case SLC_EC:
                *valp = termbuf.sg.sg_erase;
-               *valpp = (unsigned char *)&termbuf.sg.sg_erase;
+               *valpp = (cc_t *)&termbuf.sg.sg_erase;
                return(SLC_VARIABLE);
        case SLC_EL:
                *valp = termbuf.sg.sg_kill;
                return(SLC_VARIABLE);
        case SLC_EL:
                *valp = termbuf.sg.sg_kill;
-               *valpp = (unsigned char *)&termbuf.sg.sg_kill;
+               *valpp = (cc_t *)&termbuf.sg.sg_kill;
                return(SLC_VARIABLE);
        case SLC_IP:
                *valp = termbuf.tc.t_intrc;
                return(SLC_VARIABLE);
        case SLC_IP:
                *valp = termbuf.tc.t_intrc;
-               *valpp = (unsigned char *)&termbuf.tc.t_intrc;
+               *valpp = (cc_t *)&termbuf.tc.t_intrc;
                return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
        case SLC_ABORT:
                *valp = termbuf.tc.t_quitc;
                return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
        case SLC_ABORT:
                *valp = termbuf.tc.t_quitc;
-               *valpp = (unsigned char *)&termbuf.tc.t_quitc;
+               *valpp = (cc_t *)&termbuf.tc.t_quitc;
                return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
        case SLC_XON:
                *valp = termbuf.tc.t_startc;
                return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
        case SLC_XON:
                *valp = termbuf.tc.t_startc;
-               *valpp = (unsigned char *)&termbuf.tc.t_startc;
+               *valpp = (cc_t *)&termbuf.tc.t_startc;
                return(SLC_VARIABLE);
        case SLC_XOFF:
                *valp = termbuf.tc.t_stopc;
                return(SLC_VARIABLE);
        case SLC_XOFF:
                *valp = termbuf.tc.t_stopc;
-               *valpp = (unsigned char *)&termbuf.tc.t_stopc;
+               *valpp = (cc_t *)&termbuf.tc.t_stopc;
                return(SLC_VARIABLE);
        case SLC_AO:
                *valp = termbuf.ltc.t_flushc;
                return(SLC_VARIABLE);
        case SLC_AO:
                *valp = termbuf.ltc.t_flushc;
-               *valpp = (unsigned char *)&termbuf.ltc.t_flushc;
+               *valpp = (cc_t *)&termbuf.ltc.t_flushc;
                return(SLC_VARIABLE);
        case SLC_SUSP:
                *valp = termbuf.ltc.t_suspc;
                return(SLC_VARIABLE);
        case SLC_SUSP:
                *valp = termbuf.ltc.t_suspc;
-               *valpp = (unsigned char *)&termbuf.ltc.t_suspc;
+               *valpp = (cc_t *)&termbuf.ltc.t_suspc;
                return(SLC_VARIABLE);
        case SLC_EW:
                *valp = termbuf.ltc.t_werasc;
                return(SLC_VARIABLE);
        case SLC_EW:
                *valp = termbuf.ltc.t_werasc;
-               *valpp = (unsigned char *)&termbuf.ltc.t_werasc;
+               *valpp = (cc_t *)&termbuf.ltc.t_werasc;
                return(SLC_VARIABLE);
        case SLC_RP:
                *valp = termbuf.ltc.t_rprntc;
                return(SLC_VARIABLE);
        case SLC_RP:
                *valp = termbuf.ltc.t_rprntc;
-               *valpp = (unsigned char *)&termbuf.ltc.t_rprntc;
+               *valpp = (cc_t *)&termbuf.ltc.t_rprntc;
                return(SLC_VARIABLE);
        case SLC_LNEXT:
                *valp = termbuf.ltc.t_lnextc;
                return(SLC_VARIABLE);
        case SLC_LNEXT:
                *valp = termbuf.ltc.t_lnextc;
-               *valpp = (unsigned char *)&termbuf.ltc.t_lnextc;
+               *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
+               return(SLC_VARIABLE);
+       case SLC_FORW1:
+               *valp = termbuf.tc.t_brkc;
+               *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
                return(SLC_VARIABLE);
        case SLC_BRK:
        case SLC_SYNCH:
        case SLC_AYT:
        case SLC_EOR:
                return(SLC_VARIABLE);
        case SLC_BRK:
        case SLC_SYNCH:
        case SLC_AYT:
        case SLC_EOR:
-               *valp = 0;
-               *valpp = 0;
+               *valp = (cc_t)0;
+               *valpp = (cc_t *)0;
                return(SLC_DEFAULT);
        default:
                return(SLC_DEFAULT);
        default:
-               *valp = 0;
-               *valpp = 0;
+               *valp = (cc_t)0;
+               *valpp = (cc_t *)0;
                return(SLC_NOSUPPORT);
        }
 }
                return(SLC_NOSUPPORT);
        }
 }
@@ -226,14 +230,14 @@ unsigned char **valpp;
 
 spcset(func, valp, valpp)
 int func;
 
 spcset(func, valp, valpp)
 int func;
-unsigned char *valp;
-unsigned char **valpp;
+cc_t *valp;
+cc_t **valpp;
 {
 
 #define        setval(a, b)    *valp = termbuf.c_cc[a]; \
                        *valpp = &termbuf.c_cc[a]; \
                        return(b);
 {
 
 #define        setval(a, b)    *valp = termbuf.c_cc[a]; \
                        *valpp = &termbuf.c_cc[a]; \
                        return(b);
-#define        defval(a)       *valp = (a); *valpp = 0; return(SLC_DEFAULT);
+#define        defval(a) *valp = ((cc_t)a); *valpp = (cc_t *)0; return(SLC_DEFAULT);
 
        switch(func) {
        case SLC_EOF:
 
        switch(func) {
        case SLC_EOF:
@@ -288,6 +292,14 @@ unsigned char **valpp;
 #else
                defval(0);
 #endif
 #else
                defval(0);
 #endif
+#ifdef VEOL
+       case SLC_FORW1:
+               setval(VEOL, SLC_VARIABLE);
+#endif
+#ifdef VEOL2
+       case SLC_FORW2:
+               setval(VEOL2, SLC_VARIABLE);
+#endif
 
        case SLC_BRK:
        case SLC_SYNCH:
 
        case SLC_BRK:
        case SLC_SYNCH:
@@ -303,6 +315,22 @@ unsigned char **valpp;
 }
 #endif /* USE_TERMIO */
 
 }
 #endif /* USE_TERMIO */
 
+#ifdef CRAY
+/*
+ * getnpty()
+ *
+ * Return the number of pty's configured into the system.
+ */
+getnpty()
+{
+#ifdef _SC_CRAY_NPTY
+       return sysconf(_SC_CRAY_NPTY);
+#else
+       return 128;
+#endif /* _SC_CRAY_NPTY */
+}
+#endif /* CRAY */
+
 /*
  * getpty()
  *
 /*
  * getpty()
  *
@@ -604,7 +632,7 @@ tty_rspeed(val)
 #endif
 }
 
 #endif
 }
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
 tty_isnewmap()
 {
        return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) &&
 tty_isnewmap()
 {
        return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) &&
@@ -618,7 +646,10 @@ extern     struct utmp wtmp;
 extern char wtmpf[];
 # else /* NEWINIT */
 int    gotalarm;
 extern char wtmpf[];
 # else /* NEWINIT */
 int    gotalarm;
-nologinproc()
+/* ARGSUSED */
+void
+nologinproc(sig)
+int sig;
 {
        gotalarm++;
 }
 {
        gotalarm++;
 }
@@ -661,7 +692,7 @@ getptyslave()
 
        init_termbuf();
 #ifndef        USE_TERMIO
 
        init_termbuf();
 #ifndef        USE_TERMIO
-       termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO;
+       termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO|XTABS;
        termbuf.sg.sg_ospeed = termbuf.sg.sg_ispeed = B9600;
 #else
        termbuf.c_lflag |= ECHO;
        termbuf.sg.sg_ospeed = termbuf.sg.sg_ispeed = B9600;
 #else
        termbuf.c_lflag |= ECHO;
@@ -746,7 +777,7 @@ char *host;
 
        extern char *ptyip;
        struct init_request request;
 
        extern char *ptyip;
        struct init_request request;
-       int nologinproc();
+       void nologinproc();
        register int n;
 
        /*
        register int n;
 
        /*
@@ -764,6 +795,10 @@ char *host;
        SCPYN(request.tty_id, &line[8]);
        SCPYN(request.host, host);
        SCPYN(request.term_type, &terminaltype[5]);
        SCPYN(request.tty_id, &line[8]);
        SCPYN(request.host, host);
        SCPYN(request.term_type, &terminaltype[5]);
+#if    defined(UNICOS5)
+       request.signal = SIGCLD;
+       request.pid = getpid();
+#endif
        if (write(i, (char *)&request, sizeof(request)) < 0) {
                char tbuf[128];
                (void) sprintf(tbuf, "Can't write to %s\n", INIT_FIFO);
        if (write(i, (char *)&request, sizeof(request)) < 0) {
                char tbuf[128];
                (void) sprintf(tbuf, "Can't write to %s\n", INIT_FIFO);
@@ -772,12 +807,14 @@ char *host;
        (void) close(i);
        (void) signal(SIGALRM, nologinproc);
        for (i = 0; ; i++) {
        (void) close(i);
        (void) signal(SIGALRM, nologinproc);
        for (i = 0; ; i++) {
+               char tbuf[128];
                alarm(15);
                n = read(pty, ptyip, BUFSIZ);
                if (i == 3 || n >= 0 || !gotalarm)
                        break;
                gotalarm = 0;
                alarm(15);
                n = read(pty, ptyip, BUFSIZ);
                if (i == 3 || n >= 0 || !gotalarm)
                        break;
                gotalarm = 0;
-               (void) write(net, "telnetd: waiting for /etc/init to start login process.\r\n", 56);
+               sprintf(tbuf, "telnetd: waiting for /etc/init to start login process on %s\r\n", line);
+               (void) write(net, tbuf, strlen(tbuf));
        }
        if (n < 0 && gotalarm)
                fatal(net, "/etc/init didn't start login process");
        }
        if (n < 0 && gotalarm)
                fatal(net, "/etc/init didn't start login process");
@@ -785,14 +822,6 @@ char *host;
        alarm(0);
        (void) signal(SIGALRM, SIG_DFL);
 
        alarm(0);
        (void) signal(SIGALRM, SIG_DFL);
 
-       /*
-        * Set tab expansion the way we like, in case init did something
-        * different.
-        */
-       init_termbuf();
-       termbuf.c_oflag &= ~TABDLY;
-       termbuf.c_oflag |= TAB0;
-       set_termbuf();
        return;
 #endif /* NEWINIT */
 }
        return;
 #endif /* NEWINIT */
 }
@@ -843,7 +872,7 @@ char *host;
         * set ttyp modes as we like them to be
         */
        init_termbuf();
         * set ttyp modes as we like them to be
         */
        init_termbuf();
-       termbuf.c_oflag = OPOST|ONLCR;
+       termbuf.c_oflag = OPOST|ONLCR|TAB3;
        termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
        termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
        termbuf.c_cflag = EXTB|HUPCL|CS8;
        termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
        termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
        termbuf.c_cflag = EXTB|HUPCL|CS8;
@@ -925,7 +954,7 @@ cleanup()
        kill(0, SIGHUP);
 # else /* NEWINIT */
        (void) shutdown(net, 2);
        kill(0, SIGHUP);
 # else /* NEWINIT */
        (void) shutdown(net, 2);
-       sleep(5);
+       sleep(2);
 # endif        /* NEWINT */
 #endif /* CRAY */
        exit(1);
 # endif        /* NEWINT */
 #endif /* CRAY */
        exit(1);
index 9bca18d..b25ddff 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.41 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.42 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -40,23 +40,58 @@ int hostinfo = 1;                   /* do we print login banner? */
 
 #ifdef CRAY
 extern int      newmap; /* nonzero if \n maps to ^M^J */
 
 #ifdef CRAY
 extern int      newmap; /* nonzero if \n maps to ^M^J */
-int    lowpty = 0, highpty = 128;      /* low, high pty numbers */
+int    lowpty = 0, highpty;    /* low, high pty numbers */
 #endif /* CRAY */
 
 int debug = 0;
 char *progname;
 
 #endif /* CRAY */
 
 int debug = 0;
 char *progname;
 
+#if    defined(IP_TOS) && defined(NEED_GETTOS)
+struct tosent {
+       char    *t_name;        /* name */
+       char    **t_aliases;    /* alias list */
+       char    *t_proto;       /* protocol */
+       int     t_tos;          /* Type Of Service bits */
+};
+
+struct tosent *
+gettosbyname(name, proto)
+char *name, *proto;
+{
+       static struct tosent te;
+       static char *aliasp = 0;
+
+       te.t_name = name;
+       te.t_aliases = &aliasp;
+       te.t_proto = proto;
+       te.t_tos = 020; /* Low Delay bit */
+       return(&te);
+}
+#endif
+
 main(argc, argv)
        char *argv[];
 {
        struct sockaddr_in from;
        int on = 1, fromlen;
 main(argc, argv)
        char *argv[];
 {
        struct sockaddr_in from;
        int on = 1, fromlen;
+#ifdef IP_TOS
+       struct tosent *tp;
+#endif /* IP_TOS */
 
        pfrontp = pbackp = ptyobuf;
        netip = netibuf;
        nfrontp = nbackp = netobuf;
 
        progname = *argv;
 
        pfrontp = pbackp = ptyobuf;
        netip = netibuf;
        nfrontp = nbackp = netobuf;
 
        progname = *argv;
+
+#ifdef CRAY
+       /*
+        * Get number of pty's before trying to process options,
+        * which may include changing pty range.
+        */
+       highpty = getnpty();
+#endif /* CRAY */
+
 top:
        argc--, argv++;
 
 top:
        argc--, argv++;
 
@@ -82,6 +117,11 @@ top:
                char *strchr();
                char *c;
 
                char *strchr();
                char *c;
 
+               /*
+                * Allow the specification of alterations to the pty search
+                * range.  It is legal to specify only one, and not change the
+                * other from its default.
+                */
                *argv += 2;
                if (**argv == '\0' && argc)
                        argv++, argc--;
                *argv += 2;
                if (**argv == '\0' && argc)
                        argv++, argc--;
@@ -89,16 +129,16 @@ top:
                if (c) {
                        *c++ = '\0';
                        highpty = atoi(c);
                if (c) {
                        *c++ = '\0';
                        highpty = atoi(c);
-               } else
-                       highpty = -1;
-               lowpty = atoi(*argv);
-               if ((lowpty > highpty) || (lowpty < 0) || (highpty > 999)) {
+               }
+               if (**argv != '\0')
+                       lowpty = atoi(*argv);
+               if ((lowpty > highpty) || (lowpty < 0) || (highpty > 32767)) {
        usage:
                        fprintf(stderr, "Usage: telnetd [-debug] [-h] ");
 # ifdef        NEWINIT
                        fprintf(stderr, "[-Iinitid] ");
 # endif        /* NEWINIT */
        usage:
                        fprintf(stderr, "Usage: telnetd [-debug] [-h] ");
 # ifdef        NEWINIT
                        fprintf(stderr, "[-Iinitid] ");
 # endif        /* NEWINIT */
-                       fprintf(stderr, "[-l] [-rlowpty-highpty] [port]\n");
+                       fprintf(stderr, "[-l] [-r[lowpty]-[highpty]] [port]\n");
                        exit(1);
                }
                goto top;
                        exit(1);
                }
                goto top;
@@ -182,12 +222,18 @@ top:
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
                syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
                syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
        }
+
+#ifdef IP_TOS
+       if ((tp = gettosbyname("telnet", "tcp")) &&
+           (setsockopt(0, IPPROTO_IP, IP_TOS, &tp->t_tos, sizeof(int)) < 0))
+               syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
+#endif /* IP_TOS */
        net = 0;
        doit(&from);
        /* NOTREACHED */
 }  /* end of main */
 
        net = 0;
        doit(&from);
        /* NOTREACHED */
 }  /* end of main */
 
-int    cleanup();
+void   cleanup();
 
 /*
  * getterminaltype
 
 /*
  * getterminaltype
@@ -345,7 +391,7 @@ int f, p;
 {
        int on = 1;
        char hostname[MAXHOSTNAMELEN];
 {
        int on = 1;
        char hostname[MAXHOSTNAMELEN];
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
        int termstat();
        int interrupt(), sendbrk();
 #endif
        int termstat();
        int interrupt(), sendbrk();
 #endif
@@ -423,8 +469,9 @@ int f, p;
         * respond because it believes that it is already in DO ECHO
         * mode, which we do not want.
         */
         * respond because it believes that it is already in DO ECHO
         * mode, which we do not want.
         */
-       if (hiswants[TELOPT_ECHO] == OPT_YES)
+       if (hiswants[TELOPT_ECHO] == OPT_YES) {
                willoption(TELOPT_ECHO);
                willoption(TELOPT_ECHO);
+       }
 
        /*
         * Finally, to clean things up, we turn on our echo.  This
 
        /*
         * Finally, to clean things up, we turn on our echo.  This
@@ -461,7 +508,7 @@ int f, p;
 
        (void) ioctl(f, FIONBIO, (char *)&on);
        (void) ioctl(p, FIONBIO, (char *)&on);
 
        (void) ioctl(f, FIONBIO, (char *)&on);
        (void) ioctl(p, FIONBIO, (char *)&on);
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
        init_termdriver(f, p, interrupt, sendbrk);
 #endif
 
        init_termdriver(f, p, interrupt, sendbrk);
 #endif
 
@@ -482,7 +529,7 @@ int f, p;
 
        (void) signal(SIGCHLD, cleanup);
 
 
        (void) signal(SIGCHLD, cleanup);
 
-#if    defined(CRAY2)
+#if    defined(CRAY2) && defined(UNICOS5)
        /*
         * Cray-2 will send a signal when pty modes are changed by slave
         * side.  Set up signal handler now.
        /*
         * Cray-2 will send a signal when pty modes are changed by slave
         * side.  Set up signal handler now.
@@ -498,6 +545,9 @@ int f, p;
 #endif
 
        (void) setpgrp(0, 0);
 #endif
 
        (void) setpgrp(0, 0);
+#ifdef TCSETCTTY
+       ioctl(p, TCSETCTTY, 0);
+#endif
 
        /*
         * Show banner that getty never gave.
 
        /*
         * Show banner that getty never gave.
@@ -537,6 +587,13 @@ int f, p;
                (void) strncat(ptyibuf2, ptyip, pcc+1);
        ptyip = ptyibuf2;
        pcc = strlen(ptyip);
                (void) strncat(ptyibuf2, ptyip, pcc+1);
        ptyip = ptyibuf2;
        pcc = strlen(ptyip);
+#ifdef LINEMODE
+       /*
+        * Last check to make sure all our states are correct.
+        */
+       init_termbuf();
+       localstat();
+#endif /* LINEMODE */
 
        for (;;) {
                fd_set ibits, obits, xbits;
 
        for (;;) {
                fd_set ibits, obits, xbits;
@@ -545,10 +602,10 @@ int f, p;
                if (ncc < 0 && pcc < 0)
                        break;
 
                if (ncc < 0 && pcc < 0)
                        break;
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
                if (needtermstat)
                        _termstat();
                if (needtermstat)
                        _termstat();
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
                FD_ZERO(&ibits);
                FD_ZERO(&obits);
                FD_ZERO(&xbits);
                FD_ZERO(&ibits);
                FD_ZERO(&obits);
                FD_ZERO(&xbits);
@@ -668,7 +725,7 @@ int f, p;
                        else {
                                if (pcc <= 0)
                                        break;
                        else {
                                if (pcc <= 0)
                                        break;
-#ifndef        CRAY2
+#if    !defined(CRAY2) || !defined(UNICOS5)
 #ifdef LINEMODE
                                /*
                                 * If ioctl from pty, pass it through net
 #ifdef LINEMODE
                                /*
                                 * If ioctl from pty, pass it through net
@@ -681,9 +738,19 @@ int f, p;
 #endif LINEMODE
                                if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
                                        netclear();     /* clear buffer back */
 #endif LINEMODE
                                if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
                                        netclear();     /* clear buffer back */
+#ifdef notdef
+                                       /*
+                                        * We really should have this in, but
+                                        * there are client telnets on some
+                                        * operating systems get screwed up
+                                        * royally if we send them urgent
+                                        * mode data.  So, for now, we'll not
+                                        * do this...
+                                        */
                                        *nfrontp++ = IAC;
                                        *nfrontp++ = DM;
                                        neturg = nfrontp-1; /* off by one XXX */
                                        *nfrontp++ = IAC;
                                        *nfrontp++ = DM;
                                        neturg = nfrontp-1; /* off by one XXX */
+#endif
                                }
                                if (hisopts[TELOPT_LFLOW] &&
                                    (ptyibuf[0] &
                                }
                                if (hisopts[TELOPT_LFLOW] &&
                                    (ptyibuf[0] &
@@ -696,7 +763,7 @@ int f, p;
                                }
                                pcc--;
                                ptyip = ptyibuf+1;
                                }
                                pcc--;
                                ptyip = ptyibuf+1;
-#else  /* CRAY2 */
+#else  /* defined(CRAY2) && defined(UNICOS5) */
                                if (!uselinemode) {
                                        unpcc = pcc;
                                        unptyip = ptyibuf;
                                if (!uselinemode) {
                                        unpcc = pcc;
                                        unptyip = ptyibuf;
@@ -705,7 +772,7 @@ int f, p;
                                        ptyip = ptyibuf2;
                                } else
                                        ptyip = ptyibuf;
                                        ptyip = ptyibuf2;
                                } else
                                        ptyip = ptyibuf;
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
                        }
                }
 
                        }
                }
 
@@ -715,11 +782,11 @@ int f, p;
                        c = *ptyip++ & 0377, pcc--;
                        if (c == IAC)
                                *nfrontp++ = c;
                        c = *ptyip++ & 0377, pcc--;
                        if (c == IAC)
                                *nfrontp++ = c;
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
                        else if (c == '\n' &&
                                     myopts[TELOPT_BINARY] == OPT_NO && newmap)
                                *nfrontp++ = '\r';
                        else if (c == '\n' &&
                                     myopts[TELOPT_BINARY] == OPT_NO && newmap)
                                *nfrontp++ = '\r';
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
                        *nfrontp++ = c;
                        if ((c == '\r') && (myopts[TELOPT_BINARY] == OPT_NO)) {
                                if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
                        *nfrontp++ = c;
                        if ((c == '\r') && (myopts[TELOPT_BINARY] == OPT_NO)) {
                                if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
@@ -729,7 +796,7 @@ int f, p;
                                        *nfrontp++ = '\0';
                        }
                }
                                        *nfrontp++ = '\0';
                        }
                }
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
                /*
                 * If chars were left over from the terminal driver,
                 * note their existence.
                /*
                 * If chars were left over from the terminal driver,
                 * note their existence.
@@ -739,7 +806,7 @@ int f, p;
                        unpcc = 0;
                        ptyip = unptyip;
                }
                        unpcc = 0;
                        ptyip = unptyip;
                }
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
 
                if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0)
                        netflush();
 
                if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0)
                        netflush();
@@ -770,7 +837,8 @@ interrupt()
        (void) ioctl(pty, TCSIG, (char *)SIGINT);
 #else  /* TCSIG */
        init_termbuf();
        (void) ioctl(pty, TCSIG, (char *)SIGINT);
 #else  /* TCSIG */
        init_termbuf();
-       *pfrontp++ = slctab[SLC_IP].sptr ? *slctab[SLC_IP].sptr : '\177';
+       *pfrontp++ = slctab[SLC_IP].sptr ?
+                       (unsigned char)*slctab[SLC_IP].sptr : '\177';
 #endif /* TCSIG */
 }
 
 #endif /* TCSIG */
 }
 
@@ -786,7 +854,8 @@ sendbrk()
        (void) ioctl(pty, TCSIG, (char *)SIGQUIT);
 #else  /* TCSIG */
        init_termbuf();
        (void) ioctl(pty, TCSIG, (char *)SIGQUIT);
 #else  /* TCSIG */
        init_termbuf();
-       *pfrontp++ = slctab[SLC_ABORT].sptr ? *slctab[SLC_ABORT].sptr : '\034';
+       *pfrontp++ = slctab[SLC_ABORT].sptr ?
+                       (unsigned char)*slctab[SLC_ABORT].sptr : '\034';
 #endif /* TCSIG */
 }
 
 #endif /* TCSIG */
 }
 
@@ -797,14 +866,25 @@ sendsusp()
 # ifdef        TCSIG
        (void) ioctl(pty, TCSIG, (char *)SIGTSTP);
 # else /* TCSIG */
 # ifdef        TCSIG
        (void) ioctl(pty, TCSIG, (char *)SIGTSTP);
 # else /* TCSIG */
-       *pfrontp++ = slctab[SLC_SUSP].sptr ? *slctab[SLC_SUSP].sptr : '\032';
+       *pfrontp++ = slctab[SLC_SUSP].sptr ?
+                       (unsigned char)*slctab[SLC_SUSP].sptr : '\032';
 # endif        /* TCSIG */
 #endif /* SIGTSTP */
 }
 
 doeof()
 {
 # endif        /* TCSIG */
 #endif /* SIGTSTP */
 }
 
 doeof()
 {
+#if    defined(USE_TERMIO) && defined(SYSV_TERMIO)
+       extern char oldeofc;
+#endif
        init_termbuf();
 
        init_termbuf();
 
-       *pfrontp++ = slctab[SLC_EOF].sptr ? *slctab[SLC_EOF].sptr : '\004';
+#if    defined(USE_TERMIO) && defined(SYSV_TERMIO)
+       if (!tty_isediting()) {
+               *pfrontp++ = oldeofc;
+               return;
+       }
+#endif
+       *pfrontp++ = slctab[SLC_EOF].sptr ?
+                       (unsigned char)*slctab[SLC_EOF].sptr : '\004';
 }
 }
index ddadde1..4dc9727 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)termstat.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)termstat.c 5.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -32,7 +32,7 @@ static int def_row = 0, def_col = 0;
 #endif
 #endif LINEMODE
 
 #endif
 #endif LINEMODE
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
 int    newmap = 1;     /* nonzero if \n maps to ^M^J */
 #endif
 
 int    newmap = 1;     /* nonzero if \n maps to ^M^J */
 #endif
 
@@ -115,13 +115,13 @@ localstat()
 {
        void netflush();
 
 {
        void netflush();
 
-#ifdef CRAY2
+#ifdef defined(CRAY2) && defined(UNICOS5)
        /*
         * Keep track of that ol' CR/NL mapping while we're in the
         * neighborhood.
         */
        newmap = tty_isnewmap();
        /*
         * Keep track of that ol' CR/NL mapping while we're in the
         * neighborhood.
         */
        newmap = tty_isnewmap();
-#endif /* CRAY2 */
+#endif defined(CRAY2) && defined(UNICOS5)
 
        /*
         * Check for state of BINARY options.
 
        /*
         * Check for state of BINARY options.
@@ -175,8 +175,10 @@ localstat()
         * pty.  This becomes the test for linemode on/off when
         * using kludge linemode.
         */
         * pty.  This becomes the test for linemode on/off when
         * using kludge linemode.
         */
-       if (lmodetype == KLUDGE_LINEMODE && uselinemode && tty_israw())
+       if (lmodetype == KLUDGE_LINEMODE && uselinemode && tty_israw()) {
                uselinemode = 0;
                uselinemode = 0;
+               tty_setlinemode(uselinemode);
+       }
 # endif        /* KLUDGELINEMODE */
 
        /*
 # endif        /* KLUDGELINEMODE */
 
        /*
@@ -436,7 +438,7 @@ register int code, parm1, parm2;
                 */
                if (terminit() == 0) {
                        def_col = parm1;
                 */
                if (terminit() == 0) {
                        def_col = parm1;
-                       def_row = parm1;
+                       def_row = parm2;
                        return;
                }
 #endif /* LINEMODE */
                        return;
                }
 #endif /* LINEMODE */
@@ -481,18 +483,18 @@ register int code, parm1, parm2;
                break;
        }  /* end of switch */
 
                break;
        }  /* end of switch */
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
        /*
         * Just in case of the likely event that we changed the pty state.
         */
        rcv_ioctl();
        /*
         * Just in case of the likely event that we changed the pty state.
         */
        rcv_ioctl();
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
 
        netflush();
 
 }  /* end of clientstat */
 
 
        netflush();
 
 }  /* end of clientstat */
 
-#ifdef CRAY2
+#if    defined(CRAY2) && defined(UNICOS5)
 termstat()
 {
        needtermstat = 1;
 termstat()
 {
        needtermstat = 1;
@@ -505,7 +507,7 @@ _termstat()
        localstat();
        rcv_ioctl();
 }
        localstat();
        rcv_ioctl();
 }
-#endif /* CRAY2 */
+#endif /* defined(CRAY2) && defined(UNICOS5) */
 
 #ifdef LINEMODE
 /*
 
 #ifdef LINEMODE
 /*