2001-05-08 Tom Yu <tlyu@mit.edu>
+ * 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.
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));
|| (!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);
}
#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
* 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
* 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 <com_err.h>
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();