diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2015-03-25 23:59:45 +0100 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2015-03-25 23:59:45 +0100 |
commit | 6ff9c31abc14f207265ab214370982ecb3bfe428 (patch) | |
tree | afdaf5624e71c939c39abe8ef3aba5980aa4d911 /libutil | |
parent | 2b33716c08cc506e57115e34b5fe11d8d5477398 (diff) |
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 <rep.dot.nop@gmail.com>
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/forkpty.c | 3 | ||||
-rw-r--r-- | libutil/login.c | 6 | ||||
-rw-r--r-- | libutil/login_tty.c | 1 | ||||
-rw-r--r-- | libutil/logout.c | 6 | ||||
-rw-r--r-- | libutil/logwtmp.c | 21 | ||||
-rw-r--r-- | libutil/openpty.c | 1 |
6 files changed, 8 insertions, 30 deletions
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 <utmp.h> #include <pty.h> -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 <string.h> #include <unistd.h> #include <stdlib.h> -#include <utmp.h> +#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 <fcntl.h> #include <utmp.h> -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 <errno.h> #include <string.h> -#include <utmp.h> #include <sys/time.h> +#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 <sys/time.h> #include <time.h> #include <unistd.h> -#include <utmp.h> #include <fcntl.h> #include <sys/file.h> +#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) |