diff options
author | Steve Langasek <vorlon@debian.org> | 2019-01-22 14:54:11 -0800 |
---|---|---|
committer | Steve Langasek <vorlon@debian.org> | 2019-01-22 14:54:11 -0800 |
commit | f00afb1ef201b2eef7f9ddbe5a0c6ca802cf49bb (patch) | |
tree | 402838c53047b0e21466a653ae88d86a8e4b7b65 /modules/pam_lastlog/pam_lastlog.c | |
parent | 795badba7f95e737f979917859cd32c9bd47bcad (diff) | |
parent | 1cad9fb2a0d729c5b5e5aa7297c521df7d5a2d33 (diff) | |
download | pam-f00afb1ef201b2eef7f9ddbe5a0c6ca802cf49bb.tar.gz pam-f00afb1ef201b2eef7f9ddbe5a0c6ca802cf49bb.tar.bz2 pam-f00afb1ef201b2eef7f9ddbe5a0c6ca802cf49bb.zip |
New upstream version 1.3.0
Diffstat (limited to 'modules/pam_lastlog/pam_lastlog.c')
-rw-r--r-- | modules/pam_lastlog/pam_lastlog.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c index bd454ffd..1e2f08d2 100644 --- a/modules/pam_lastlog/pam_lastlog.c +++ b/modules/pam_lastlog/pam_lastlog.c @@ -276,12 +276,12 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid, time_t time_t ll_time; ll_time = last_login.ll_time; - tm = localtime_r (&ll_time, &tm_buf); - strftime (the_time, sizeof (the_time), - /* TRANSLATORS: "strftime options for date of last login" */ - _(" %a %b %e %H:%M:%S %Z %Y"), tm); - - date = the_time; + if ((tm = localtime_r (&ll_time, &tm_buf)) != NULL) { + strftime (the_time, sizeof (the_time), + /* TRANSLATORS: "strftime options for date of last login" */ + _(" %a %b %e %H:%M:%S %Z %Y"), tm); + date = the_time; + } } /* we want & have the host? */ @@ -350,6 +350,8 @@ last_login_write(pam_handle_t *pamh, int announce, int last_fd, return PAM_SERVICE_ERR; } + memset(&last_login, 0, sizeof(last_login)); + /* set this login date */ D(("set the most recent login time")); (void) time(&ll_time); /* set the time */ @@ -364,14 +366,12 @@ last_login_write(pam_handle_t *pamh, int announce, int last_fd, } /* copy to last_login */ - last_login.ll_host[0] = '\0'; strncat(last_login.ll_host, remote_host, sizeof(last_login.ll_host)-1); /* set the terminal line */ terminal_line = get_tty(pamh); /* copy to last_login */ - last_login.ll_line[0] = '\0'; strncat(last_login.ll_line, terminal_line, sizeof(last_login.ll_line)-1); terminal_line = NULL; @@ -566,7 +566,7 @@ cleanup: } /* --- authentication (locking out inactive users) functions --- */ -PAM_EXTERN int +int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { @@ -628,21 +628,22 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags, lltime = (time(NULL) - lltime) / (24*60*60); if (lltime > inactive_days) { - pam_syslog(pamh, LOG_INFO, "user %s inactive for %d days - denied", user, lltime); + pam_syslog(pamh, LOG_INFO, "user %s inactive for %ld days - denied", + user, (long) lltime); return PAM_AUTH_ERR; } return PAM_SUCCESS; } -PAM_EXTERN int +int pam_sm_setcred(pam_handle_t *pamh UNUSED, int flags UNUSED, int argc UNUSED, const char **argv UNUSED) { return PAM_SUCCESS; } -PAM_EXTERN int +int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) { @@ -651,7 +652,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, /* --- session management functions --- */ -PAM_EXTERN int +int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { @@ -701,7 +702,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, return retval; } -PAM_EXTERN int +int pam_sm_close_session (pam_handle_t *pamh, int flags, int argc, const char **argv) { @@ -718,20 +719,4 @@ pam_sm_close_session (pam_handle_t *pamh, int flags, return PAM_SUCCESS; } -#ifdef PAM_STATIC - -/* static module data */ - -struct pam_module _pam_lastlog_modstruct = { - "pam_lastlog", - pam_sm_authenticate, - pam_sm_setcred, - pam_sm_acct_mgmt, - pam_sm_open_session, - pam_sm_close_session, - NULL, -}; - -#endif - /* end of module definition */ |