diff options
author | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-08-24 18:01:22 +0000 |
---|---|---|
committer | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-08-24 18:01:22 +0000 |
commit | 4f552174b48efdde7d47e090ebc6203657adc19b (patch) | |
tree | 3149830727becf72d4a5f0ead3d212b2ef89c6cc /modules | |
parent | 59a0a225801c71269dc07f96df3861b74f7949e3 (diff) | |
download | pam-4f552174b48efdde7d47e090ebc6203657adc19b.tar.gz pam-4f552174b48efdde7d47e090ebc6203657adc19b.tar.bz2 pam-4f552174b48efdde7d47e090ebc6203657adc19b.zip |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
2006-08-24 Thorsten Kukuk <kukuk@thkukuk.de>
* release version 0.99.6.2
* modules/pam_lastlog/pam_lastlog.c (last_login_date): Create
lastlog file if it does not exist.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/pam_lastlog/pam_lastlog.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c index f470166f..a26b7c2e 100644 --- a/modules/pam_lastlog/pam_lastlog.c +++ b/modules/pam_lastlog/pam_lastlog.c @@ -12,6 +12,7 @@ #include <fcntl.h> #include <time.h> +#include <errno.h> #ifdef HAVE_UTMP_H # include <utmp.h> #else @@ -327,9 +328,23 @@ last_login_date(pam_handle_t *pamh, int announce, uid_t uid, const char *user) /* obtain the last login date and all the relevant info */ last_fd = open(_PATH_LASTLOG, O_RDWR); if (last_fd < 0) { - pam_syslog(pamh, LOG_ERR, "unable to open %s: %m", _PATH_LASTLOG); - D(("unable to open %s file", _PATH_LASTLOG)); - return PAM_SERVICE_ERR; + if (errno == ENOENT) { + last_fd = open(_PATH_LASTLOG, O_RDWR|O_CREAT, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if (last_fd < 0) { + pam_syslog(pamh, LOG_ERR, + "unable to create %s: %m", _PATH_LASTLOG); + D(("unable to create %s file", _PATH_LASTLOG)); + return PAM_SERVICE_ERR; + } + pam_syslog(pamh, LOG_WARN, + "file %s created", _PATH_LASTLOG); + D(("file %s created", _PATH_LASTLOG)); + } else { + pam_syslog(pamh, LOG_ERR, "unable to open %s: %m", _PATH_LASTLOG); + D(("unable to open %s file", _PATH_LASTLOG)); + return PAM_SERVICE_ERR; + } } if (lseek(last_fd, sizeof(struct lastlog) * (off_t) uid, SEEK_SET) < 0) { |