From dba0e1cfe0fb2cbc2245818155d28ddd81c15db3 Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Fri, 30 Dec 1994 04:38:18 +0000 Subject: [PATCH] configure.in: Removed extraneous characters krlogind.c: Try all the forms of tty access (for most types of machines) logutil.c: Corrected conditionalization for ut_pid. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4780 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 27 ++++++++-------- src/appl/bsd/configure.in | 4 +-- src/appl/bsd/krlogind.c | 67 +++++++++++++++++++-------------------- src/appl/bsd/logutil.c | 9 ++++-- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 71fe38701..5afde16cd 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,28 +1,27 @@ Thu Dec 29 10:12:48 1994 Richard Basch (probe@tardis) * krlogind.c + Conditionalize grantpt/unlockpt on HAVE_GRANTPT (not just Sun) + Conditionalized references to ut_type and ut_pid. + Try all the methods for getting a pty... + * logutil.c - Conditionalized references to ut_type. + Conditionalized references to ut_type and ut_pid. - * krlogind.c * configure.in Conditionalize grantpt/unlockpt on HAVE_GRANTPT - (added check to configure.in) - - * krlogind.c - Try all the pty master devices. Other systems frequently - use the same names. + Corrected a minor syntactical error with extraneous "]," Thu Dec 29 01:38:17 1994 Richard Basch * krlogind.c: - More error checking for Solaris tty setup routines (grantpt/unlockpt) - Commented out the OOB code, as it causes problems currently. - Cleaned up some of the #ifdef's for logging incoming users - Removed extraneous declaration of malloc() - Pass a "" for the hostname rather than NULL to update_utmp. - Some additional cosmetic changes. - Included/excluded #ifdef SYSV code (SYSV is not defined anywhere) + Error checks for Solaris tty setup routines (grantpt/unlockpt) + Commented out the OOB code, as it causes problems currently. + Cleaned up some of the #ifdef's for logging incoming users + Removed extraneous declaration of malloc() + Pass a "" for the hostname rather than NULL to update_utmp. + Some additional cosmetic changes. + Included/excluded SYSV code (SYSV is not defined anywhere) Wed Dec 28 14:59:58 1994 Richard Basch (probe@tardis) diff --git a/src/appl/bsd/configure.in b/src/appl/bsd/configure.in index 1c459b0a5..a265b05ca 100644 --- a/src/appl/bsd/configure.in +++ b/src/appl/bsd/configure.in @@ -44,7 +44,7 @@ CHECK_SETJMP CHECK_DIRENT CHECK_FCNTL CHECK_WAIT_TYPE -AC_HEADER_CHECK(termios.h,AC_FUNC_CHECK([cfsetispeed],AC_DEFINE(POSIX_TERMIOS))) +AC_HEADER_CHECK(termios.h,AC_FUNC_CHECK(cfsetispeed,AC_DEFINE(POSIX_TERMIOS))) KRB_INCLUDE CHECK_UTMP WITH_KRB5ROOT @@ -123,7 +123,7 @@ AC_CACHE_VAL(krb5_cv_setpgrp_args, krb5_cv_setpgrp_args=two, krb5_cv_setpgrp_args=void)]) AC_MSG_RESULT($krb5_cv_setpgrp_args) if test $krb5_cv_setpgrp_args = two; then -AC_DEFINE(SETPGRP_TWOARG)], +AC_DEFINE(SETPGRP_TWOARG) fi dnl dnl diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 31d34c778..32dd82eb7 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -1374,57 +1374,54 @@ getpty(fd,slave) int i,ptynum; struct stat stb; -#ifdef HAVE_STREAMS - *fd = open("/dev/ptmx", O_RDWR|O_NDELAY); /* Solaris, IRIX */ if (*fd < 0) *fd = open("/dev/ptc", O_RDWR|O_NDELAY); /* AIX */ - if (*fd < 0) *fd = open("/dev/ptm", O_RDWR|O_NDELAY); /* OSF/1 */ if (*fd < 0) *fd = open("/dev/pty", O_RDWR|O_NDELAY); /* sysvimp */ - if (*fd < 0) return 1; + if (*fd >= 0) { #ifdef HAVE_GRANTPT - if (grantpt(*fd) || unlockpt(*fd)) return 1; + if (grantpt(*fd) || unlockpt(*fd)) return 1; #endif #ifdef HAVE_PTSNAME - p = ptsname(*fd); + p = ptsname(*fd); #else - p = ttyname(*fd); + p = ttyname(*fd); #endif - if (p) { - strcpy(slave, p); + if (p) { + strcpy(slave, p); + return 0; + } + + if (fstat(*fd, &stb) < 0) { + close(*fd); + return 1; + } + ptynum = (int)(stb.st_rdev&0xFF); + sprintf(slave, "/dev/ttyp%x", ptynum); return 0; - } - if (fstat(*fd, &stb) < 0) { - close(*fd); - return 1; - } - ptynum = (int)(stb.st_rdev&0xFF); - sprintf(slave, "/dev/ttyp%x", ptynum); - return 0; + } else { -#else /* NOT STREAMS */ - - for (c = 'p'; c <= 's'; c++) { - sprintf(slave,"/dev/ptyXX"); - slave[strlen("/dev/pty")] = c; - slave[strlen("/dev/ptyp")] = '0'; - if (stat(slave, &stb) < 0) - break; - for (i = 0; i < 16; i++) { - slave[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i]; - *fd = open(slave, O_RDWR); - if (*fd > 0) - goto gotpty; + for (c = 'p'; c <= 's'; c++) { + sprintf(slave,"/dev/ptyXX"); + slave[strlen("/dev/pty")] = c; + slave[strlen("/dev/ptyp")] = '0'; + if (stat(slave, &stb) < 0) + break; + for (i = 0; i < 16; i++) { + slave[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i]; + *fd = open(slave, O_RDWR); + if (*fd < 0) continue; + + /* got pty */ + slave[strlen("/dev/")] = 't'; + return 0; + } } + return 1; } - return 1; - gotpty: - slave[strlen("/dev/")] = 't'; - return 0; -#endif /* STREAMS */ } diff --git a/src/appl/bsd/logutil.c b/src/appl/bsd/logutil.c index 22e67a72b..d92eac7b7 100644 --- a/src/appl/bsd/logutil.c +++ b/src/appl/bsd/logutil.c @@ -74,7 +74,7 @@ void update_utmp(ent, username, line, host) ent->ut_host[0] = '\0'; #endif -#ifdef HAVE_SETUTENT +#ifndef NO_UT_PID tmpx = line + strlen(line)-1; if (*(tmpx-1) != '/') tmpx--; /* last two characters, unless it's a / */ sprintf(utmp_id, "kl%s", tmpx); @@ -158,19 +158,22 @@ void logwtmp(tty, locuser, host, loggingin) strncpy(ut.ut_line, tty, sizeof(ut.ut_line)); ut.ut_time = time(0); -#ifdef HAVE_SETUTENT +#ifndef NO_UT_PID + ut.ut_pid = getpid(); strncpy(ut.ut_user, locuser, sizeof(ut.ut_user)); tmpx = tty + strlen(tty) - 2; sprintf(utmp_id, "kr%s", tmpx); strncpy(ut.ut_id, utmp_id, sizeof(ut.ut_id)); +#else + strncpy(ut.ut_name, locuser, sizeof(ut.ut_name)); +#endif #ifndef NO_UT_TYPE ut.ut_type = (loggingin ? USER_PROCESS : DEAD_PROCESS); #endif #ifndef NO_UT_PID ut.ut_pid = (loggingin ? getpid() : 0); -#endif #endif update_wtmp(&ut); -- 2.26.2