From: Tom Yu Date: Wed, 9 May 2001 03:38:37 +0000 (+0000) Subject: * logwtmp.c: Delete code under "#if 0". Fix reversed test for X-Git-Tag: krb5-1.3-alpha1~1514 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d84339bed1350e13a02edf83bd1a8624dd889188;p=krb5.git * logwtmp.c: Delete code under "#if 0". Fix reversed test for loggingin. Don't forget to set the ut_tv or ut_time for the entry. * update_utmp.c: Update rant about Tru64; remove fetching of ut_user from old entry. The existence of the old ut_user in the logout entry in wtmp was confusing last. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13237 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index 8bea2de82..c17a9e5b0 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,5 +1,13 @@ 2001-05-08 Tom Yu + * logwtmp.c: Delete code under "#if 0". Fix reversed test for + loggingin. Don't forget to set the ut_tv or ut_time for the + entry. + + * update_utmp.c: Update rant about Tru64; remove fetching of + ut_user from old entry. The existence of the old ut_user in the + logout entry in wtmp was confusing last. + * cleanup.c: Call update_utmp() with the correct pid to assist in finding the old utmp entry. diff --git a/src/util/pty/logwtmp.c b/src/util/pty/logwtmp.c index 5b10f4616..204727889 100644 --- a/src/util/pty/logwtmp.c +++ b/src/util/pty/logwtmp.c @@ -46,7 +46,7 @@ pty_logwtmp(const char *tty, const char *user, const char *host) return 0; #else - loggingin = (user[0] == '\0'); + loggingin = (user[0] != '\0'); memset(&utx, 0, sizeof(utx)); strncpy(utx.ut_line, tty, sizeof(utx.ut_line)); @@ -55,6 +55,11 @@ pty_logwtmp(const char *tty, const char *user, const char *host) || (!defined(HAVE_SETUTXENT) && defined(HAVE_STRUCT_UTMP_UT_HOST)) strncpy(utx.ut_host, host, sizeof(utx.ut_host)); utx.ut_host[sizeof(utx.ut_host) - 1] = '\0'; +#endif +#ifdef HAVE_SETUTXENT + gettimeofday(&utx.ut_tv, NULL); +#else + (void)time(&utx.ut_time); #endif utx.ut_pid = (loggingin ? getpid() : 0); utx.ut_type = (loggingin ? USER_PROCESS : DEAD_PROCESS); @@ -101,44 +106,3 @@ pty_logwtmp(const char *tty, const char *user, const char *host) } #endif /* !(defined(HAVE_SETUTXENT) || defined(HAVE_SETUTENT)) */ - -#if 0 -long pty_logwtmp (tty, user, host ) - char *user, *tty, *host; -{ -#ifdef HAVE_LOGWTMP - logwtmp(tty,user,host); - return 0; -#else - struct utmp ut; - char *tmpx; - char utmp_id[5]; - - /* Will be empty for logout */ - int loggingin = user[0]; - - -#ifndef NO_UT_HOST - strncpy(ut.ut_host, host, sizeof(ut.ut_host)); -#endif - - strncpy(ut.ut_line, tty, sizeof(ut.ut_line)); - ut.ut_time = time(0); - -#ifndef NO_UT_PID - ut.ut_pid = getpid(); - strncpy(ut.ut_user, user, 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)); - ut.ut_pid = (loggingin ? getpid() : 0); - ut.ut_type = (loggingin ? USER_PROCESS : DEAD_PROCESS); -#else - strncpy(ut.ut_name, user, sizeof(ut.ut_name)); -#endif - - return ptyint_update_wtmp(&ut, host, user); -#endif /*HAVE_LOGWTMP*/ -} -#endif diff --git a/src/util/pty/update_utmp.c b/src/util/pty/update_utmp.c index 6eefe89b6..e47fede75 100644 --- a/src/util/pty/update_utmp.c +++ b/src/util/pty/update_utmp.c @@ -275,6 +275,9 @@ * contains the expected fields. The files utmp and wtmp seem to * exist, but not utmpx or wtmpx. * + * When writing a logout entry, the presence of a non-empty username + * confuses last. + * * AIX 4.3.x: * * The ut_exit field seems to exist in utmp, but not utmpx. The files @@ -300,6 +303,9 @@ * available, we write the utmpx or utmp structure out to disk * ourselves, though sometimes conversion from utmpx to utmp format is * needed. + * + * We assume that at logout the system is ok with with having an empty + * username both in utmp and wtmp. */ #include @@ -608,13 +614,6 @@ pty_update_utmp(int process_type, int pid, const char *username, strncpy(utx2.ut_line, utxtmp->ut_line, sizeof(utx2.ut_line)); } - if (username[0] == '\0' - && (flags & PTY_UTMP_USERNAME_VALID) && utxtmp != NULL) { - /* Use the ut_user from the entry we looked up, if any. */ - /* XXX Is this really necessary? */ - strncpy(utx2.ut_user, utxtmp->ut_user, sizeof(utx2.ut_user)); - } - PTY_SETUTXENT(); PTY_PUTUTXLINE(&utx); PTY_ENDUTXENT();