diff options
author | Damien Miller <djm@mindrot.org> | 1999-12-28 10:41:12 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-12-28 10:41:12 +1100 |
commit | 4ff2b9bf429f40cb4d8119108cd7c4aa76c081ee (patch) | |
tree | 1d5585780b56b4296c8dfa43caf69fa0a1b96523 /login.c | |
parent | 13bc0be2b65b65ab7ac020bbd0a772ed3abe1738 (diff) |
- NetBSD login.c compile fix from David Rankin
<drankin@bohemians.lexington.ky.us>
- Fully set ut_tv if present in utmp or utmpx
Diffstat (limited to 'login.c')
-rw-r--r-- | login.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -18,7 +18,7 @@ */ #include "includes.h" -RCSID("$Id: login.c,v 1.13 1999/12/27 00:33:56 damien Exp $"); +RCSID("$Id: login.c,v 1.14 1999/12/27 23:41:12 damien Exp $"); #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include <utmpx.h> @@ -142,10 +142,18 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, memset(&u, 0, sizeof(u)); strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); strncpy(u.ut_id, ttyname + 8, sizeof(u.ut_id)); - u.ut_pid = (pid_t)pid; - u.ut_time = time(NULL); strncpy(u.ut_name, user, sizeof(u.ut_name)); +#if defined(HAVE_TV_IN_UTMP) + (void)gettimeofday(&u.ut_tv, NULL); +#else /* defined(HAVE_TV_IN_UTMP) */ + u.ut_time = time(NULL); +#endif /* defined(HAVE_TV_IN_UTMP) */ +#if defined(HAVE_PID_IN_UTMP) + u.ut_pid = (pid_t)pid; +#endif /* HAVE_PID_IN_UTMP */ +#if defined(HAVE_TYPE_IN_UTMP) u.ut_type = (uid == -1)?DEAD_PROCESS:USER_PROCESS; +#endif /* HAVE_TYPE_IN_UTMP */ #if defined(HAVE_HOST_IN_UTMP) strncpy(u.ut_host, host, sizeof(u.ut_host)); #endif @@ -156,7 +164,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, strncpy(utx.ut_line, ttyname + 5, sizeof(utx.ut_line)); strncpy(utx.ut_id, ttyname + 8, sizeof(utx.ut_id)); utx.ut_pid = (pid_t)pid; - utx.ut_tv.tv_sec = time(NULL); + (void)gettimeofday(&utx.ut_tv, NULL); utx.ut_type = (uid == -1)?DEAD_PROCESS:USER_PROCESS; # ifdef HAVE_HOST_IN_UTMPX # ifdef HAVE_SYSLEN_IN_UTMPX |