summaryrefslogtreecommitdiffstats
path: root/lib/libpam
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-11-15 22:42:00 +0000
committerpeter <peter@FreeBSD.org>2002-11-15 22:42:00 +0000
commit97526c738c4cd08d52cb022605460e34b2f0b80f (patch)
tree414badc6420598c8e62302e330f16ee827afd3eb /lib/libpam
parentc841be9bcbd974616aaa3b10b66a62d927ea1f88 (diff)
downloadFreeBSD-src-97526c738c4cd08d52cb022605460e34b2f0b80f.zip
FreeBSD-src-97526c738c4cd08d52cb022605460e34b2f0b80f.tar.gz
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)
Diffstat (limited to 'lib/libpam')
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.c10
1 files changed, 6 insertions, 4 deletions
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)
OpenPOWER on IntegriCloud