From b4b919fe5e1fc1d346fa6315748d0e0709d02096 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Thu, 1 Dec 2016 09:52:11 +0100 Subject: login-utils: switch to utmpx.h Now the build will fail on many non-Linux systems because utmpx.h is available everywhere but we still use non-POSIX features. We'll fix this next commit. Signed-off-by: Ruediger Meier --- term-utils/write.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'term-utils/write.c') diff --git a/term-utils/write.c b/term-utils/write.c index 4f8f21eb5..2b05e89d9 100644 --- a/term-utils/write.c +++ b/term-utils/write.c @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include "c.h" #include "carefulputc.h" @@ -130,13 +130,13 @@ static int check_tty(const char *tty, int *tty_writeable, time_t *tty_atime, int */ static int check_utmp(const struct write_control *ctl) { - struct utmp *u; + struct utmpx *u; int res = 1; - utmpname(_PATH_UTMP); - setutent(); + utmpxname(_PATH_UTMP); + setutxent(); - while ((u = getutent())) { + while ((u = getutxent())) { if (strncmp(ctl->dst_login, u->ut_user, sizeof(u->ut_user)) == 0 && strncmp(ctl->dst_tty_name, u->ut_line, sizeof(u->ut_line)) == 0) { res = 0; @@ -144,7 +144,7 @@ static int check_utmp(const struct write_control *ctl) } } - endutent(); + endutxent(); return res; } @@ -161,15 +161,15 @@ static int check_utmp(const struct write_control *ctl) */ static void search_utmp(struct write_control *ctl) { - struct utmp *u; + struct utmpx *u; time_t best_atime = 0, tty_atime; int num_ttys = 0, valid_ttys = 0, tty_writeable = 0, user_is_me = 0; char path[sizeof(u->ut_line) + 6]; - utmpname(_PATH_UTMP); - setutent(); + utmpxname(_PATH_UTMP); + setutxent(); - while ((u = getutent())) { + while ((u = getutxent())) { if (strncmp(ctl->dst_login, u->ut_user, sizeof(u->ut_user)) != 0) continue; num_ttys++; @@ -197,7 +197,7 @@ static void search_utmp(struct write_control *ctl) } } - endutent(); + endutxent(); if (num_ttys == 0) errx(EXIT_FAILURE, _("%s is not logged in"), ctl->dst_login); if (valid_ttys == 0) { -- cgit v1.2.3-55-g7522