From 6ff9c31abc14f207265ab214370982ecb3bfe428 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 25 Mar 2015 23:59:45 +0100 Subject: utmp: favour POSIX utmpx over SVID utmp Note: _PATH_UTMPX == _PATH_UTMP and the utmp struct is identical to the utmpx struct so this only changes the external API entrypoints and NOT the underlying data source. This saves about 500b (~1300b from previously ~1950) while at it. Signed-off-by: Bernhard Reutner-Fischer --- libutil/forkpty.c | 3 --- libutil/login.c | 6 +++--- libutil/login_tty.c | 1 - libutil/logout.c | 6 +++--- libutil/logwtmp.c | 21 ++------------------- libutil/openpty.c | 1 - 6 files changed, 8 insertions(+), 30 deletions(-) (limited to 'libutil') diff --git a/libutil/forkpty.c b/libutil/forkpty.c index ec490f053..24643330c 100644 --- a/libutil/forkpty.c +++ b/libutil/forkpty.c @@ -22,9 +22,6 @@ #include #include -libutil_hidden_proto(openpty) -libutil_hidden_proto(login_tty) - int forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp) { diff --git a/libutil/login.c b/libutil/login.c index 4007e4c7e..971997d4a 100644 --- a/libutil/login.c +++ b/libutil/login.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "internal/utmp.h" /* Write the given entry into utmp and wtmp. * Note: the match in utmp is done against ut_id field, @@ -11,7 +11,7 @@ */ void login(const struct utmp *entry) { - struct utmp copy; + struct UT copy; char tty_name[sizeof(copy.ut_line) + 6]; int fd; @@ -20,7 +20,7 @@ void login(const struct utmp *entry) // (if there is such a field) with the value USER_PROCESS, // and fills the field ut->ut_pid (if there is such a field) // with the process ID of the calling process. - copy = *entry; + copy = *((const struct UT *)(entry)); #if _HAVE_UT_TYPE - 0 copy.ut_type = USER_PROCESS; #endif diff --git a/libutil/login_tty.c b/libutil/login_tty.c index 3979adcec..366585834 100644 --- a/libutil/login_tty.c +++ b/libutil/login_tty.c @@ -36,7 +36,6 @@ #include #include -libutil_hidden_proto(login_tty) int login_tty(int fd) { (void) setsid(); diff --git a/libutil/logout.c b/libutil/logout.c index 45804552d..0181e23aa 100644 --- a/libutil/logout.c +++ b/libutil/logout.c @@ -18,14 +18,14 @@ #include #include -#include #include +#include "internal/utmp.h" int logout (const char *line) { - struct utmp tmp; - struct utmp *ut; + struct UT tmp; + struct UT *ut; int result = 0; /* if (utmpname (_PATH_UTMP) == -1) return 0; - why? diff --git a/libutil/logwtmp.c b/libutil/logwtmp.c index 6a53b5ff1..99b772fc4 100644 --- a/libutil/logwtmp.c +++ b/libutil/logwtmp.c @@ -9,13 +9,13 @@ #include #include #include -#include #include #include +#include "internal/utmp.h" void logwtmp(const char *line, const char *name, const char *host) { - struct utmp lutmp; + struct UT lutmp; memset(&lutmp, 0, sizeof(lutmp)); lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS; @@ -36,20 +36,3 @@ void logwtmp(const char *line, const char *name, const char *host) updwtmp(_PATH_WTMP, &lutmp); } - -#if 0 -/* This is enabled in uClibc/libc/misc/utmp/wtent.c */ -void updwtmp(const char *wtmp_file, const struct utmp *lutmp) -{ - int fd; - - fd = open(wtmp_file, O_APPEND | O_WRONLY); - if (fd >= 0) { - if (lockf(fd, F_LOCK, 0) == 0) { - write(fd, lutmp, sizeof(*lutmp)); - lockf(fd, F_ULOCK, 0); - close(fd); - } - } -} -#endif diff --git a/libutil/openpty.c b/libutil/openpty.c index bd8b8d9a4..848dc8d38 100644 --- a/libutil/openpty.c +++ b/libutil/openpty.c @@ -84,7 +84,6 @@ pts_name (int fd, char **pts, size_t buf_len) /* Create pseudo tty master slave pair and set terminal attributes according to TERMP and WINP. Return handles for both ends in AMASTER and ASLAVE, and return the name of the slave end in NAME. */ -libutil_hidden_proto(openpty) int openpty (int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) -- cgit v1.2.3