[PATCH] pam_lastlog.c: Fix build with musl
maxin.john at gmail.com
maxin.john at gmail.com
Tue May 24 14:36:22 UTC 2016
From: "Maxin B. John" <maxin.john at intel.com>
Define strndupa if not available in libc. Also fix headers to explicitly
needed include files which glibc was including indirectly
Signed-off-by: Khem Raj <raj.khem at gmail.com>
Signed-off-by: Maxin B. John <maxin.john at intel.com>
---
modules/pam_lastlog/pam_lastlog.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c
index 1e2f08d..6c17a31 100644
--- a/modules/pam_lastlog/pam_lastlog.c
+++ b/modules/pam_lastlog/pam_lastlog.c
@@ -23,9 +23,11 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <sys/file.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
+#include <paths.h>
#if defined(hpux) || defined(sunos) || defined(solaris)
# ifndef _PATH_LASTLOG
@@ -332,6 +334,23 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid, time_t
return retval;
}
+#ifndef __GLIBC__
+static void logwtmp(const char * line, const char * name, const char * host)
+{
+ struct utmp u;
+ memset(&u, 0, sizeof(u));
+
+ u.ut_pid = getpid();
+ u.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS;
+ strncpy(u.ut_line, line, sizeof(u.ut_line));
+ strncpy(u.ut_name, name, sizeof(u.ut_name));
+ strncpy(u.ut_host, host, sizeof(u.ut_host));
+ gettimeofday(&(u.ut_tv), NULL);
+
+ updwtmp(_PATH_WTMP, &u);
+}
+#endif /* __GLIBC__ */
+
static int
last_login_write(pam_handle_t *pamh, int announce, int last_fd,
uid_t uid, const char *user)
--
2.4.0
More information about the Pam-list
mailing list