Signed-off-by: Yousong Zhou <[email protected]> --- ...ide-wtmp-compatibility-stub-for-Linux-PAM.patch | 104 ++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 toolchain/musl/patches/200-Provide-wtmp-compatibility-stub-for-Linux-PAM.patch
diff --git a/toolchain/musl/patches/200-Provide-wtmp-compatibility-stub-for-Linux-PAM.patch b/toolchain/musl/patches/200-Provide-wtmp-compatibility-stub-for-Linux-PAM.patch new file mode 100644 index 0000000..fd9d9b1 --- /dev/null +++ b/toolchain/musl/patches/200-Provide-wtmp-compatibility-stub-for-Linux-PAM.patch @@ -0,0 +1,104 @@ +From 57f783cdc46dd11a186dd6fb78ebba1a3986cf6d Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <[email protected]> +Date: Tue, 16 Jun 2015 16:49:39 +0800 +Subject: [PATCH] Provide wtmp compatibility stub for Linux PAM. + +Adapted from a version by Raphael Cohn [1] + + - Patch to musl to provide wtmp for Linux PAM, + http://www.openwall.com/lists/musl/2013/12/04/11 + +Signed-off-by: Yousong Zhou <[email protected]> +--- + include/utmp.h | 6 +----- + include/utmpx.h | 9 +++++++-- + src/legacy/utmp.c | 20 ++++++++++++++++++++ + 3 files changed, 28 insertions(+), 7 deletions(-) + create mode 100644 src/legacy/utmp.c + +diff --git a/include/utmp.h b/include/utmp.h +index 24e2da7..2338587 100644 +--- a/include/utmp.h ++++ b/include/utmp.h +@@ -7,11 +7,6 @@ extern "C" { + + #include <utmpx.h> + +-#define ACCOUNTING 9 +-#define UT_NAMESIZE 32 +-#define UT_HOSTSIZE 256 +-#define UT_LINESIZE 32 +- + struct lastlog { + time_t ll_time; + char ll_line[UT_LINESIZE]; +@@ -39,6 +34,7 @@ int login_tty(int); + + #define _PATH_UTMP "/dev/null/utmp" + #define _PATH_WTMP "/dev/null/wtmp" ++#define _PATH_LASTLOG "/dev/null/lastlog" + + #define UTMP_FILE _PATH_UTMP + #define WTMP_FILE _PATH_WTMP +diff --git a/include/utmpx.h b/include/utmpx.h +index f0c3b01..12da4da 100644 +--- a/include/utmpx.h ++++ b/include/utmpx.h +@@ -14,14 +14,18 @@ extern "C" { + + #include <bits/alltypes.h> + ++#define UT_NAMESIZE 32 ++#define UT_HOSTSIZE 256 ++#define UT_LINESIZE 32 ++ + struct utmpx + { + short ut_type; + pid_t ut_pid; + char ut_line[32]; + char ut_id[4]; +- char ut_user[32]; +- char ut_host[256]; ++ char ut_user[UT_NAMESIZE]; ++ char ut_host[UT_HOSTSIZE]; + struct { + short __e_termination; + short __e_exit; +@@ -54,6 +58,7 @@ void updwtmpx(const char *, const struct utmpx *); + #define LOGIN_PROCESS 6 + #define USER_PROCESS 7 + #define DEAD_PROCESS 8 ++#define ACCOUNTING 9 + + #ifdef __cplusplus + } +diff --git a/src/legacy/utmp.c b/src/legacy/utmp.c +new file mode 100644 +index 0000000..4c94547 +--- /dev/null ++++ b/src/legacy/utmp.c +@@ -0,0 +1,20 @@ ++#include <utmp.h> ++#include <string.h> ++#include <unistd.h> ++#include <sys/time.h> ++#include "libc.h" ++ ++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); ++} +-- +1.7.10.4 + -- 1.7.10.4 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
