Hi,
here is a proposed patch by me:
--- modules/pam_lastlog/pam_lastlog.c 16 Jun 2006 06:58:26 -0000 1.21
+++ modules/pam_lastlog/pam_lastlog.c 24 Aug 2006 14:41:28 -0000
@@ -12,6 +12,7 @@
#include <fcntl.h>
#include <time.h>
+#include <errno.h>
#ifdef HAVE_UTMP_H
# include <utmp.h>
#else
@@ -327,9 +328,22 @@
/* 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);
+ 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_INFO,
+ "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) {
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@...
SUSE LINUX Products GmbH Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = 8C6B FD92 EE0F 42ED F91A 6A73 6D1A 7F05 2E59 24BB
|