cygnus merge:
authorKen Raeburn <raeburn@mit.edu>
Thu, 2 May 1996 01:22:45 +0000 (01:22 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 2 May 1996 01:22:45 +0000 (01:22 +0000)
* configure.in: Fix typo in Apr 16 HP-UX change.

* state.c (envvarok): nuke all KRB5* environment variables, not just the
previously selected ones.

* telnetd.c (telnet -> doit): moved SIGTTOU handler before the first thing
which would cause the terminal driver to get upset.

* sys_term.c (line): Remove initialization silliness.  The non-GNUC method was
Just Wrong, do it the other way always.
(Xline): Specify length, not contents.

* termio-tn.c (readstream_termio): new file, provides isolated version of
M_IOCTL handling for systems where termio and termios can't be compiled
together.
* termios-tn.c (readstream_termios): new file, provides isolated version of
M_IOCTL handling for systems where termio and termios can't be compiled
together.
* telnetd.c (readstream): use readstream_termios and readstream_termio to
handle getmsg with M_IOCTL.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7883 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/telnet/telnetd/ChangeLog
src/appl/telnet/telnetd/Makefile.in
src/appl/telnet/telnetd/configure.in
src/appl/telnet/telnetd/state.c
src/appl/telnet/telnetd/sys_term.c
src/appl/telnet/telnetd/telnetd.c
src/appl/telnet/telnetd/termio-tn.c [new file with mode: 0644]
src/appl/telnet/telnetd/termios-tn.c [new file with mode: 0644]

index 21fa61c27b46c9ebbbc564622418216337ba6ef7..2bcce3a8702b7daa8133d3066edec2c4edb270e4 100644 (file)
@@ -1,6 +1,38 @@
+Wed May  1 21:14:45 1996  Ken Raeburn  <raeburn@cygnus.com>
+
+       * configure.in: Fix typo in Apr 16 HP-UX change.
+
+       Thu Apr 18 16:17:55 1996  Mark Eichin  <eichin@cygnus.com>
+
+       * state.c (envvarok): nuke all KRB5* environment variables, not
+       just the previously selected ones.
+
+       Fri Mar 29 01:21:29 1996  Marc Horowitz  <marc@mit.edu>
+
+       * telnetd.c (telnet -> doit): moved SIGTTOU handler before the
+       first thing which would cause the terminal driver to get upset.
+
+       Mon Mar 25 01:05:50 1996  Ken Raeburn  <raeburn@cygnus.com>
+
+       * sys_term.c (line): Remove initialization silliness.  The
+       non-GNUC method was Just Wrong, do it the other way always.
+       (Xline): Specify length, not contents.
+
+       Wed Feb 28 22:27:46 1996  Mark Eichin  <eichin@cygnus.com>
+
+       * termio-tn.c (readstream_termio): new file, provides isolated
+       version of M_IOCTL handling for systems where termio and termios
+       can't be compiled together.
+       * termios-tn.c (readstream_termios): new file, provides isolated
+       version of M_IOCTL handling for systems where termio and termios
+       can't be compiled together.
+       * telnetd.c (readstream): use readstream_termios and
+       readstream_termio to handle getmsg with M_IOCTL.
+
 Thu Apr 18 16:33:42 1996  Sam Hartman  <hartmans@mit.edu>
 
-       * state.c (suboption): Don't accept authentication suboptions after authentication negotiation complete. 
+       * state.c (suboption): Don't accept authentication suboptions
+       after authentication negotiation complete.
        (envvarok):  exclude KRB5_KTNAME and KRB5CCNAME
 
 Tue Apr 16 12:23:02 1996  Sam Hartman  <hartmans@mit.edu>
index a0421779f21f64ca01568b4cf6a49c6e5dfb5181..26887b9e802fd8fe7620f474812add4a4693b6a7 100644 (file)
@@ -29,6 +29,8 @@ CFLAGS = $(CCOPTS) $(AUTH_DEF) $(OTHERDEFS) $(DEFS) $(LOCALINCLUDES)
 ARPA_TELNET= $(srcdir)/../arpa/telnet.h
 
 SRCS=  $(srcdir)/telnetd.c \
+       $(srcdir)/termio-tn.c \
+       $(srcdir)/termios-tn.c \
        $(srcdir)/state.c \
        $(srcdir)/termstat.c \
        $(srcdir)/slc.c \
@@ -38,6 +40,8 @@ SRCS= $(srcdir)/telnetd.c \
        $(srcdir)/authenc.c \
        $(GETTYSRC)
 OBJS=  telnetd.o \
+       termio-tn.o \
+       termios-tn.o \
        state.o \
        termstat.o \
        slc.o \
index 42a3c7ed80212d44b44cbd22b1b4de86dda6e58b..97af7585bea255fd2ebe3b3609ee765618a1f796 100644 (file)
@@ -29,14 +29,14 @@ dnl Make our operating system-specific security checks and definitions for
 dnl login.
 dnl
 case $krb5_cv_host in
-*-*-hpux-*)
+*-*-hpux*)
      broken_streams=yes
      ;;
 *-*-irix*)
      # Irix doesn't have a working granpt, and more over
      # you can't push anything onto a pty, so telnetd really
      # Really wants to treat it as if it doesn't have streams
-    broken_streams=yes
+     broken_streams=yes
      ;;
 esac
 if test -z "$broken_streams" ; then
index 2faed71980db4d0415b8d239ace88c3ed982461d..c398db214b4514825b7471cc1058c93465ccb56c 100644 (file)
@@ -1144,7 +1144,7 @@ suboption()
 
        if (his_state_is_wont(TELOPT_TTYPE))    /* Ignore if option disabled */
                break;
-sb_auth_complete();
+       sb_auth_complete();
        settimer(ttypesubopt);
 
        if (SB_EOF() || SB_GET() != TELQUAL_IS) {
@@ -1264,7 +1264,7 @@ sb_auth_complete();
     case TELOPT_XDISPLOC: {
        if (SB_EOF() || SB_GET() != TELQUAL_IS)
                return;
-sb_auth_complete();
+       sb_auth_complete();
        settimer(xdisplocsubopt);
        subpointer[SB_LEN()] = '\0';
        (void)setenv("DISPLAY", (char *)subpointer, 1);
@@ -1280,7 +1280,7 @@ sb_auth_complete();
 
        if (SB_EOF())
                return;
-sb_auth_complete();
+       sb_auth_complete();
        c = SB_GET();
        if (c == TELQUAL_IS) {
                if (subchar == TELOPT_OLD_ENVIRON)
@@ -1435,10 +1435,10 @@ sb_auth_complete();
                case ENV_USERVAR:
                        *cp = '\0';
                        if (envvarok(varp)) {
-                           if (valp)
-                               (void)setenv(varp, valp, 1);
-                           else
-                               unsetenv(varp);
+                               if (valp)
+                                       (void)setenv(varp, valp, 1);
+                               else
+                                       unsetenv(varp);
                        }
                        cp = varp = (char *)subpointer;
                        valp = 0;
@@ -1456,10 +1456,10 @@ sb_auth_complete();
        }
        *cp = '\0';
        if (envvarok(varp)) {
-           if (valp)
-               (void)setenv(varp, valp, 1);
-           else
-               unsetenv(varp);
+               if (valp)
+                       (void)setenv(varp, valp, 1);
+               else
+                       unsetenv(varp);
        }
        break;
     }  /* end of case TELOPT_NEW_ENVIRON */
@@ -1476,12 +1476,12 @@ sb_auth_complete();
                 */
                break;
        case TELQUAL_IS:
-         if (!auth_negotiated)
-  auth_is(subpointer, SB_LEN());
+               if (!auth_negotiated)
+                       auth_is(subpointer, SB_LEN());
                break;
        case TELQUAL_NAME:
-         if (!auth_negotiated)
-  auth_name(subpointer, SB_LEN());
+               if (!auth_negotiated)
+                       auth_name(subpointer, SB_LEN());
                break;
        }
        break;
@@ -1642,16 +1642,28 @@ send_status()
 }
 
 static int envvarok(varp)
-  char *varp;
+       char *varp;
 {
-    if (!strncmp(varp, "LD_", 3) || !strncmp(varp, "_RLD_", 5) ||
-       !strncmp(varp, "ELF_LD_", 7) || !strncmp(varp, "AOUT_LD_", 8) ||
-        !strcmp(varp, "LIBPATH") || !strcmp(varp, "IFS") ||
-!strcmp(varp, "KRB5_KTNAME")|| !strcmp(varp, "KRB5CCNAME")||
-       strchr(varp, '='))
-    {
-       syslog(LOG_INFO, "Rejected the attempt to modify the environment variable \"%s\"", varp);
-       return 0;
-    }
-    return 1;
+       if (!strchr(varp, '=') &&
+           strncmp(varp, "LD_", strlen("LD_")) && /* most systems */
+           strncmp(varp, "_RLD_", strlen("_RLD_")) && /* irix */
+           strncmp(varp, "KRB5", strlen("KRB5")) && /* v5 */
+           /* The above is a catch-all for now.  Here are some of the
+              specific ones we must avoid passing, at least until we
+              can prove it can be done safely.  Keep this list around
+              in case someone wants to remove the catch-all.  */
+           strcmp(varp, "KRB5_CONFIG") && /* v5 */
+           strcmp(varp, "KRB5CCNAME") &&  /* v5 */
+           strcmp(varp, "KRB5_KTNAME") && /* v5 */
+           strcmp(varp, "KRBTKFILE") &&   /* v4 */
+           strcmp(varp, "KRB_CONF") &&    /* cns v4 */
+           strcmp(varp, "KRB_REALMS") &&  /* cns v4 */
+           strcmp(varp, "LIBPATH") &&     /* AIX */
+           strcmp(varp, "IFS")) {
+               return 1;
+       } else {
+               syslog(LOG_INFO, "Rejected the attempt to modify the environment variable \"%s\"", varp);
+               return 0;
+       }
+
 }
index ac76cd864531c3130783b2082fe5e7b54855a1e7..829260b552b5683b74f67704b5e253a342a3ee05 100644 (file)
@@ -482,12 +482,9 @@ getnpty()
  *
  * Returns the file descriptor of the opened pty.
  */
-#ifndef        __GNUC__
-char *line = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-#else
-static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+static char Xline[17];
 char *line = Xline;
-#endif
+
 #ifdef CRAY
 char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 #endif /* CRAY */
@@ -1050,7 +1047,6 @@ termbuf.c_cflag |= HUPCL;
 #ifndef        O_NOCTTY
 #define        O_NOCTTY        0
 #endif
-
 #endif /* !defined(CRAY) || !defined(NEWINIT) */
 
 
index 1fd55e62451ab26024771a6dfe957aa873c54a69..c3660d2c2200558a5f8762a4296ec5d14bb35e70 100644 (file)
@@ -933,6 +933,15 @@ pty_init();
 #endif
 
        init_env();
+
+#ifdef SIGTTOU
+       /*
+        * Ignoring SIGTTOU keeps the kernel from blocking us.
+        * we tweak the tty with an ioctl()
+        * (in ttioct() in /sys/tty.c in a BSD kernel)
+        */
+       (void) signal(SIGTTOU, SIG_IGN);
+#endif
        /*
         * get terminal type.
         */
@@ -1137,13 +1146,6 @@ telnet(f, p, host)
 #ifdef SIGTSTP
        (void) signal(SIGTSTP, SIG_IGN);
 #endif
-#ifdef SIGTTOU
-       /*
-        * Ignoring SIGTTOU keeps the kernel from blocking us
-        * in ttioct() in /sys/tty.c.
-        */
-       (void) signal(SIGTTOU, SIG_IGN);
-#endif
 
        (void) signal(SIGCHLD, cleanup);
 
@@ -1533,28 +1535,13 @@ int readstream(p, ibuf, bufsize)
 
        case M_IOCTL:
                ip = (struct iocblk *) (ibuf+1);
-
-               switch (ip->ioc_cmd) {
-               case TCSETS:
-               case TCSETSW:
-               case TCSETSF:
-                       tsp = (struct termios *)
-                                       (ibuf+1 + sizeof(struct iocblk));
-                       vstop = tsp->c_cc[VSTOP];
-                       vstart = tsp->c_cc[VSTART];
-                       ixon = tsp->c_iflag & IXON;
-                       break;
-               case TCSETA:
-               case TCSETAW:
-               case TCSETAF:
-                       tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
-                       vstop = tp->c_cc[VSTOP];
-                       vstart = tp->c_cc[VSTART];
-                       ixon = tp->c_iflag & IXON;      
-                       break;
-               default:
-                       errno = EAGAIN;
-                       return(-1);
+               if (readstream_termio(ip->ioc_cmd, ibuf, 
+                                     &vstop, &vstart, &ixon)) {
+                 if (readstream_termios(ip->ioc_cmd, ibuf, 
+                                        &vstop, &vstart, &ixon)) {
+                   errno = EAGAIN;
+                   return(-1);
+                 }
                }
 
                newflow =  (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
diff --git a/src/appl/telnet/telnetd/termio-tn.c b/src/appl/telnet/telnetd/termio-tn.c
new file mode 100644 (file)
index 0000000..24eaffd
--- /dev/null
@@ -0,0 +1,31 @@
+/* handle having mutually exclusive termio vs. termios */
+/* return 0 if handled */
+#ifdef STREAMSPTY
+#include <sys/types.h>
+#include <sys/stream.h>
+#include <sys/ioctl.h>
+#include <termio.h>
+
+int readstream_termio(cmd, ibuf, vstop, vstart, ixon)
+     int cmd;
+     char *ibuf;
+     char *vstop, *vstart;
+     int *ixon;
+{
+  struct termio *tp;
+  switch (cmd) {
+  case TCSETA:
+  case TCSETAW:
+  case TCSETAF:
+    tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
+#if 0                          /* VSTOP/VSTART only in termios!? */
+    *vstop = tp->c_cc[VSTOP];
+    *vstart = tp->c_cc[VSTART];
+#endif
+    *ixon = tp->c_iflag & IXON;      
+    return 0;
+  }
+  return -1;
+}
+
+#endif /* STREAMSPTY */
diff --git a/src/appl/telnet/telnetd/termios-tn.c b/src/appl/telnet/telnetd/termios-tn.c
new file mode 100644 (file)
index 0000000..4712a33
--- /dev/null
@@ -0,0 +1,30 @@
+/* handle having mutually exclusive termio vs. termios */
+/* return 0 if handled */
+#ifdef STREAMSPTY
+#include <sys/types.h>
+#include <sys/stream.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+
+int readstream_termios(cmd, ibuf, vstop, vstart, ixon)
+     int cmd;
+     char *ibuf;
+     char *vstop, *vstart;
+     int *ixon;
+{
+  struct termios *tsp;
+  switch (cmd) {
+  case TCSETS:
+  case TCSETSW:
+  case TCSETSF:
+    tsp = (struct termios *)
+      (ibuf+1 + sizeof(struct iocblk));
+    *vstop = tsp->c_cc[VSTOP];
+    *vstart = tsp->c_cc[VSTART];
+    *ixon = tsp->c_iflag & IXON;
+    return 0;
+  }
+  return -1;
+}
+
+#endif /* STREAMSPTY */