diff options
author | Sam Hartman <hartmans@mit.edu> | 1996-01-19 01:33:08 +0000 |
---|---|---|
committer | Sam Hartman <hartmans@mit.edu> | 1996-01-19 01:33:08 +0000 |
commit | c37e7830bd25238f680af7464837c829a89337cf (patch) | |
tree | ff4f2c4f6489333815ebe435f9a4214ae7f85b7e /src/appl/bsd | |
parent | 671787e2b4910be41223d0f7961acea87ad498ce (diff) | |
download | krb5-c37e7830bd25238f680af7464837c829a89337cf.tar.gz krb5-c37e7830bd25238f680af7464837c829a89337cf.tar.xz krb5-c37e7830bd25238f680af7464837c829a89337cf.zip |
Mainline utmp and login cleanups from hartmans_pty_utmp:
* Fix utmp handling on Solaris for wtmpx records
* Replace krlogin's SIGURG handler with a call to select squashing Solaris ctrl-c bug
* Fix utmp on systems without pututline so ttyslot is only used when it works
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7338 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/bsd')
-rw-r--r-- | src/appl/bsd/ChangeLog | 14 | ||||
-rw-r--r-- | src/appl/bsd/configure.in | 6 | ||||
-rw-r--r-- | src/appl/bsd/krlogin.c | 159 | ||||
-rw-r--r-- | src/appl/bsd/krlogind.c | 3 | ||||
-rw-r--r-- | src/appl/bsd/login.c | 2 |
5 files changed, 52 insertions, 132 deletions
diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 6945cedaf..4e2f94298 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,17 @@ +Wed Jan 17 15:14:33 1996 Sam Hartman <hartmans@tertius.mit.edu> + + * krlogin.c ((reader): Use select to find out-of-band data, not signals. + (oob): No longer a signal handler; just a function. + (writer): get rid of copytochild setup as sigurg no longer needed + (main): Don't block SIGURG + * configure.in : Include sys/time.h check + +Mon Jan 15 16:16:07 1996 Sam Hartman <hartmans@tertius.mit.edu> + + * login.c (main): ttyslot usable here as well + + * krlogind.c (doit): update_utmp can use ttyslot. + Thu Jan 11 12:40:08 1996 Ezra Peisach (epeisach@paris) * krsh.c, krlogin.c: (main): Ultrix cc does not support automatic diff --git a/src/appl/bsd/configure.in b/src/appl/bsd/configure.in index 114d29547..7e5e2a910 100644 --- a/src/appl/bsd/configure.in +++ b/src/appl/bsd/configure.in @@ -52,9 +52,9 @@ AC_FUNC_CHECK(grantpt,AC_DEFINE(HAVE_GRANTPT)) AC_FUNC_CHECK(openpty,AC_DEFINE(HAVE_OPENPTY)) AC_FUNC_CHECK(setlogin,AC_DEFINE(HAVE_SETLOGIN)) AC_FUNC_CHECK(logwtmp,AC_DEFINE(HAVE_LOGWTMP)) -AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h) -AC_CHECK_HEADERS(sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h) -AC_CHECK_HEADERS(sys/ptyvar.h utmp.h utmpx.h stdarg.h) +AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h ) +AC_CHECK_HEADERS(sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h ) +AC_CHECK_HEADERS(sys/ptyvar.h utmp.h utmpx.h stdarg.h sys/time.h) AC_REPLACE_FUNCS(getdtablesize) DECLARE_SYS_ERRLIST KRB5_SIGTYPE diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 3483f7940..00f3e765c 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -64,6 +64,12 @@ char copyright[] = #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif +#if HAVE_SYS_TIME_H +#include <sys/time.h> +#endif #ifdef POSIX_TERMIOS #include <termios.h> @@ -216,7 +222,8 @@ struct winsize winsize; char *host=0; /* external, so it can be reached from confirm_death() */ -krb5_sigtype sigwinch KRB5_PROTOTYPE((int)), oob KRB5_PROTOTYPE((int)); +krb5_sigtype sigwinch KRB5_PROTOTYPE((int)); +void oob KRB5_PROTOTYPE((void)); krb5_sigtype lostpeer KRB5_PROTOTYPE((int)); #if __STDC__ int setsignal(int sig, krb5_sigtype (*act)()); @@ -544,16 +551,15 @@ main(argc, argv) (void) sigaction(SIGPIPE, &sa, (struct sigaction *)0); (void) sigemptyset(&urgmask); - (void) sigaddset(&urgmask, SIGURG); (void) sigaddset(&urgmask, SIGUSR1); oldmask = &omask; (void) sigprocmask(SIG_BLOCK, &urgmask, oldmask); #else (void) signal(SIGPIPE, lostpeer); #ifdef sgi - oldmask = sigignore(sigmask(SIGURG) | sigmask(SIGUSR1)); + oldmask = sigignore( sigmask(SIGUSR1)); #else - oldmask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1)); + oldmask = sigblock( sigmask(SIGUSR1)); #endif #endif /* POSIX_SIGNALS */ @@ -603,28 +609,6 @@ main(argc, argv) if (rem < 0) exit(1); - /* we need to do the SETOWN here so that we get the SIGURG - registered if the URG data come in early, before the reader() gets - to do this for real (otherwise, the signal is never generated - by the kernel). We block it above, so when it gets unblocked - it will get processed by the reader(). - There is a possibility that the signal will get delivered to both - writer and reader, but that is harmless, since the writer reflects - it to the reader, and the oob() processing code in the reader will - work properly even if it is called when no oob() data is present. - */ -#ifdef hpux - /* hpux invention */ - { - int pid = getpid(); - ioctl(rem, FIOSSAIOSTAT, &pid); /* trick: pid is non-zero */ - ioctl(rem, FIOSSAIOOWN, &pid); - } -#else -#ifdef HAVE_SETOWN - (void) fcntl(rem, F_SETOWN, getpid()); -#endif -#endif if (options & SO_DEBUG && setsockopt(rem, SOL_SOCKET, SO_DEBUG, (char*)&on, sizeof (on)) < 0) perror("rlogin: setsockopt (SO_DEBUG)"); @@ -682,8 +666,7 @@ int confirm_death () int child; krb5_sigtype catchild KRB5_PROTOTYPE((int)); -krb5_sigtype copytochild KRB5_PROTOTYPE((int)), - writeroob KRB5_PROTOTYPE((int)); +krb5_sigtype writeroob KRB5_PROTOTYPE((int)); int defflags, tabflag; int deflflags; @@ -810,16 +793,8 @@ doit(oldmask) exit(3); } - /* - * We may still own the socket, and may have a pending SIGURG - * (or might receive one soon) that we really want to send to - * the reader. Set a trap that simply copies such signals to - * the child. - */ #ifdef POSIX_SIGNALS /* "sa" has already been initialized above. */ - sa.sa_handler = copytochild; - (void) sigaction(SIGURG, &sa, (struct sigaction *)0); sa.sa_handler = writeroob; (void) sigaction(SIGUSR1, &sa, (struct sigaction *)0); @@ -829,7 +804,6 @@ doit(oldmask) sa.sa_handler = catchild; (void) sigaction(SIGCHLD, &sa, (struct sigaction *)0); #else - (void) signal(SIGURG, copytochild); (void) signal(SIGUSR1, writeroob); #ifndef sgi (void) sigsetmask(oldmask); @@ -921,15 +895,6 @@ done(status) -/* - * Copy SIGURGs to the child process. - */ -krb5_sigtype - copytochild(signo) -int signo; -{ - (void) kill(child, SIGURG); -} @@ -1228,15 +1193,8 @@ int rcvcnt; int rcvstate; int ppid; -#ifdef POSIX_SETJMP -sigjmp_buf rcvtop; -#else -jmp_buf rcvtop; -#endif -krb5_sigtype - oob(signo) -int signo; +void oob() { #ifndef POSIX_TERMIOS int out = FWRITE; @@ -1253,33 +1211,9 @@ int signo; struct sgttyb sb; #endif #endif + mark = 0; - while (recv(rem, &mark, 1, MSG_OOB) < 0) - switch (errno) { - - case EWOULDBLOCK: - /* - * Urgent data not here yet. - * It may not be possible to send it yet - * if we are blocked for output - * and our input buffer is full. - */ - if (rcvcnt < sizeof(rcvbuf)) { - n = read(rem, rcvbuf + rcvcnt, - sizeof(rcvbuf) - rcvcnt); - if (n <= 0) - return; - rcvd += n; - } else { - n = read(rem, waste, sizeof(waste)); - if (n <= 0) - return; - } - continue; - - default: - return; - } + recv(rem, &mark, 1, MSG_OOB); if (mark & TIOCPKT_WINDOW) { /* * Let server know about window size changes @@ -1347,38 +1281,11 @@ int signo; n = read(rem, waste, sizeof (waste)); if (n <= 0) break; +return; } - /* - * Don't want any pending data to be output, - * so clear the recv buffer. - * If we were hanging on a write when interrupted, - * don't want it to restart. If we were reading, - * restart anyway. - */ - rcvcnt = 0; -#ifdef POSIX_SETJMP - siglongjmp(rcvtop, 1); -#else - longjmp(rcvtop, 1); -#endif } - /* - * oob does not do FLUSHREAD (alas!) - */ - /* - * If we filled the receive buffer while a read was pending, - * longjmp to the top to restart appropriately. Don't abort - * a pending write, however, or we won't know how much was written. - */ -#ifdef POSIX_SETJMP - if (rcvd && rcvstate == READING) - siglongjmp(rcvtop, 1); -#else - if (rcvd && rcvstate == READING) - longjmp(rcvtop, 1); -#endif } @@ -1398,6 +1305,7 @@ reader(oldmask) #else int pid = -getpid(); #endif +fd_set readset, excset; int n, remaining; char *bufp = rcvbuf; @@ -1409,27 +1317,13 @@ reader(oldmask) sa.sa_handler = SIG_IGN; (void) sigaction(SIGTTOU, &sa, (struct sigaction *)0); -#ifdef SA_RESTART - /* Because SIGURG will be coming in during a read, - * we want to restart the syscall afterwards. */ - sa.sa_flags |= SA_RESTART; -#endif - sa.sa_handler = oob; - (void) sigaction(SIGURG, &sa, (struct sigaction *)0); #else (void) signal(SIGTTOU, SIG_IGN); - (void) signal(SIGURG, oob); #endif ppid = getppid(); -#ifdef HAVE_SETOWN - (void) fcntl(rem, F_SETOWN, pid); -#endif -#ifdef POSIX_SETJMP - (void) sigsetjmp(rcvtop, 1); -#else - (void) setjmp(rcvtop); -#endif +FD_ZERO(&readset); + FD_ZERO(&excset); #ifdef POSIX_SIGNALS sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0); #else @@ -1437,6 +1331,7 @@ reader(oldmask) (void) sigsetmask(oldmask); #endif #endif /* POSIX_SIGNALS */ + for (;;) { while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) { rcvstate = WRITING; @@ -1450,11 +1345,21 @@ reader(oldmask) } bufp = rcvbuf; rcvcnt = 0; - rcvstate = READING; - rcvcnt = des_read(rem, rcvbuf, sizeof (rcvbuf)); + rcvstate = READING; +FD_SET(rem,&readset); + FD_SET(rem,&excset); + if (select(rem+1, &readset, 0, &excset, 0) > 0 ) { +if (FD_ISSET(rem, &excset)) + oob(); +if (FD_ISSET(rem, &readset)) { + rcvcnt = des_read(rem, rcvbuf, sizeof (rcvbuf)); if (rcvcnt == 0) return (0); - if (rcvcnt < 0) { + if (rcvcnt < 0) + goto error; +} + } else + error: { if (errno == EINTR) continue; perror("read"); diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 36dd01de7..33867b180 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -703,7 +703,8 @@ int syncpipe[2]; #ifndef NO_UT_PID { - pty_update_utmp(PTY_LOGIN_PROCESS, getpid(), "rlogin", line, ""/*host*/); + pty_update_utmp(PTY_LOGIN_PROCESS, getpid(), "rlogin", line, + ""/*host*/, PTY_TTYSLOT_USABLE); } #endif diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index a6c45173a..d1e98e23a 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -784,7 +784,7 @@ bad_login: struct utmp utmp; login_time = time(&utmp.ut_time); - if ( (retval = pty_update_utmp(PTY_USER_PROCESS, getpid(), username, ttyn, hostname)) < 0 ) + if ( (retval = pty_update_utmp(PTY_USER_PROCESS, getpid(), username, ttyn, hostname, PTY_TTYSLOT_USABLE)) < 0 ) com_err (argv[0], retval, "while updating utmp"); } |