summaryrefslogtreecommitdiff
path: root/modules/pam_lastlog/pam_lastlog.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2005-12-20 21:28:06 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2005-12-20 21:28:06 +0000
commitb1d9b2322daa439194aaa53037fe27a0ccc0596b (patch)
tree65c7a0d7197333c810fe6bd6c5abe0a5f0e99238 /modules/pam_lastlog/pam_lastlog.c
parent065665d89f20cb18167ca158b39c7e122107cf49 (diff)
Relevant BUGIDs:
Purpose of commit: new feature Commit summary: --------------- 2005-12-20 Thorsten Kukuk <kukuk@thkukuk.de> * modules/pam_lastlog/pam_lastlog.c (last_login_read): Use strftime instead of ctime.
Diffstat (limited to 'modules/pam_lastlog/pam_lastlog.c')
-rw-r--r--modules/pam_lastlog/pam_lastlog.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c
index 947d3c2d..24a13ef6 100644
--- a/modules/pam_lastlog/pam_lastlog.c
+++ b/modules/pam_lastlog/pam_lastlog.c
@@ -139,6 +139,7 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid)
struct flock last_lock;
struct lastlog last_login;
int retval = PAM_SUCCESS;
+ char the_time[256];
char *date = NULL;
char *host = NULL;
char *line = NULL;
@@ -176,18 +177,15 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid)
/* we want the date? */
if (announce & LASTLOG_DATE) {
+ struct tm *tm, tm_buf;
time_t ll_time;
- char *the_time;
ll_time = last_login.ll_time;
- the_time = ctime(&ll_time);
- the_time[strlen(the_time)-1] = '\0'; /* strip trailing '\n' */
+ tm = localtime_r (&ll_time, &tm_buf);
+ strftime (the_time, sizeof (the_time),
+ " %a %b %e %H:%M:%S %Z %Y", tm);
- if (asprintf(&date, " %s", the_time) < 0) {
- pam_syslog(pamh, LOG_ERR, "out of memory");
- retval = PAM_BUF_ERR;
- goto cleanup;
- }
+ date = the_time;
}
/* we want & have the host? */
@@ -229,7 +227,6 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid)
cleanup:
memset(&last_login, 0, sizeof(last_login));
_pam_overwrite(date);
- _pam_drop(date);
_pam_overwrite(host);
_pam_drop(host);
_pam_overwrite(line);