From 97526c738c4cd08d52cb022605460e34b2f0b80f Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 15 Nov 2002 22:42:00 +0000 Subject: utmp.ut_time and lastlog.ll_time are explicitly int32_t rather than time_t. Deal with the possibility that time_t != int32_t. This boils down to this sort of thing: - time(&ut.ut_time); + ut.ut_time = time(NULL); and similar for ctime(3) etc. I've kept it minimal for the stuff that may need to be portable (or 3rd party code), but used Matt's time32 stuff for cases where that isn't as much of a concern. Approved by: re (jhb) --- lib/libpam/modules/pam_lastlog/pam_lastlog.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c index f33d0a6..66f61d3 100644 --- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c +++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c @@ -71,6 +71,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, struct passwd *pwd; struct utmp utmp; struct lastlog ll; + time_t t; const char *rhost, *user, *tty; off_t llpos; int fd, pam_err; @@ -109,13 +110,14 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, goto file_err; if ((flags & PAM_SILENT) == 0) { if (read(fd, &ll, sizeof ll) == sizeof ll && ll.ll_time != 0) { + t = ll.ll_time; if (*ll.ll_host != '\0') pam_info(pamh, "Last login: %.*s from %.*s", - 24 - 5, ctime(&ll.ll_time), + 24 - 5, ctime(&t), (int)sizeof(ll.ll_host), ll.ll_host); else pam_info(pamh, "Last login: %.*s on %.*s", - 24 - 5, ctime(&ll.ll_time), + 24 - 5, ctime(&t), (int)sizeof(ll.ll_line), ll.ll_line); } if (lseek(fd, llpos, L_SET) != llpos) @@ -123,7 +125,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, } bzero(&ll, sizeof(ll)); - time(&ll.ll_time); + ll.ll_time = time(NULL); /* note: does not need to be NUL-terminated */ strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); @@ -140,7 +142,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, * Record session in utmp(5) and wtmp(5). */ bzero(&utmp, sizeof(utmp)); - time(&utmp.ut_time); + utmp.ut_time = time(NULL); /* note: does not need to be NUL-terminated */ strncpy(utmp.ut_name, user, sizeof(utmp.ut_name)); if (rhost != NULL) -- cgit v1.1