From e723097e4f2e14c637858a95d90cc81f0d4ec7f4 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Sun, 24 Mar 1996 20:23:45 +0000 Subject: [PATCH] * Apply patch from Ken Raeburn to get telnetd compiling on the SGI * Force telnetd not to use streams on the SGI; it doesn't support pushing modules onto a pty. * Remove old utmpx crud from sys_term.c because it was getting called inadvertently, didn't compile on the SGI, and libpty already does something reasonable with utmpx. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7705 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/telnet/telnetd/ChangeLog | 22 ++++ src/appl/telnet/telnetd/configure.in | 15 ++- src/appl/telnet/telnetd/defs.h | 15 +++ src/appl/telnet/telnetd/ext.h | 5 +- src/appl/telnet/telnetd/sys_term.c | 153 +-------------------------- src/appl/telnet/telnetd/telnetd.c | 7 +- 6 files changed, 57 insertions(+), 160 deletions(-) diff --git a/src/appl/telnet/telnetd/ChangeLog b/src/appl/telnet/telnetd/ChangeLog index 1b4cd3fa3..d473f86c7 100644 --- a/src/appl/telnet/telnetd/ChangeLog +++ b/src/appl/telnet/telnetd/ChangeLog @@ -1,3 +1,25 @@ +Sat Mar 23 01:33:09 1996 Sam Hartman + + * sys_term.c: Remove utmpx stuff so libpty can do it. + (start_login): Remove utmpx handling here as well. + (rmut): expunged; libpty should deal. + + * configure.in : Do not use streamspty on SGIs; it really doesn't + work, even though all the interfaces are prsent. + + * telnetd.c: Move prototype for doit to be global instead of + streams-specific. + + Tue Mar 19 18:43:46 1996 Ken Raeburn + + For environments not supporting common storage: + * defs.h (P): Add definition here. + (line, encrypt_output, decrypt_input): Declare here. + * ext.h (line, encrypt_output, decrypt_input): Not here. + (terminaltype): Declare explicitly "extern". + * telnetd.c (auth_level, require_SecurID): Don't initialize here. + + Mon Mar 18 20:29:05 1996 Theodore Y. Ts'o * Makefile.in: Added flags which turn on the encryption option. diff --git a/src/appl/telnet/telnetd/configure.in b/src/appl/telnet/telnetd/configure.in index d301f547e..9a4648b94 100644 --- a/src/appl/telnet/telnetd/configure.in +++ b/src/appl/telnet/telnetd/configure.in @@ -25,7 +25,20 @@ AC_HEADER_TIME AC_CHECK_HEADERS(string.h arpa/nameser.h) AC_CHECK_HEADERS(sys/time.h sys/tty.h) AC_HAVE_FUNCS(vhangup) -AC_FUNC_CHECK(grantpt,AC_DEFINE(STREAMSPTY)) +dnl Make our operating system-specific security checks and definitions for +dnl login. +dnl +case $krb5_cv_host in +*-*-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 +;; +esac +if test -z "$broken_streams" ; then + AC_FUNC_CHECK(grantpt,AC_DEFINE(STREAMSPTY)) +fi AC_HEADER_CHECK(sac.h,AC_DEFINE(HAS_SAC)) AC_HEADER_CHECK(sys/ptyvar.h,AC_DEFINE(HAS_PTYVAR)) AC_FUNC_CHECK(gettosbyname,AC_DEFINE(HAS_GETTOS)) diff --git a/src/appl/telnet/telnetd/defs.h b/src/appl/telnet/telnetd/defs.h index b876269f7..3ce72c6fc 100644 --- a/src/appl/telnet/telnetd/defs.h +++ b/src/appl/telnet/telnetd/defs.h @@ -309,3 +309,18 @@ typedef struct { #define his_will_wont_is_changing my_do_dont_is_changing #define his_do_dont_is_changing my_will_wont_is_changing + +extern char *line; + +#ifndef P +# ifdef __STDC__ +# define P(x) x +# else +# define P(x) () +# endif +#endif + +#ifdef ENCRYPTION +extern void (*encrypt_output) P((unsigned char *, int)); +extern int (*decrypt_input) P((int)); +#endif /* ENCRYPTION */ diff --git a/src/appl/telnet/telnetd/ext.h b/src/appl/telnet/telnetd/ext.h index 4a332cea5..53d90698d 100644 --- a/src/appl/telnet/telnetd/ext.h +++ b/src/appl/telnet/telnetd/ext.h @@ -66,7 +66,7 @@ extern int auth_level; extern slcfun slctab[NSLC + 1]; /* slc mapping table */ -char *terminaltype; +extern char *terminaltype; /* * I/O data buffers, pointers, and counters. @@ -86,7 +86,6 @@ extern char *unptyip; /* pointer to remaining characters in buffer */ #endif extern int pty, net; -extern char *line; extern int SYNCHing; /* we are in TELNET SYNCH mode */ #ifndef P @@ -192,8 +191,6 @@ extern void writenet P((unsigned char *, int)); #ifdef ENCRYPTION -extern void (*encrypt_output) P((unsigned char *, int)); -extern int (*decrypt_input) P((int)); extern char *nclearto; #endif /* ENCRYPTION */ diff --git a/src/appl/telnet/telnetd/sys_term.c b/src/appl/telnet/telnetd/sys_term.c index ccd061fb9..e6d9786d1 100644 --- a/src/appl/telnet/telnetd/sys_term.c +++ b/src/appl/telnet/telnetd/sys_term.c @@ -64,9 +64,9 @@ int utmp_len = MAXHOSTNAMELEN; /* sizeof(init_request.host) */ # include struct utmpx wtmp; # else -# include +#include struct utmp wtmp; -# endif /* UTMPX */ +#endif /*UTMPX*/ int utmp_len = sizeof(wtmp.ut_host); # ifndef PARENT_DOES_UTMP @@ -1244,33 +1244,13 @@ start_login(host, autologin, name) register char **argv; char **addarg(); extern char *getenv(); -#ifdef UTMPX register int pid = getpid(); - struct utmpx utmpx; -#endif + #ifdef SOLARIS char *term; char termbuf[64]; #endif -#ifdef UTMPX - /* - * Create utmp entry for child - */ - - memset(&utmpx, 0, sizeof(utmpx)); - SCPYN(utmpx.ut_user, ".telnet"); - SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); - utmpx.ut_pid = pid; - utmpx.ut_id[0] = 't'; - utmpx.ut_id[1] = 'n'; - utmpx.ut_id[2] = SC_WILDC; - utmpx.ut_id[3] = SC_WILDC; - utmpx.ut_type = LOGIN_PROCESS; - (void) time(&utmpx.ut_tv.tv_sec); - if (makeutx(&utmpx) == NULL) - fatal(net, "makeutx failed"); -#endif /* * -h : pass on name of host. @@ -1685,131 +1665,4 @@ cleantmpdir(jid, tpath, user) # endif /* CRAY */ #endif /* defined(PARENT_DOES_UTMP) && !defined(NEWINIT) */ -/* - * rmut() - * - * This is the function called by cleanup() to - * remove the utmp entry for this person. - */ - -#ifdef UTMPX - void -rmut() -{ - register f; - int found = 0; - struct utmp *u, *utmp; - int nutmp; - struct stat statbf; - struct utmpx *utxp, utmpx; - - /* - * This updates the utmpx and utmp entries and make a wtmp/x entry - */ - - SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); - utxp = getutxline(&utmpx); - if (utxp) { - utxp->ut_type = DEAD_PROCESS; - utxp->ut_exit.e_termination = 0; - utxp->ut_exit.e_exit = 0; - (void) time(&utmpx.ut_tv.tv_sec); - utmpx.ut_tv.tv_usec = 0; - modutx(utxp); - } - endutxent(); -} /* end of rmut */ -#endif - -#if !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43 - void -rmut() -{ - register f; - int found = 0; - struct utmp *u, *utmp; - int nutmp; - struct stat statbf; - - f = open(utmpf, O_RDWR); - if (f >= 0) { - (void) fstat(f, &statbf); - utmp = (struct utmp *)malloc((unsigned)statbf.st_size); - if (!utmp) - syslog(LOG_ERR, "utmp malloc failed"); - if (statbf.st_size && utmp) { - nutmp = read(f, (char *)utmp, (int)statbf.st_size); - nutmp /= sizeof(struct utmp); - - for (u = utmp ; u < &utmp[nutmp] ; u++) { - if (SCMPN(u->ut_line, line+5) || - u->ut_name[0]==0) - continue; - (void) lseek(f, ((long)u)-((long)utmp), L_SET); - SCPYN(u->ut_name, ""); - SCPYN(u->ut_host, ""); - (void) time(&u->ut_time); - (void) write(f, (char *)u, sizeof(wtmp)); - found++; - } - } - (void) close(f); - } - if (found) { - f = open(wtmpf, O_WRONLY|O_APPEND); - if (f >= 0) { - SCPYN(wtmp.ut_line, line+5); - SCPYN(wtmp.ut_name, ""); - SCPYN(wtmp.ut_host, ""); - (void) time(&wtmp.ut_time); - (void) write(f, (char *)&wtmp, sizeof(wtmp)); - (void) close(f); - } - } - (void) chmod(line, 0666); - (void) chown(line, 0, 0); - line[strlen("/dev/")] = 'p'; - (void) chmod(line, 0666); - (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 diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c index 029add63b..a96dc8455 100644 --- a/src/appl/telnet/telnetd/telnetd.c +++ b/src/appl/telnet/telnetd/telnetd.c @@ -82,10 +82,6 @@ struct socket_security ss; #if defined(AUTHENTICATION) #include #include -int auth_level = 0; -#endif -#if defined(SecurID) -int require_SecurID = 0; #endif #ifdef ENCRYPTION #include @@ -107,7 +103,6 @@ int registerd_host_only = 0; # include #endif -void doit P((struct sockaddr_in *)); /* * Because of the way ptyibuf is used with streams messages, we need @@ -134,6 +129,8 @@ char ptyibuf2[BUFSIZ]; #endif /* ! STREAMPTY */ +void doit P((struct sockaddr_in *)); + int hostinfo = 1; /* do we print login banner? */ #ifdef CRAY -- 2.26.2