Several fixes. The big one is that all of the
authorDave A. Borman <dab@ucbvax.Berkeley.EDU>
Fri, 21 May 1993 02:38:08 +0000 (18:38 -0800)
committerDave A. Borman <dab@ucbvax.Berkeley.EDU>
Fri, 21 May 1993 02:38:08 +0000 (18:38 -0800)
code that was "#if defined(ENCRYPTION)" is now changed
to "#ifdef ENCRYPTION", so that all the encryption code
can be stripped out using unifdef.
Other fixes:
Add support for HP-UX (untested...)
Simplification of the ENV_HACK stuff
Add in UNICOS 8.0 secure system changes
Clean up the option processing
Fix up the usage() statement

SCCS-vsn: libexec/telnetd/authenc.c 5.3
SCCS-vsn: libexec/telnetd/telnetd.c 5.52
SCCS-vsn: libexec/telnetd/termstat.c 5.14
SCCS-vsn: libexec/telnetd/utility.c 5.12
SCCS-vsn: libexec/telnetd/defs.h 5.12
SCCS-vsn: libexec/telnetd/state.c 5.14
SCCS-vsn: libexec/telnetd/sys_term.c 5.22
SCCS-vsn: libexec/telnetd/ext.h 5.10

usr/src/libexec/telnetd/authenc.c
usr/src/libexec/telnetd/defs.h
usr/src/libexec/telnetd/ext.h
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
usr/src/libexec/telnetd/utility.c

index 0d951d7..186e247 100644 (file)
@@ -6,10 +6,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)authenc.c  5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)authenc.c  5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#if    defined(ENCRYPTION) || defined(AUTHENTICATION)
+#if    defined(AUTHENTICATION) || defined(ENCRYPTION)
 #include "telnetd.h"
 #include <libtelnet/misc.h>
 
 #include "telnetd.h"
 #include <libtelnet/misc.h>
 
@@ -29,13 +29,13 @@ net_write(str, len)
        void
 net_encrypt()
 {
        void
 net_encrypt()
 {
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        char *s = (nclearto > nbackp) ? nclearto : nbackp;
        if (s < nfrontp && encrypt_output) {
                (*encrypt_output)((unsigned char *)s, nfrontp - s);
        }
        nclearto = nfrontp;
        char *s = (nclearto > nbackp) ? nclearto : nbackp;
        if (s < nfrontp && encrypt_output) {
                (*encrypt_output)((unsigned char *)s, nfrontp - s);
        }
        nclearto = nfrontp;
-#endif
+#endif /* ENCRYPTION */
 }
 
        int
 }
 
        int
@@ -62,4 +62,4 @@ telnet_gets(prompt, result, length, echo)
 {
        return((char *)0);
 }
 {
        return((char *)0);
 }
-#endif
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
index 215baec..00d3794 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)defs.h      5.11 (Berkeley) %G%
+ *     @(#)defs.h      5.12 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -120,6 +120,10 @@ typedef unsigned char cc_t;
 #include <memory.h>
 #endif /* CRAY */
 
 #include <memory.h>
 #endif /* CRAY */
 
+#ifdef __hpux
+#include <sys/ptyio.h>
+#endif
+
 #if    !defined(TIOCSCTTY) && defined(TCSETCTTY)
 # define       TIOCSCTTY TCSETCTTY
 #endif
 #if    !defined(TIOCSCTTY) && defined(TCSETCTTY)
 # define       TIOCSCTTY TCSETCTTY
 #endif
index 426505c..d7dc54f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ext.h       5.9 (Berkeley) %G%
+ *     @(#)ext.h       5.10 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -130,7 +130,9 @@ extern void
 extern int
        end_slc P((unsigned char **)),
        getnpty P((void)),
 extern int
        end_slc P((unsigned char **)),
        getnpty P((void)),
-       getpty P((void)),
+#ifndef convex
+       getpty P((int *)),
+#endif convex
        login_tty P((int)),
        spcset P((int, cc_t *, cc_t **)),
        stilloob P((int)),
        login_tty P((int)),
        spcset P((int, cc_t *, cc_t **)),
        stilloob P((int)),
@@ -163,11 +165,11 @@ extern void
        wontoption P((int)),
        writenet P((unsigned char *, int));
 
        wontoption P((int)),
        writenet P((unsigned char *, int));
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
 extern void    (*encrypt_output) P((unsigned char *, int));
 extern int     (*decrypt_input) P((int));
 extern char    *nclearto;
 extern void    (*encrypt_output) P((unsigned char *, int));
 extern int     (*decrypt_input) P((int));
 extern char    *nclearto;
-#endif
+#endif /* ENCRYPTION */
 
 
 /*
 
 
 /*
index 5314a4a..a4f8b23 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)state.c    5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)state.c    5.14 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -68,10 +68,10 @@ telrcv()
                if ((&ptyobuf[BUFSIZ] - pfrontp) < 2)
                        break;
                c = *netip++ & 0377, ncc--;
                if ((&ptyobuf[BUFSIZ] - pfrontp) < 2)
                        break;
                c = *netip++ & 0377, ncc--;
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
                if (decrypt_input)
                        c = (*decrypt_input)(c);
                if (decrypt_input)
                        c = (*decrypt_input)(c);
-#endif
+#endif /* ENCRYPTION */
                switch (state) {
 
                case TS_CR:
                switch (state) {
 
                case TS_CR:
@@ -100,10 +100,10 @@ telrcv()
                         */
                        if ((c == '\r') && his_state_is_wont(TELOPT_BINARY)) {
                                int nc = *netip;
                         */
                        if ((c == '\r') && his_state_is_wont(TELOPT_BINARY)) {
                                int nc = *netip;
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
                                if (decrypt_input)
                                        nc = (*decrypt_input)(nc & 0xff);
                                if (decrypt_input)
                                        nc = (*decrypt_input)(nc & 0xff);
-#endif
+#endif /* ENCRYPTION */
 #ifdef LINEMODE
                                /*
                                 * If we are operating in linemode,
 #ifdef LINEMODE
                                /*
                                 * If we are operating in linemode,
@@ -116,10 +116,10 @@ telrcv()
                                } else
 #endif
                                {
                                } else
 #endif
                                {
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
                                        if (decrypt_input)
                                                (void)(*decrypt_input)(-1);
                                        if (decrypt_input)
                                                (void)(*decrypt_input)(-1);
-#endif
+#endif /* ENCRYPTION */
                                        state = TS_CR;
                                }
                        }
                                        state = TS_CR;
                                }
                        }
@@ -440,7 +440,7 @@ extern void doclientstat();
 #endif
 #ifdef ENCRYPTION
 extern void encrypt_send_support();
 #endif
 #ifdef ENCRYPTION
 extern void encrypt_send_support();
-#endif
+#endif /* ENCRYPTION */
 
        void
 willoption(option)
 
        void
 willoption(option)
@@ -558,7 +558,7 @@ willoption(option)
                        func = encrypt_send_support;
                        changeok++;
                        break;
                        func = encrypt_send_support;
                        changeok++;
                        break;
-#endif
+#endif /* ENCRYPTION */
 
                default:
                        break;
 
                default:
                        break;
@@ -622,7 +622,7 @@ willoption(option)
                case TELOPT_ENCRYPT:
                        func = encrypt_send_support;
                        break;
                case TELOPT_ENCRYPT:
                        func = encrypt_send_support;
                        break;
-#endif
+#endif /* ENCRYPTION */
                case TELOPT_LFLOW:
                        func = flowstat;
                        break;
                case TELOPT_LFLOW:
                        func = flowstat;
                        break;
@@ -909,11 +909,11 @@ dooption(option)
                        /* NOT REACHED */
                        break;
 
                        /* NOT REACHED */
                        break;
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
                case TELOPT_ENCRYPT:
                        changeok++;
                        break;
                case TELOPT_ENCRYPT:
                        changeok++;
                        break;
-#endif
+#endif /* ENCRYPTION */
                case TELOPT_LINEMODE:
                case TELOPT_TTYPE:
                case TELOPT_NAWS:
                case TELOPT_LINEMODE:
                case TELOPT_TTYPE:
                case TELOPT_NAWS:
@@ -1316,22 +1316,14 @@ suboption()
                 * If we got exactly as many VALUEs as VARs and
                 * USERVARs, the client has the same definitions.
                 *
                 * If we got exactly as many VALUEs as VARs and
                 * USERVARs, the client has the same definitions.
                 *
-                * If we get more VARs than the total number of VALUEs
-                * and USERVARs, the client has the same definitions.
-                *
                 * If we got exactly as many VARs as VALUEs and
                 * USERVARS, the client has reversed definitions.
                 * If we got exactly as many VARs as VALUEs and
                 * USERVARS, the client has reversed definitions.
-                *
-                * If we get more VALUEs than the total number of VARs
-                * and USERVARs, the client has reversed definitions
                 */
                 */
-               if ((got_uservar + got_var == got_value) ||
-                   (got_var > got_uservar + got_value)) {
+               if (got_uservar + got_var == got_value) {
            env_var_ok:
                        env_var = ENV_VAR;
                        env_value = ENV_VALUE;
            env_var_ok:
                        env_var = ENV_VAR;
                        env_value = ENV_VALUE;
-               } else if ((got_uservar + got_value == got_var) ||
-                          (got_value > got_uservar + got_var)) {
+               } else if (got_uservar + got_value == got_var) {
            env_var_wrong:
                        env_var = ENV_VALUE;
                        env_value = ENV_VAR;
            env_var_wrong:
                        env_var = ENV_VALUE;
                        env_value = ENV_VAR;
@@ -1420,7 +1412,7 @@ suboption()
        }
        break;
 #endif
        }
        break;
 #endif
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     case TELOPT_ENCRYPT:
        if (SB_EOF())
                break;
     case TELOPT_ENCRYPT:
        if (SB_EOF())
                break;
@@ -1462,7 +1454,7 @@ suboption()
                break;
        }
        break;
                break;
        }
        break;
-#endif
+#endif /* ENCRYPTION */
 
     default:
        break;
 
     default:
        break;
index c841ef3..7a485d1 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sys_term.c 5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_term.c 5.22 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -16,8 +16,13 @@ static char sccsid[] = "@(#)sys_term.c       5.21 (Berkeley) %G%";
 #include <libtelnet/auth.h>
 #endif
 
 #include <libtelnet/auth.h>
 #endif
 
+#if defined(CRAY) || defined(__hpux)
+# define PARENT_DOES_UTMP
+#endif
+
 #ifdef NEWINIT
 #include <initreq.h>
 #ifdef NEWINIT
 #include <initreq.h>
+int    utmp_len = MAXHOSTNAMELEN;      /* sizeof(init_request.host) */
 #else  /* NEWINIT*/
 # ifdef        UTMPX
 # include <utmpx.h>
 #else  /* NEWINIT*/
 # ifdef        UTMPX
 # include <utmpx.h>
@@ -27,13 +32,25 @@ static char sccsid[] = "@(#)sys_term.c      5.21 (Berkeley) %G%";
 struct utmp wtmp;
 
 int    utmp_len = sizeof(wtmp.ut_host);
 struct utmp wtmp;
 
 int    utmp_len = sizeof(wtmp.ut_host);
-# ifndef CRAY
+# ifndef PARENT_DOES_UTMP
 char   wtmpf[] = "/usr/adm/wtmp";
 char   utmpf[] = "/etc/utmp";
 char   wtmpf[] = "/usr/adm/wtmp";
 char   utmpf[] = "/etc/utmp";
-# else /* CRAY */
+# else /* PARENT_DOES_UTMP */
 char   wtmpf[] = "/etc/wtmp";
 char   wtmpf[] = "/etc/wtmp";
+# endif /* PARENT_DOES_UTMP */
+
+# ifdef CRAY
 #include <tmpdir.h>
 #include <sys/wait.h>
 #include <tmpdir.h>
 #include <sys/wait.h>
+#  if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
+   /*
+    * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
+    * use it to tell us to turn off all the socket security code,
+    * since that is only used in UNICOS 7.0 and later.
+    */
+#   undef _SC_CRAY_SECURE_SYS
+#  endif
+
 #  if defined(_SC_CRAY_SECURE_SYS)
 #include <sys/sysv.h>
 #include <sys/secstat.h>
 #  if defined(_SC_CRAY_SECURE_SYS)
 #include <sys/sysv.h>
 #include <sys/secstat.h>
@@ -54,6 +71,10 @@ extern struct sysv sysv;
 #ifdef STREAMS
 #include <sys/stream.h>
 #endif
 #ifdef STREAMS
 #include <sys/stream.h>
 #endif
+#ifdef __hpux
+#include <sys/resource.h>
+#include <sys/proc.h>
+#endif
 #include <sys/tty.h>
 #ifdef t_erase
 #undef t_erase
 #include <sys/tty.h>
 #ifdef t_erase
 #undef t_erase
@@ -425,7 +446,8 @@ char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 #endif /* CRAY */
 
        int
 #endif /* CRAY */
 
        int
-getpty()
+getpty(ptynum)
+int *ptynum;
 {
        register int p;
 #ifdef STREAMSPTY
 {
        register int p;
 #ifdef STREAMSPTY
@@ -448,9 +470,15 @@ getpty()
        int dummy;
 #endif
 
        int dummy;
 #endif
 
+#ifndef        __hpux
        (void) sprintf(line, "/dev/ptyXX");
        p1 = &line[8];
        p2 = &line[9];
        (void) sprintf(line, "/dev/ptyXX");
        p1 = &line[8];
        p2 = &line[9];
+#else
+       (void) sprintf(line, "/dev/ptym/ptyXX");
+       p1 = &line[13];
+       p2 = &line[14];
+#endif
 
        for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) {
                struct stat stb;
 
        for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) {
                struct stat stb;
@@ -468,7 +496,13 @@ getpty()
                        *p2 = "0123456789abcdef"[i];
                        p = open(line, 2);
                        if (p > 0) {
                        *p2 = "0123456789abcdef"[i];
                        p = open(line, 2);
                        if (p > 0) {
+#ifndef        __hpux
                                line[5] = 't';
                                line[5] = 't';
+#else
+                               for (p1 = &line[8]; *p1; p1++)
+                                       *p1 = *(p1+1);
+                               line[9] = 't';
+#endif
                                chown(line, 0, 0);
                                chmod(line, 0600);
 #if defined(sun) && defined(TIOCGPGRP) && BSD < 199207
                                chown(line, 0, 0);
                                chmod(line, 0600);
 #if defined(sun) && defined(TIOCGPGRP) && BSD < 199207
@@ -484,16 +518,15 @@ getpty()
                }
        }
 #else  /* CRAY */
                }
        }
 #else  /* CRAY */
-       register int npty;
        extern lowpty, highpty;
        struct stat sb;
 
        extern lowpty, highpty;
        struct stat sb;
 
-       for (npty = lowpty; npty <= highpty; npty++) {
-               (void) sprintf(myline, "/dev/pty/%03d", npty);
+       for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) {
+               (void) sprintf(myline, "/dev/pty/%03d", *ptynum);
                p = open(myline, 2);
                if (p < 0)
                        continue;
                p = open(myline, 2);
                if (p < 0)
                        continue;
-               (void) sprintf(line, "/dev/ttyp%03d", npty);
+               (void) sprintf(line, "/dev/ttyp%03d", *ptynum);
                /*
                 * Here are some shenanigans to make sure that there
                 * are no listeners lurking on the line.
                /*
                 * Here are some shenanigans to make sure that there
                 * are no listeners lurking on the line.
@@ -912,7 +945,7 @@ tty_isnewmap()
 }
 #endif
 
 }
 #endif
 
-#ifdef CRAY
+#ifdef PARENT_DOES_UTMP
 # ifndef NEWINIT
 extern struct utmp wtmp;
 extern char wtmpf[];
 # ifndef NEWINIT
 extern struct utmp wtmp;
 extern char wtmpf[];
@@ -927,15 +960,15 @@ nologinproc(sig)
        gotalarm++;
 }
 # endif        /* NEWINIT */
        gotalarm++;
 }
 # endif        /* NEWINIT */
-#endif /* CRAY */
+#endif /* PARENT_DOES_UTMP */
 
 #ifndef        NEWINIT
 
 #ifndef        NEWINIT
-# ifdef        CRAY
+# ifdef PARENT_DOES_UTMP
 extern void utmp_sig_init P((void));
 extern void utmp_sig_reset P((void));
 extern void utmp_sig_wait P((void));
 extern void utmp_sig_notify P((int));
 extern void utmp_sig_init P((void));
 extern void utmp_sig_reset P((void));
 extern void utmp_sig_wait P((void));
 extern void utmp_sig_notify P((int));
-# endif
+# endif /* PARENT_DOES_UTMP */
 #endif
 
 /*
 #endif
 
 /*
@@ -985,7 +1018,7 @@ getptyslave()
 # endif
 
 
 # endif
 
 
-# ifdef        CRAY
+# ifdef PARENT_DOES_UTMP
        /*
         * Wait for our parent to get the utmp stuff to get done.
         */
        /*
         * Wait for our parent to get the utmp stuff to get done.
         */
@@ -1031,9 +1064,9 @@ getptyslave()
 # endif        /* USE_TERMIO */
 
        /*
 # endif        /* USE_TERMIO */
 
        /*
-        * Settings for UNICOS
+        * Settings for UNICOS (and HPUX)
         */
         */
-# ifdef        CRAY
+# if defined(CRAY) || defined(__hpux)
        termbuf.c_oflag = OPOST|ONLCR|TAB3;
        termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
        termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
        termbuf.c_oflag = OPOST|ONLCR|TAB3;
        termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
        termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
@@ -1045,7 +1078,7 @@ getptyslave()
         * systems, other than 4.4BSD.  In 4.4BSD the
         * kernel does the initial terminal setup.
         */
         * systems, other than 4.4BSD.  In 4.4BSD the
         * kernel does the initial terminal setup.
         */
-# if defined(USE_TERMIO) && !defined(CRAY) && (BSD <= 43)
+# if defined(USE_TERMIO) && !(defined(CRAY) || defined(__hpux)) && (BSD <= 43)
 #  ifndef      OXTABS
 #   define OXTABS      0
 #  endif
 #  ifndef      OXTABS
 #   define OXTABS      0
 #  endif
@@ -1132,7 +1165,7 @@ cleanopen(line)
         * Hangup anybody else using this ttyp, then reopen it for
         * ourselves.
         */
         * Hangup anybody else using this ttyp, then reopen it for
         * ourselves.
         */
-# if !defined(CRAY) && (BSD <= 43) && !defined(STREAMSPTY)
+# if !(defined(CRAY) || defined(__hpux)) && (BSD <= 43) && !defined(STREAMSPTY)
        (void) signal(SIGHUP, SIG_IGN);
        vhangup();
        (void) signal(SIGHUP, SIG_DFL);
        (void) signal(SIGHUP, SIG_IGN);
        vhangup();
        (void) signal(SIGHUP, SIG_DFL);
@@ -1253,14 +1286,14 @@ startslave(host, autologin, autoname)
 #endif
 
 #ifndef        NEWINIT
 #endif
 
 #ifndef        NEWINIT
-# ifdef        CRAY
+# ifdef        PARENT_DOES_UTMP
        utmp_sig_init();
        utmp_sig_init();
-# endif        /* CRAY */
+# endif        /* PARENT_DOES_UTMP */
 
        if ((i = fork()) < 0)
                fatalperror(net, "fork");
        if (i) {
 
        if ((i = fork()) < 0)
                fatalperror(net, "fork");
        if (i) {
-# ifdef        CRAY
+# ifdef PARENT_DOES_UTMP
                /*
                 * Cray parent will create utmp entry for child and send
                 * signal to child to tell when done.  Child waits for signal
                /*
                 * Cray parent will create utmp entry for child and send
                 * signal to child to tell when done.  Child waits for signal
@@ -1280,16 +1313,22 @@ startslave(host, autologin, autoname)
                SCPYN(wtmp.ut_user, "LOGIN");
                SCPYN(wtmp.ut_host, host);
                SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1);
                SCPYN(wtmp.ut_user, "LOGIN");
                SCPYN(wtmp.ut_host, host);
                SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1);
+#ifndef        __hpux
                SCPYN(wtmp.ut_id, wtmp.ut_line+3);
                SCPYN(wtmp.ut_id, wtmp.ut_line+3);
+#else
+               SCPYN(wtmp.ut_id, wtmp.ut_line+7);
+#endif
                pututline(&wtmp);
                endutent();
                if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
                        (void) write(i, (char *)&wtmp, sizeof(struct utmp));
                        (void) close(i);
                }
                pututline(&wtmp);
                endutent();
                if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
                        (void) write(i, (char *)&wtmp, sizeof(struct utmp));
                        (void) close(i);
                }
+#ifdef CRAY
                (void) signal(WJSIGNAL, sigjob);
                (void) signal(WJSIGNAL, sigjob);
+#endif
                utmp_sig_notify(pid);
                utmp_sig_notify(pid);
-# endif        /* CRAY */
+# endif        /* PARENT_DOES_UTMP */
        } else {
                getptyslave();
                start_login(host, autologin, autoname);
        } else {
                getptyslave();
                start_login(host, autologin, autoname);
@@ -1363,7 +1402,7 @@ init_env()
        envp = envinit;
        if (*envp = getenv("TZ"))
                *envp++ -= 3;
        envp = envinit;
        if (*envp = getenv("TZ"))
                *envp++ -= 3;
-#ifdef CRAY
+#if    defined(CRAY) || defined(__hpux)
        else
                *envp++ = "TZ=GMT0";
 #endif
        else
                *envp++ = "TZ=GMT0";
 #endif
@@ -1426,8 +1465,10 @@ start_login(host, autologin, name)
         * -f : force this login, he has already been authenticated
         */
        argv = addarg(0, "login");
         * -f : force this login, he has already been authenticated
         */
        argv = addarg(0, "login");
+#if    !defined(NO_LOGIN_H)
        argv = addarg(argv, "-h");
        argv = addarg(argv, host);
        argv = addarg(argv, "-h");
        argv = addarg(argv, host);
+#endif
 #ifdef __svr4__
        /*
         * SVR4 version of -h takes TERM= as second arg, or -
 #ifdef __svr4__
        /*
         * SVR4 version of -h takes TERM= as second arg, or -
@@ -1473,7 +1514,7 @@ start_login(host, autologin, name)
 #endif
        if (getenv("USER")) {
                argv = addarg(argv, getenv("USER"));
 #endif
        if (getenv("USER")) {
                argv = addarg(argv, getenv("USER"));
-#if    defined(CRAY) && defined(NO_LOGIN_P)
+#if    (defined(CRAY) || defined(__hpux)) && defined(NO_LOGIN_P)
                {
                        register char **cpp;
                        for (cpp = environ; *cpp; cpp++)
                {
                        register char **cpp;
                        for (cpp = environ; *cpp; cpp++)
@@ -1545,7 +1586,7 @@ addarg(argv, val)
 cleanup(sig)
        int sig;
 {
 cleanup(sig)
        int sig;
 {
-#ifndef        CRAY
+#ifndef        PARENT_DOES_UTMP
 # if (BSD > 43) || defined(convex)
        char *p;
 
 # if (BSD > 43) || defined(convex)
        char *p;
 
@@ -1567,11 +1608,12 @@ cleanup(sig)
        (void) shutdown(net, 2);
        exit(1);
 # endif
        (void) shutdown(net, 2);
        exit(1);
 # endif
-#else  /* CRAY */
+#else  /* PARENT_DOES_UTMP */
 # ifdef        NEWINIT
        (void) shutdown(net, 2);
        exit(1);
 # else /* NEWINIT */
 # ifdef        NEWINIT
        (void) shutdown(net, 2);
        exit(1);
 # else /* NEWINIT */
+#  ifdef CRAY
        static int incleanup = 0;
        register int t;
 
        static int incleanup = 0;
        register int t;
 
@@ -1594,20 +1636,32 @@ cleanup(sig)
        }
        incleanup = 1;
        sigsetmask(t);
        }
        incleanup = 1;
        sigsetmask(t);
+       if (secflag) {
+               /*
+                *      We need to set ourselves back to a null
+                *      label to clean up.
+                */
+
+               setulvl(sysv.sy_minlvl);
+               setucmp((long)0);
+       }
 
        t = cleantmp(&wtmp);
        setutent();     /* just to make sure */
 
        t = cleantmp(&wtmp);
        setutent();     /* just to make sure */
+#  endif /* CRAY */
        rmut(line);
        close(pty);
        (void) shutdown(net, 2);
        rmut(line);
        close(pty);
        (void) shutdown(net, 2);
+#  ifdef CRAY
        if (t == 0)
                cleantmp(&wtmp);
        if (t == 0)
                cleantmp(&wtmp);
+#  endif /* CRAY */
        exit(1);
 # endif        /* NEWINT */
        exit(1);
 # endif        /* NEWINT */
-#endif /* CRAY */
+#endif /* PARENT_DOES_UTMP */
 }
 
 }
 
-#if    defined(CRAY) && !defined(NEWINIT)
+#if defined(PARENT_DOES_UTMP) && !defined(NEWINIT)
 /*
  * _utmp_sig_rcv
  * utmp_sig_init
 /*
  * _utmp_sig_rcv
  * utmp_sig_init
@@ -1645,6 +1699,11 @@ utmp_sig_reset()
        (void) signal(SIGUSR1, func);   /* reset handler to default */
 }
 
        (void) signal(SIGUSR1, func);   /* reset handler to default */
 }
 
+# ifdef __hpux
+# define sigoff() /* do nothing */
+# define sigon() /* do nothing */
+# endif
+
        void
 utmp_sig_wait()
 {
        void
 utmp_sig_wait()
 {
@@ -1665,6 +1724,7 @@ utmp_sig_notify(pid)
        kill(pid, SIGUSR1);
 }
 
        kill(pid, SIGUSR1);
 }
 
+# ifdef CRAY
 static int gotsigjob = 0;
 
        /*ARGSUSED*/
 static int gotsigjob = 0;
 
        /*ARGSUSED*/
@@ -1782,7 +1842,8 @@ cleantmpdir(jid, tpath, user)
                break;
        }
 }
                break;
        }
 }
-#endif /* defined(CRAY) && !defined(NEWINIT) */
+# endif /* CRAY */
+#endif /* defined(PARENT_DOES_UTMP) && !defined(NEWINIT) */
 
 /*
  * rmut()
 
 /*
  * rmut()
@@ -1820,7 +1881,7 @@ rmut()
 }  /* end of rmut */
 #endif
 
 }  /* end of rmut */
 #endif
 
-#if    !defined(UTMPX) && !defined(CRAY) && BSD <= 43
+#if    !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43
        void
 rmut()
 {
        void
 rmut()
 {
@@ -1872,3 +1933,42 @@ rmut()
        (void) chown(line, 0, 0);
 }  /* end of rmut */
 #endif /* CRAY */
        (void) chown(line, 0, 0);
 }  /* end of rmut */
 #endif /* CRAY */
+
+#ifdef __hpux
+rmut (line)
+char *line;
+{
+       struct utmp utmp;
+       struct utmp *utptr;
+       int fd;                 /* for /etc/wtmp */
+
+       utmp.ut_type = USER_PROCESS;
+       (void) strncpy(utmp.ut_id, line+12, sizeof(utmp.ut_id));
+       (void) setutent();
+       utptr = getutid(&utmp);
+       /* write it out only if it exists */
+       if (utptr) {
+               utptr->ut_type = DEAD_PROCESS;
+               utptr->ut_time = time((long *) 0);
+               (void) pututline(utptr);
+               /* set wtmp entry if wtmp file exists */
+               if ((fd = open(wtmpf, O_WRONLY | O_APPEND)) >= 0) {
+                       (void) write(fd, utptr, sizeof(utmp));
+                       (void) close(fd);
+               }
+       }
+       (void) endutent();
+
+       (void) chmod(line, 0666);
+       (void) chown(line, 0, 0);
+       line[14] = line[13];
+       line[13] = line[12];
+       line[8] = 'm';
+       line[9] = '/';
+       line[10] = 'p';
+       line[11] = 't';
+       line[12] = 'y';
+       (void) chmod(line, 0666);
+       (void) chown(line, 0, 0);
+}
+#endif
index 1faeb8a..d4032c9 100644 (file)
@@ -12,20 +12,37 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.51 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.52 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #include "pathnames.h"
 
 #endif /* not lint */
 
 #include "telnetd.h"
 #include "pathnames.h"
 
+#if    defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
+/*
+ * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
+ * use it to tell us to turn off all the socket security code,
+ * since that is only used in UNICOS 7.0 and later.
+ */
+# undef _SC_CRAY_SECURE_SYS
+#endif
+
 #if    defined(_SC_CRAY_SECURE_SYS)
 #include <sys/sysv.h>
 #include <sys/secdev.h>
 #if    defined(_SC_CRAY_SECURE_SYS)
 #include <sys/sysv.h>
 #include <sys/secdev.h>
+# ifdef SO_SEC_MULTI           /* 8.0 code */
+#include <sys/secparm.h>
+#include <sys/usrv.h>
+# endif /* SO_SEC_MULTI */
 int    secflag;
 char   tty_dev[16];
 struct secdev dv;
 struct sysv sysv;
 int    secflag;
 char   tty_dev[16];
 struct secdev dv;
 struct sysv sysv;
+# ifdef SO_SEC_MULTI           /* 8.0 code */
+struct socksec ss;
+# else /* SO_SEC_MULTI */      /* 7.0 code */
 struct socket_security ss;
 struct socket_security ss;
+# endif /* SO_SEC_MULTI */
 #endif /* _SC_CRAY_SECURE_SYS */
 
 #if    defined(AUTHENTICATION)
 #endif /* _SC_CRAY_SECURE_SYS */
 
 #if    defined(AUTHENTICATION)
@@ -84,6 +101,40 @@ char *progname;
 
 extern void usage P((void));
 
 
 extern void usage P((void));
 
+/*
+ * The string to pass to getopt().  We do it this way so
+ * that only the actual options that we support will be
+ * passed off to getopt().
+ */
+char valid_opts[] = {
+       'd', ':', 'h', 'k', 'n', 'S', ':', 'u', ':', 'U',
+#ifdef AUTHENTICATION
+       'a', ':', 'X', ':',
+#endif
+#ifdef BFTPDAEMON
+       'B',
+#endif
+#ifdef DIAGNOSTICS
+       'D', ':',
+#endif
+#ifdef ENCRYPTION
+       'e', ':',
+#endif
+#if    defined(CRAY) && defined(NEWINIT)
+       'I', ':',
+#endif
+#ifdef LINEMODE
+       'l',
+#endif
+#ifdef CRAY
+       'r', ':',
+#endif
+#ifdef SecurID
+       's',
+#endif
+       '\0'
+};
+
 main(argc, argv)
        char *argv[];
 {
 main(argc, argv)
        char *argv[];
 {
@@ -99,9 +150,9 @@ main(argc, argv)
        pfrontp = pbackp = ptyobuf;
        netip = netibuf;
        nfrontp = nbackp = netobuf;
        pfrontp = pbackp = ptyobuf;
        netip = netibuf;
        nfrontp = nbackp = netobuf;
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        nclearto = 0;
        nclearto = 0;
-#endif
+#endif /* ENCRYPTION */
 
        progname = *argv;
 
 
        progname = *argv;
 
@@ -113,7 +164,7 @@ main(argc, argv)
        highpty = getnpty();
 #endif /* CRAY */
 
        highpty = getnpty();
 #endif /* CRAY */
 
-       while ((ch = getopt(argc, argv, "d:a:e:klhnr:u:UI:D:B:sS:a:X:")) != EOF) {
+       while ((ch = getopt(argc, argv, valid_opts)) != EOF) {
                switch(ch) {
 
 #ifdef AUTHENTICATION
                switch(ch) {
 
 #ifdef AUTHENTICATION
@@ -288,7 +339,7 @@ main(argc, argv)
 #endif /* AUTHENTICATION */
 
                default:
 #endif /* AUTHENTICATION */
 
                default:
-                       fprintf(stderr, "telnetd: %s: unknown option\n", ch);
+                       fprintf(stderr, "telnetd: %c: unknown option\n", ch);
                        /* FALLTHROUGH */
                case '?':
                        usage();
                        /* FALLTHROUGH */
                case '?':
                        usage();
@@ -365,10 +416,14 @@ main(argc, argv)
        secflag = sysconf(_SC_CRAY_SECURE_SYS);
 
        /*
        secflag = sysconf(_SC_CRAY_SECURE_SYS);
 
        /*
-        *      Get socket's security label 
+        *      Get socket's security label
         */
        if (secflag)  {
         */
        if (secflag)  {
-               int sz = sizeof(ss);
+               int szss = sizeof(ss);
+#ifdef SO_SEC_MULTI                    /* 8.0 code */
+               int sock_multi;
+               int szi = sizeof(int);
+#endif /* SO_SEC_MULTI */
 
                bzero((char *)&dv, sizeof(dv));
 
 
                bzero((char *)&dv, sizeof(dv));
 
@@ -378,18 +433,39 @@ main(argc, argv)
                }
 
                /*
                }
 
                /*
-                *      Get socket security label and set device values
-                *         {security label to be set on ttyp device}
+                *      Get socket security label and set device values
+                *         {security label to be set on ttyp device}
                 */
                 */
+#ifdef SO_SEC_MULTI                    /* 8.0 code */
+               if ((getsockopt(0, SOL_SOCKET, SO_SECURITY,
+                              (char *)&ss, &szss) < 0) ||
+                   (getsockopt(0, SOL_SOCKET, SO_SEC_MULTI,
+                               (char *)&sock_multi, &szi) < 0)) {
+                       perror("getsockopt");
+                       exit(1);
+               } else {
+                       dv.dv_actlvl = ss.ss_actlabel.lt_level;
+                       dv.dv_actcmp = ss.ss_actlabel.lt_compart;
+                       if (!sock_multi) {
+                               dv.dv_minlvl = dv.dv_maxlvl = dv.dv_actlvl;
+                               dv.dv_valcmp = dv.dv_actcmp;
+                       } else {
+                               dv.dv_minlvl = ss.ss_minlabel.lt_level;
+                               dv.dv_maxlvl = ss.ss_maxlabel.lt_level;
+                               dv.dv_valcmp = ss.ss_maxlabel.lt_compart;
+                       }
+                       dv.dv_devflg = 0;
+               }
+#else /* SO_SEC_MULTI */               /* 7.0 code */
                if (getsockopt(0, SOL_SOCKET, SO_SECURITY,
                if (getsockopt(0, SOL_SOCKET, SO_SECURITY,
-                               (char *)&ss, &sz) >= 0) {
-
+                               (char *)&ss, &szss) >= 0) {
                        dv.dv_actlvl = ss.ss_slevel;
                        dv.dv_actcmp = ss.ss_compart;
                        dv.dv_minlvl = ss.ss_minlvl;
                        dv.dv_maxlvl = ss.ss_maxlvl;
                        dv.dv_valcmp = ss.ss_maxcmp;
                }
                        dv.dv_actlvl = ss.ss_slevel;
                        dv.dv_actcmp = ss.ss_compart;
                        dv.dv_minlvl = ss.ss_minlvl;
                        dv.dv_maxlvl = ss.ss_maxlvl;
                        dv.dv_valcmp = ss.ss_maxcmp;
                }
+#endif /* SO_SEC_MULTI */
        }
 #endif /* _SC_CRAY_SECURE_SYS */
 
        }
 #endif /* _SC_CRAY_SECURE_SYS */
 
@@ -432,7 +508,7 @@ usage()
 {
        fprintf(stderr, "Usage: telnetd");
 #ifdef AUTHENTICATION
 {
        fprintf(stderr, "Usage: telnetd");
 #ifdef AUTHENTICATION
-       fprintf(stderr, " [-a (debug|other|user|valid|off)]\n\t");
+       fprintf(stderr, " [-a (debug|other|user|valid|off|none)]\n\t");
 #endif
 #ifdef BFTPDAEMON
        fprintf(stderr, " [-B]");
 #endif
 #ifdef BFTPDAEMON
        fprintf(stderr, " [-B]");
@@ -448,6 +524,9 @@ usage()
 #if    defined(CRAY) && defined(NEWINIT)
        fprintf(stderr, " [-Iinitid]");
 #endif
 #if    defined(CRAY) && defined(NEWINIT)
        fprintf(stderr, " [-Iinitid]");
 #endif
+#if    defined(LINEMODE) && defined(KLUDGELINEMODE)
+       fprintf(stderr, " [-k]");
+#endif
 #ifdef LINEMODE
        fprintf(stderr, " [-l]");
 #endif
 #ifdef LINEMODE
        fprintf(stderr, " [-l]");
 #endif
@@ -455,9 +534,13 @@ usage()
 #ifdef CRAY
        fprintf(stderr, " [-r[lowpty]-[highpty]]");
 #endif
 #ifdef CRAY
        fprintf(stderr, " [-r[lowpty]-[highpty]]");
 #endif
+       fprintf(stderr, "\n\t");
 #ifdef SecurID
        fprintf(stderr, " [-s]");
 #endif
 #ifdef SecurID
        fprintf(stderr, " [-s]");
 #endif
+#ifdef HAS_GETTOS
+       fprintf(stderr, " [-S tos]");
+#endif
 #ifdef AUTHENTICATION
        fprintf(stderr, " [-X auth-type]");
 #endif
 #ifdef AUTHENTICATION
        fprintf(stderr, " [-X auth-type]");
 #endif
@@ -494,24 +577,24 @@ getterminaltype(name)
     }
 #endif
 
     }
 #endif
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     send_will(TELOPT_ENCRYPT, 1);
     send_will(TELOPT_ENCRYPT, 1);
-#endif
+#endif /* ENCRYPTION */
     send_do(TELOPT_TTYPE, 1);
     send_do(TELOPT_TSPEED, 1);
     send_do(TELOPT_XDISPLOC, 1);
     send_do(TELOPT_ENVIRON, 1);
     while (
     send_do(TELOPT_TTYPE, 1);
     send_do(TELOPT_TSPEED, 1);
     send_do(TELOPT_XDISPLOC, 1);
     send_do(TELOPT_ENVIRON, 1);
     while (
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
           his_do_dont_is_changing(TELOPT_ENCRYPT) ||
           his_do_dont_is_changing(TELOPT_ENCRYPT) ||
-#endif
+#endif /* ENCRYPTION */
           his_will_wont_is_changing(TELOPT_TTYPE) ||
           his_will_wont_is_changing(TELOPT_TSPEED) ||
           his_will_wont_is_changing(TELOPT_XDISPLOC) ||
           his_will_wont_is_changing(TELOPT_ENVIRON)) {
        ttloop();
     }
           his_will_wont_is_changing(TELOPT_TTYPE) ||
           his_will_wont_is_changing(TELOPT_TSPEED) ||
           his_will_wont_is_changing(TELOPT_XDISPLOC) ||
           his_will_wont_is_changing(TELOPT_ENVIRON)) {
        ttloop();
     }
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     /*
      * Wait for the negotiation of what type of encryption we can
      * send with.  If autoencrypt is not set, this will just return.
     /*
      * Wait for the negotiation of what type of encryption we can
      * send with.  If autoencrypt is not set, this will just return.
@@ -519,7 +602,7 @@ getterminaltype(name)
     if (his_state_is_will(TELOPT_ENCRYPT)) {
        encrypt_wait();
     }
     if (his_state_is_will(TELOPT_ENCRYPT)) {
        encrypt_wait();
     }
-#endif
+#endif /* ENCRYPTION */
     if (his_state_is_will(TELOPT_TSPEED)) {
        static char sbbuf[] = { IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
 
     if (his_state_is_will(TELOPT_TSPEED)) {
        static char sbbuf[] = { IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
 
@@ -661,13 +744,14 @@ doit(who)
        int t;
        struct hostent *hp;
        int level;
        int t;
        struct hostent *hp;
        int level;
+       int ptynum;
        char user_name[256];
 
        /*
         * Find an available pty to use.
         */
 #ifndef        convex
        char user_name[256];
 
        /*
         * Find an available pty to use.
         */
 #ifndef        convex
-       pty = getpty();
+       pty = getpty(&ptynum);
        if (pty < 0)
                fatal(net, "All network ports in use");
 #else
        if (pty < 0)
                fatal(net, "All network ports in use");
 #else
@@ -691,9 +775,14 @@ doit(who)
         *      set ttyp line security label 
         */
        if (secflag) {
         *      set ttyp line security label 
         */
        if (secflag) {
-               extern char *myline;
-               if (setdevs(myline, &dv) < 0)
-                       fatal(net, "cannot set pty security");
+               char slave_dev[16];
+
+               sprintf(tty_dev, "/dev/pty/%03d", ptynum);
+               if (setdevs(tty_dev, &dv) < 0)
+                       fatal(net, "cannot set pty security");
+               sprintf(slave_dev, "/dev/ttyp%03d", ptynum);
+               if (setdevs(slave_dev, &dv) < 0)
+                       fatal(net, "cannot set tty security");
        }
 #endif /* _SC_CRAY_SECURE_SYS */
 
        }
 #endif /* _SC_CRAY_SECURE_SYS */
 
@@ -739,6 +828,15 @@ doit(who)
 #ifndef        convex
        startslave(host, level, user_name);
 
 #ifndef        convex
        startslave(host, level, user_name);
 
+#if    defined(_SC_CRAY_SECURE_SYS)
+       if (secflag) {
+               if (setulvl(dv.dv_actlvl) < 0)
+                       fatal(net,"cannot setulvl()");
+               if (setucmp(dv.dv_actcmp) < 0)
+                       fatal(net, "cannot setucmp()");
+       }
+#endif /* _SC_CRAY_SECURE_SYS */
+
        telnet(net, pty);  /* begin server processing */
 #else
        telnet(net, pty, host);
        telnet(net, pty);  /* begin server processing */
 #else
        telnet(net, pty, host);
index c7b2844..c84ae50 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)termstat.c 5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)termstat.c 5.14 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -155,7 +155,7 @@ localstat()
                tty_setlinemode(uselinemode);
        }
 
                tty_setlinemode(uselinemode);
        }
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        /*
         * If the terminal is not echoing, but editing is enabled,
         * something like password input is going to happen, so
        /*
         * If the terminal is not echoing, but editing is enabled,
         * something like password input is going to happen, so
@@ -173,7 +173,7 @@ localstat()
                        enc_passwd = 0;
                }
        }
                        enc_passwd = 0;
                }
        }
-#endif
+#endif /* ENCRYPTION */
 
        /*
         * Do echo mode handling as soon as we know what the
 
        /*
         * Do echo mode handling as soon as we know what the
index 4c4df25..c680160 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utility.c  5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)utility.c  5.12 (Berkeley) %G%";
 #endif /* not lint */
 
 #define PRINTOPTIONS
 #endif /* not lint */
 
 #define PRINTOPTIONS
@@ -167,11 +167,11 @@ netclear()
 #define        wewant(p)       ((nfrontp > p) && ((*p&0xff) == IAC) && \
                                ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
 
 #define        wewant(p)       ((nfrontp > p) && ((*p&0xff) == IAC) && \
                                ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     thisitem = nclearto > netobuf ? nclearto : netobuf;
     thisitem = nclearto > netobuf ? nclearto : netobuf;
-#else
+#else  /* ENCRYPTION */
     thisitem = netobuf;
     thisitem = netobuf;
-#endif
+#endif /* ENCRYPTION */
 
     while ((next = nextitem(thisitem)) <= nbackp) {
        thisitem = next;
 
     while ((next = nextitem(thisitem)) <= nbackp) {
        thisitem = next;
@@ -179,11 +179,11 @@ netclear()
 
     /* Now, thisitem is first before/at boundary. */
 
 
     /* Now, thisitem is first before/at boundary. */
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     good = nclearto > netobuf ? nclearto : netobuf;
     good = nclearto > netobuf ? nclearto : netobuf;
-#else
+#else  /* ENCRYPTION */
     good = netobuf;    /* where the good bytes go */
     good = netobuf;    /* where the good bytes go */
-#endif
+#endif /* ENCRYPTION */
 
     while (nfrontp > thisitem) {
        if (wewant(thisitem)) {
 
     while (nfrontp > thisitem) {
        if (wewant(thisitem)) {
@@ -224,7 +224,7 @@ netflush()
              n += strlen(nfrontp);  /* get count first */
              nfrontp += strlen(nfrontp);  /* then move pointer */
            });
              n += strlen(nfrontp);  /* get count first */
              nfrontp += strlen(nfrontp);  /* then move pointer */
            });
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        if (encrypt_output) {
                char *s = nclearto ? nclearto : nbackp;
                if (nfrontp - s > 0) {
        if (encrypt_output) {
                char *s = nclearto ? nclearto : nbackp;
                if (nfrontp - s > 0) {
@@ -232,7 +232,7 @@ netflush()
                        nclearto = nfrontp;
                }
        }
                        nclearto = nfrontp;
                }
        }
-#endif
+#endif /* ENCRYPTION */
        /*
         * if no urgent data, or if the other side appears to be an
         * old 4.2 client (and thus unable to survive TCP urgent data),
        /*
         * if no urgent data, or if the other side appears to be an
         * old 4.2 client (and thus unable to survive TCP urgent data),
@@ -263,18 +263,18 @@ netflush()
        cleanup(0);
     }
     nbackp += n;
        cleanup(0);
     }
     nbackp += n;
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
     if (nbackp > nclearto)
        nclearto = 0;
     if (nbackp > nclearto)
        nclearto = 0;
-#endif
+#endif /* ENCRYPTION */
     if (nbackp >= neturg) {
        neturg = 0;
     }
     if (nbackp == nfrontp) {
        nbackp = nfrontp = netobuf;
     if (nbackp >= neturg) {
        neturg = 0;
     }
     if (nbackp == nfrontp) {
        nbackp = nfrontp = netobuf;
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        nclearto = 0;
        nclearto = 0;
-#endif
+#endif /* ENCRYPTION */
     }
     return;
 }  /* end of netflush */
     }
     return;
 }  /* end of netflush */
@@ -320,7 +320,7 @@ fatal(f, msg)
        char buf[BUFSIZ];
 
        (void) sprintf(buf, "telnetd: %s.\r\n", msg);
        char buf[BUFSIZ];
 
        (void) sprintf(buf, "telnetd: %s.\r\n", msg);
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        if (encrypt_output) {
                /*
                 * Better turn off encryption first....
        if (encrypt_output) {
                /*
                 * Better turn off encryption first....
@@ -329,7 +329,7 @@ fatal(f, msg)
                encrypt_send_end();
                netflush();
        }
                encrypt_send_end();
                netflush();
        }
-#endif
+#endif /* ENCRYPTION */
        (void) write(f, buf, (int)strlen(buf));
        sleep(1);       /*XXX*/
        exit(1);
        (void) write(f, buf, (int)strlen(buf));
        sleep(1);       /*XXX*/
        exit(1);
@@ -1010,7 +1010,7 @@ printsub(direction, pointer, length)
            break;
 #endif
 
            break;
 #endif
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
        case TELOPT_ENCRYPT:
            sprintf(nfrontp, "ENCRYPT");
            nfrontp += strlen(nfrontp);
        case TELOPT_ENCRYPT:
            sprintf(nfrontp, "ENCRYPT");
            nfrontp += strlen(nfrontp);
@@ -1096,7 +1096,7 @@ printsub(direction, pointer, length)
                break;
            }
            break;
                break;
            }
            break;
-#endif
+#endif /* ENCRYPTION */
 
        default:
            if (TELOPT_OK(pointer[0]))
 
        default:
            if (TELOPT_OK(pointer[0]))