From: Richard Basch Date: Tue, 27 Dec 1994 11:45:05 +0000 (+0000) Subject: * krlogind.c X-Git-Tag: krb5-1.0-beta5~897 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9f8358ce9620ecfb552f29548f1fccb21c102bae;p=krb5.git * krlogind.c Use the file descriptor macros (eg. FD_SET) to handle fd arrays Change #ifdef STREAMS to #ifdef HAVE_STREAMS Started to add SYS-V utmp handling Ripped out the old termio code. Include and where available. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4756 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index c62f96093..3ec581599 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,16 @@ +Tue Dec 27 06:15:42 1994 Richard Basch (probe@tardis) + + * krlogind.c + Use the file descriptor macros (eg. FD_SET) to handle fd arrays + Change #ifdef STREAMS to #ifdef HAVE_STREAMS + Started to add SYS-V utmp handling + Ripped out the old termio code. + Include and where available. + + * configure.in + Combined KRB5_UT* macros into CHECK_UTMP, with more checks. + Changed obsolete AC_COMPILE_CHECK to use newer macros. + Mon Dec 26 13:51:20 1994 Richard Basch (probe@tardis) * Makefile.in diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 16bc6a852..36fdc33ed 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -80,7 +80,7 @@ char copyright[] = * instead of the accompanying login.krb5. In that case, * the remote user's name must be present in the local * .rhosts file, regardless of any options specified. - * SERVE_V4 - Define this if v4 rlogin clients are also to be served. + * KRB5_KRB4_COMPAT - Define this if v4 rlogin clients are also to be served. * ALWAYS_V5_KUSEROK - Define this if you want .k5login to be * checked even for v4 clients (instead of .klogin). * LOG_ALL_LOGINS - Define this if you want to log all logins. @@ -100,6 +100,16 @@ char copyright[] = #define LOG_REMOTE_REALM #define CRYPT +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef __SCO__ +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + #include #include #include @@ -108,16 +118,7 @@ char copyright[] = #include #include #include -#ifdef NEED_SYS_FCNTL_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef __SCO__ -#include -#endif - +#include #include #include #include @@ -130,45 +131,49 @@ char copyright[] = #endif #include + #ifdef hpux #include #endif - #ifdef sysvimp #include -#define STREAMS +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifdef HAVE_STREAMS +#include #include #endif - + #ifdef POSIX_TERMIOS #include #else -#ifdef SYSV -#define USE_TERMIO -#endif - -#ifdef USE_TERMIO -#include -#else #include -#endif /* USE_TERMIO */ -#endif /* POSIX_TERMIOS */ +#endif #include #include #include #include #include + +#ifdef HAVE_UTXENT +#include +#endif #ifdef HAVE_SYS_TTY_H #include #endif -#ifdef HAVE_STREAMS -/* but solaris actually uses packet mode, so the real macros are needed too */ +#ifdef HAVE_SYS_PTYVAR_H +/* Solaris actually uses packet mode, so the real macros are needed too */ #include #endif + #ifndef TIOCPKT_NOSTOP /* These values are over-the-wire protocol, *not* local values */ #define TIOCPKT_NOSTOP 0x10 @@ -176,7 +181,6 @@ char copyright[] = #define TIOCPKT_FLUSHWRITE 0x02 #endif - #ifdef HAVE_SYS_FILIO_H /* get FIONBIO from sys/filio.h, so what if it is a compatibility feature */ #include @@ -638,20 +642,8 @@ void doit(f, fromp) { #ifdef POSIX_TERMIOS struct termios new_termio; -#else -#ifdef USE_TERMIO - struct termio b; -# define TIOCGETP TCGETA -# define TIOCSETP TCSETA -# ifdef MIN -# undef MIN -# endif -# define MIN 1 -# define TIME 0 - #else struct sgttyb b; -#endif /* USE_TERMIO */ #endif /* POSIX_TERMIOS */ #ifdef SYSV (void) setpgrp(); @@ -661,7 +653,7 @@ void doit(f, fromp) if (t < 0) fatalperror(f, line); #endif -#ifdef STREAMS +#if defined(HAVE_STREAMS) && (defined(HAVE_LINE_PUSH) || defined(sun)) while (ioctl (t, I_POP, 0) == 0); /*Clear out any old lined's*/ #endif /* Under Ultrix 3.0, the pgrp of the slave pty terminal @@ -691,10 +683,21 @@ void doit(f, fromp) pid = 0; /*reset pid incase exec fails*/ #endif /* !sysv || sysvimp */ -#ifdef STREAMS +#ifdef HAVE_STREAMS +#ifdef HAVE_LINE_PUSH if (line_push(t) < 0) - fatalperror(f, "IPUSH",errno); -#endif + fatalperror(f, "IPUSH",errno); +#else +#ifdef sun + if (ioctl(t, I_PUSH, "ptem") < 0) + fatalperror(f, "IPUSH-ptem",errno); + if (ioctl(t, I_PUSH, "ldterm") < 0) + fatalperror(f, "IPUSH-ldterm",errno); + if (ioctl(t, I_PUSH, "ttcompat") < 0) + fatalperror(f, "IPUSH-ttcompat",errno); +#endif /* sun */ +#endif /* HAVE_LINE_PUSH */ +#endif /* HAVE_STREAMS */ #ifdef POSIX_TERMIOS tcgetattr(t,&new_termio); new_termio.c_lflag &= ~(ICANON|ECHO|ISIG|IEXTEN); @@ -707,18 +710,7 @@ void doit(f, fromp) tcsetattr(t,TCSANOW,&new_termio); #else (void)ioctl(t, TIOCGETP, &b); -#ifdef USE_TERMIO - /* The key here is to just turn off echo */ - b.c_iflag &= ~(ICRNL|IUCLC); - b.c_iflag |= IXON; - b.c_cflag |= CS8; - b.c_lflag |= ICANON|ISIG; - b.c_lflag &= ~(ECHO); - b.c_cc[VMIN] = MIN; - b.c_cc[VTIME] = TIME; -#else b.sg_flags = RAW|ANYP; -#endif /* USE_TERMIO */ (void)ioctl(t, TIOCSETP, &b); #endif /* POSIX_TERMIOS */ /* @@ -779,6 +771,44 @@ void doit(f, fromp) rhost_name, lusername); } #endif + +#ifdef HAVE_UTENT + { + int tmpx; + char utmp_id[5]; + struct utmp ent; +#ifdef HAVE_UTXENT + struct utmpx entx; +#endif + strcpy(ent.ut_user, "rlogin"); + strcpy(ent.ut_line, line+sizeof("/dev/")-1); + + sscanf(line, "/dev/pts/%d", &tmpx); + sprintf(utmp_id, "kl%02d", tmpx); + strncpy(ent.ut_id, utmp_id, sizeof(ent.ut_id)); + + ent.ut_pid = getpid; + ent.ut_type = LOGIN_PROCESS; + ent.ut_time = time(0); + +#ifdef HAVE_UTXENT + getutmpx(&ent, &entx); + setutxent(); + pututxline(&entx); + endutxent(); + updwtmpx(WTMPX_FILE, &ent); +#endif + utmpname(UTMP_FILE); + setutent(); + pututline(&ent); + endutent(); + + utmpname(WTMP_FILE); + setutent(); + pututline(&ent); + endutent(); + } +#endif #ifdef DO_NOT_USE_K_LOGIN execl(LOGIN_PROGRAM, "login", "-r", rhost_name, 0); @@ -934,43 +964,41 @@ protocol(f, p) send(f, oobdata, 1, MSG_OOB); /* indicate new rlogin */ #endif for (;;) { - int ibits, obits, ebits; - - ibits = 0; - obits = 0; + fd_set ibits, obits, ebits; + + FD_ZERO(&ibits); + FD_ZERO(&obits); + FD_ZERO(&ebits); + if (fcc) - obits |= (1<= 0) - if (pcc) - obits |= (1< 0) { + if (FD_ISSET(p, &obits) && fcc > 0) { cc = write(p, fbp, fcc); if (cc > 0) { fcc -= cc; @@ -1009,7 +1037,7 @@ protocol(f, p) } } - if (ibits & (1< 0) { + if (FD_ISSET(f, &obits) && pcc > 0) { cc = (*des_write)(f, pbp, pcc); if (cc < 0 && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) { /* also shouldn't happen */ @@ -1066,7 +1094,7 @@ krb5_sigtype cleanup() (void)chmod(line, 0666); (void)chown(line, 0, 0); -#ifndef STREAMS +#ifndef HAVE_STREAMS *p = 'p'; (void)chmod(line, 0666); (void)chown(line, 0, 0); @@ -1386,7 +1414,7 @@ getpty(fd,slave) char c; int i,ptynum; struct stat stb; -#ifdef STREAMS +#ifdef HAVE_STREAMS #ifdef sysvimp *fd = open("/dev/pty", O_RDWR|O_NDELAY); #else