diff options
Diffstat (limited to 'crypto/heimdal/appl/telnet/telnetd/sys_term.c')
-rw-r--r-- | crypto/heimdal/appl/telnet/telnetd/sys_term.c | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/crypto/heimdal/appl/telnet/telnetd/sys_term.c b/crypto/heimdal/appl/telnet/telnetd/sys_term.c index 852611f..d8af14e 100644 --- a/crypto/heimdal/appl/telnet/telnetd/sys_term.c +++ b/crypto/heimdal/appl/telnet/telnetd/sys_term.c @@ -33,7 +33,7 @@ #include "telnetd.h" -RCSID("$Id: sys_term.c 22390 2007-12-31 10:12:48Z lha $"); +RCSID("$Id$"); #if defined(_CRAY) || (defined(__hpux) && !defined(HAVE_UTMPX_H)) # define PARENT_DOES_UTMP @@ -67,6 +67,11 @@ int utmp_len = MaxHostNameLen; #endif #endif +/* really, mac os uses wtmpx (or asl) */ +#ifdef __APPLE__ +#undef _PATH_WTMP +#endif + #if !defined(WTMP_FILE) && defined(_PATH_WTMP) #define WTMP_FILE _PATH_WTMP #endif @@ -159,6 +164,8 @@ char wtmpf[] = "/etc/wtmp"; # ifdef STREAMSPTY static int ttyfd = -1; int really_stream = 0; +# else +#define really_stream 0 # endif const char *new_login = _PATH_LOGIN; @@ -379,12 +386,12 @@ int getpty(int *ptynum) return master; } #endif - + #ifdef STREAMSPTY { - char *clone[] = { "/dev/ptc", "/dev/ptmx", "/dev/ptm", + char *clone[] = { "/dev/ptc", "/dev/ptmx", "/dev/ptm", "/dev/ptym/clone", 0 }; - + char **q; int p; for(q=clone; *q; q++){ @@ -408,7 +415,7 @@ int getpty(int *ptynum) int p; char *cp, *p1, *p2; int i; - + #ifndef __hpux snprintf(line, sizeof(Xline), "/dev/ptyXX"); p1 = &line[8]; @@ -418,11 +425,11 @@ int getpty(int *ptynum) p1 = &line[13]; p2 = &line[14]; #endif - - + + for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) { struct stat stb; - + *p1 = *cp; *p2 = '0'; /* @@ -439,7 +446,7 @@ int getpty(int *ptynum) #if SunOS == 40 int dummy; #endif - + #ifndef __hpux line[5] = 't'; #else @@ -467,7 +474,7 @@ int getpty(int *ptynum) extern lowpty, highpty; struct stat sb; int p; - + for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) { snprintf(myline, sizeof(myline), "/dev/pty/%03d", *ptynum); p = open(myline, 2); @@ -748,7 +755,7 @@ static int my_find(int fd, char *module) static struct str_list sl; int n; int i; - + if(!flag){ n = ioctl(fd, I_LIST, 0); if(n < 0){ @@ -764,7 +771,7 @@ static int my_find(int fd, char *module) } flag = 1; } - + for(i=0; i<sl.sl_nmods; i++) if(!strcmp(sl.sl_modlist[i].l_name, module)) return 1; @@ -787,7 +794,7 @@ static void maybe_push_modules(int fd, char **modules) } /* p points to null or to an already pushed module, now push all modules before this one */ - + for(p--; p >= modules; p--){ err = ioctl(fd, I_PUSH, *p); if(err < 0 && errno != EINVAL) @@ -849,7 +856,7 @@ void getptyslave(void) #ifdef STREAMSPTY ttyfd = t; - + /* * Not all systems have (or need) modules ttcompat and pckt so @@ -869,7 +876,7 @@ void getptyslave(void) pushed (via autopush, for instance). */ - + char *ttymodules[] = { "ttcompat", "ldterm", "ptem", NULL }; char *ptymodules[] = { "pckt", NULL }; @@ -1008,8 +1015,10 @@ int cleanopen(char *line) int login_tty(int t) { + /* Dont need to set this as the controlling PTY on steams sockets, + * don't abort on failure. */ # if defined(TIOCSCTTY) && !defined(__hpux) - if (ioctl(t, TIOCSCTTY, (char *)0) < 0) + if (ioctl(t, TIOCSCTTY, (char *)0) < 0 && !really_stream) fatalperror(net, "ioctl(sctty)"); # ifdef _CRAY /* @@ -1081,7 +1090,7 @@ static char * make_id (char *tty) { char *res = tty; - + if (strncmp (res, "pts/", 4) == 0) res += 4; if (strncmp (res, "tty", 3) == 0) @@ -1177,7 +1186,9 @@ startslave(const char *host, const char *utmp_host, } char *envinit[3]; +#if !HAVE_DECL_ENVIRON extern char **environ; +#endif void init_env(void) @@ -1223,7 +1234,7 @@ scrub_env(void) char **cpp, **cpp2; const char **p; - + for (cpp2 = cpp = environ; *cpp; cpp++) { int reject_it = 0; @@ -1271,18 +1282,18 @@ start_login(const char *host, int autologin, char *name) encrypt_output = NULL; decrypt_input = NULL; #endif - + #ifdef HAVE_UTMPX_H { int pid = getpid(); struct utmpx utmpx; struct timeval tv; char *clean_tty; - + /* * Create utmp entry for child */ - + clean_tty = clean_ttyname(line); memset(&utmpx, 0, sizeof(utmpx)); strncpy(utmpx.ut_user, ".telnet", sizeof(utmpx.ut_user)); @@ -1291,9 +1302,9 @@ start_login(const char *host, int autologin, char *name) strncpy(utmpx.ut_id, make_id(clean_tty), sizeof(utmpx.ut_id)); #endif utmpx.ut_pid = pid; - + utmpx.ut_type = LOGIN_PROCESS; - + gettimeofday (&tv, NULL); utmpx.ut_tv.tv_sec = tv.tv_sec; utmpx.ut_tv.tv_usec = tv.tv_usec; @@ -1304,7 +1315,7 @@ start_login(const char *host, int autologin, char *name) #endif scrub_env(); - + /* * -h : pass on name of host. * WARNING: -h is accepted by login if and only if @@ -1314,7 +1325,7 @@ start_login(const char *host, int autologin, char *name) * -f : force this login, he has already been authenticated */ - /* init argv structure */ + /* init argv structure */ argv.size=0; argv.argc=0; argv.argv=malloc(0); /*so we can call realloc later */ @@ -1322,7 +1333,7 @@ start_login(const char *host, int autologin, char *name) addarg(&argv, "-h"); addarg(&argv, host); addarg(&argv, "-p"); - if(name[0]) + if(name && name[0]) user = name; else user = getenv("USER"); @@ -1339,8 +1350,8 @@ start_login(const char *host, int autologin, char *name) addarg(&argv, "-a"); addarg(&argv, "otp"); } - if(log_unauth) - syslog(LOG_INFO, "unauthenticated access from %s (%s)", + if(log_unauth) + syslog(LOG_INFO, "unauthenticated access from %s (%s)", host, user ? user : "unknown user"); } if (auth_level >= 0 && autologin == AUTH_VALID) @@ -1433,7 +1444,7 @@ rmut(void) #elif defined(__osf__) /* XXX */ utxp->ut_exit.ut_termination = 0; utxp->ut_exit.ut_exit = 0; -#else +#else utxp->ut_exit.e_termination = 0; utxp->ut_exit.e_exit = 0; #endif @@ -1585,7 +1596,7 @@ cleanup(int sig) int t; int child_status; /* status of child process as returned by waitpid */ int flags = WNOHANG|WUNTRACED; - + /* * 1: Pick up the zombie, if we are being called * as the signal handler. @@ -1613,7 +1624,7 @@ cleanup(int sig) } incleanup = 1; sigsetmask(t); - + t = cleantmp(&wtmp); setutent(); /* just to make sure */ #endif /* CRAY */ @@ -1641,7 +1652,7 @@ cleanup(int sig) #endif #else char *p; - + p = line + sizeof("/dev/") - 1; if (logout(p)) logwtmp(p, "", ""); |