From: Iker Pedrosa Date: Mon, 25 Aug 2025 07:58:51 +0000 (+0200) Subject: Remove unused `logoutd` utility X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eec97ce4c5a9fa57c387affeedd7a40c435b2b1f;p=thirdparty%2Fshadow.git Remove unused `logoutd` utility Link: Signed-off-by: Iker Pedrosa --- diff --git a/man/Makefile.am b/man/Makefile.am index f34ed7acf..315bb0c27 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -27,7 +27,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ @@ -95,7 +94,6 @@ man_XMANS = \ login.1.xml \ login.access.5.xml \ login.defs.5.xml \ - logoutd.8.xml \ newgidmap.1.xml \ newgrp.1.xml \ newuidmap.1.xml \ diff --git a/man/cs/Makefile.am b/man/cs/Makefile.am index 45aec38f9..ed6d4ae53 100644 --- a/man/cs/Makefile.am +++ b/man/cs/Makefile.am @@ -22,6 +22,5 @@ man_MANS += man8/lastlog.8 endif EXTRA_DIST = $(man_MANS) \ - man8/groupmems.8 \ - man8/logoutd.8 + man8/groupmems.8 diff --git a/man/da/Makefile.am b/man/da/Makefile.am index c61b787d0..0c85972b2 100644 --- a/man/da/Makefile.am +++ b/man/da/Makefile.am @@ -6,7 +6,6 @@ man_MANS = \ man1/chfn.1 \ man8/groupdel.8 \ man5/gshadow.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/nologin.8 \ man1/sg.1 \ diff --git a/man/de/Makefile.am b/man/de/Makefile.am index d3a6d6c1c..49505ef94 100644 --- a/man/de/Makefile.am +++ b/man/de/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/man/fr/Makefile.am b/man/fr/Makefile.am index 2365e23b7..48fcc40fa 100644 --- a/man/fr/Makefile.am +++ b/man/fr/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/man/it/Makefile.am b/man/it/Makefile.am index 736576c99..f833713b7 100644 --- a/man/it/Makefile.am +++ b/man/it/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/man/ja/Makefile.am b/man/ja/Makefile.am index b759726c6..9f3bbe4ae 100644 --- a/man/ja/Makefile.am +++ b/man/ja/Makefile.am @@ -18,7 +18,6 @@ man_MANS = \ man8/grpunconv.8 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man1/passwd.1 \ diff --git a/man/login.defs.5.xml b/man/login.defs.5.xml index 7263395cf..239154f02 100644 --- a/man/login.defs.5.xml +++ b/man/login.defs.5.xml @@ -379,7 +379,6 @@ - newgrp / sg diff --git a/man/logoutd.8.xml b/man/logoutd.8.xml deleted file mode 100644 index d3f96e4b0..000000000 --- a/man/logoutd.8.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - -]> - - - - - Julianne Frances - Haugh - Creation, 1991 - - - Thomas - Kłoczko - kloczek@pld.org.pl - shadow-utils maintainer, 2000 - 2007 - - - Nicolas - François - nicolas.francois@centraliens.net - shadow-utils maintainer, 2007 - now - - - - logoutd - 8 - System Management Commands - shadow-utils - &SHADOW_UTILS_VERSION; - - - logoutd - enforce login time restrictions - - - - - logoutd - - - - - DESCRIPTION - - logoutd enforces the login time and port - restrictions specified in /etc/porttime. - logoutd should be started from - /etc/rc. The /var/run/utmp - file is scanned periodically and each user name is checked to see if - the named user is permitted on the named port at the current time. - Any login session which is violating the restrictions in - /etc/porttime is terminated. - - - - - FILES - - - /etc/porttime - - File containing port access. - - - - /var/run/utmp - - List of current login sessions. - - - - - diff --git a/man/pl/Makefile.am b/man/pl/Makefile.am index 2a015f3ae..c691231da 100644 --- a/man/pl/Makefile.am +++ b/man/pl/Makefile.am @@ -14,7 +14,6 @@ man_MANS = \ man8/groupmems.8 \ man8/groupmod.8 \ man8/grpck.8 \ - man8/logoutd.8 \ man1/newgrp.1 \ man1/sg.1 \ man3/shadow.3 \ diff --git a/man/po/XMLFILES b/man/po/XMLFILES index bf08e6da0..f3a8e2f50 100644 --- a/man/po/XMLFILES +++ b/man/po/XMLFILES @@ -20,7 +20,6 @@ XMLFILES = \ $(top_srcdir)/man/login.1.xml \ $(top_srcdir)/man/login.access.5.xml \ $(top_srcdir)/man/login.defs.5.xml \ - $(top_srcdir)/man/logoutd.8.xml \ $(top_srcdir)/man/newgrp.1.xml \ $(top_srcdir)/man/newusers.8.xml \ $(top_srcdir)/man/nologin.8.xml \ diff --git a/man/ru/Makefile.am b/man/ru/Makefile.am index 845a603e7..4ed352858 100644 --- a/man/ru/Makefile.am +++ b/man/ru/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/man/sv/Makefile.am b/man/sv/Makefile.am index 1918af729..929954859 100644 --- a/man/sv/Makefile.am +++ b/man/sv/Makefile.am @@ -14,7 +14,6 @@ man_MANS = \ man8/groupmod.8 \ man8/grpck.8 \ man5/gshadow.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/nologin.8 \ man1/passwd.1 \ diff --git a/man/uk/Makefile.am b/man/uk/Makefile.am index a0f106d66..b23da85c7 100644 --- a/man/uk/Makefile.am +++ b/man/uk/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/man/zh_CN/Makefile.am b/man/zh_CN/Makefile.am index 59d1072dc..937a620c6 100644 --- a/man/zh_CN/Makefile.am +++ b/man/zh_CN/Makefile.am @@ -22,7 +22,6 @@ man_MANS = \ man5/gshadow.5 \ man1/login.1 \ man5/login.defs.5 \ - man8/logoutd.8 \ man1/newgrp.1 \ man8/newusers.8 \ man8/nologin.8 \ diff --git a/po/POTFILES.in b/po/POTFILES.in index 8d8ae28a4..0dae69660 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -92,7 +92,6 @@ src/grpunconv.c src/lastlog.c src/login.c src/login_nopam.c -src/logoutd.c src/newgidmap.c src/newgrp.c src/newuidmap.c diff --git a/src/.gitignore b/src/.gitignore index 9ae06b424..2dc79ad5f 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -15,7 +15,6 @@ /grpunconv /lastlog /login -/logoutd /newgrp /newgidmap /newuidmap diff --git a/src/Makefile.am b/src/Makefile.am index ed0802cd1..c387ef8a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,7 +48,6 @@ usbin_PROGRAMS = \ grpck \ grpconv \ grpunconv \ - logoutd \ newusers \ pwck \ pwconv \ diff --git a/src/logoutd.c b/src/logoutd.c deleted file mode 100644 index c87b75cbd..000000000 --- a/src/logoutd.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * SPDX-FileCopyrightText: 1991 - 1993, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#ident "$Id$" - -#include -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "prototypes.h" -#include "shadowlog.h" -#include "sizeof.h" -#include "string/strcmp/strneq.h" -#include "string/strcpy/strncat.h" -#include "string/strdup/strndupa.h" - - -/* - * Global variables - */ -static const char Prog[] = "logoutd"; - -#ifndef DEFAULT_HUP_MESG -#define DEFAULT_HUP_MESG _("login time exceeded\n\n") -#endif - -#ifndef HUP_MESG_FILE -#define HUP_MESG_FILE "/etc/logoutd.mesg" -#endif - - -/* local function prototypes */ -static int check_login (const struct utmpx *ut); -static void send_mesg_to_tty (int tty_fd); - - -/* - * check_login - check if user (struct utmpx) allowed to stay logged in - */ -static int -check_login(const struct utmpx *ut) -{ - char *user; - char *line; - time_t now; - - user = strndupa_a(ut->ut_user); - line = strndupa_a(ut->ut_line); - - now = time(NULL); - - return isttytime(user, line, now); -} - - -static void send_mesg_to_tty (int tty_fd) -{ - TERMIO oldt, newt; - FILE *mesg_file, *tty_file; - bool is_tty; - - tty_file = fdopen (tty_fd, "w"); - if (NULL == tty_file) { - return; - } - - is_tty = (GTTY (tty_fd, &oldt) == 0); - if (is_tty) { - /* Suggested by Ivan Nejgebauar : - set OPOST before writing the message. */ - newt = oldt; - newt.c_oflag |= OPOST; - STTY (tty_fd, &newt); - } - - mesg_file = fopen (HUP_MESG_FILE, "r"); - if (NULL != mesg_file) { - int c; - while ((c = getc (mesg_file)) != EOF) { - if (c == '\n') { - putc ('\r', tty_file); - } - putc (c, tty_file); - } - fclose (mesg_file); - } else { - fputs (DEFAULT_HUP_MESG, tty_file); - } - fflush (tty_file); - fclose (tty_file); - - if (is_tty) { - STTY (tty_fd, &oldt); - } -} - - -/* - * logoutd - logout daemon to enforce /etc/porttime file policy - * - * logoutd is started at system boot time and enforces the login - * time and port restrictions specified in /etc/porttime. The - * utmp file is periodically scanned and offending users are logged - * off from the system. - */ -int -main(int argc, char *[]) -{ - pid_t pid; - - if (1 != argc) { - (void) fputs (_("Usage: logoutd\n"), stderr); - } - - (void) setlocale (LC_ALL, ""); - (void) bindtextdomain (PACKAGE, LOCALEDIR); - (void) textdomain (PACKAGE); - -#ifndef DEBUG - for (int i = 0; close(i) == 0; i++); - - setpgrp (); - - /* - * Put this process in the background. - */ - pid = fork (); - if (pid > 0) { - /* parent */ - exit (EXIT_SUCCESS); - } else if (pid < 0) { - /* error */ - perror ("fork"); - exit (EXIT_FAILURE); - } -#endif /* !DEBUG */ - - /* - * Start syslogging everything - */ - log_set_progname(Prog); - log_set_logfd(stderr); - - OPENLOG (Prog); - - /* - * Scan the utmp file once per minute looking for users that - * are not supposed to still be logged in. - */ - while (true) { - struct utmpx *ut; - - /* - * Attempt to re-open the utmp file. The file is only - * open while it is being used. - */ - setutxent(); - - /* - * Read all of the entries in the utmp file. The entries - * for login sessions will be checked to see if the user - * is permitted to be signed on at this time. - */ - while (NULL != (ut = getutxent())) { - int tty_fd; - char tty_name[sizeof(ut->ut_line) + 6]; // /dev/ + NUL - - if (ut->ut_type != USER_PROCESS) { - continue; - } - if (strneq_a(ut->ut_user, "")) - continue; - - if (check_login (ut)) { - continue; - } - - /* - * Put the rest of this in a child process. This - * keeps the scan from waiting on other ports to die. - */ - - pid = fork (); - if (pid > 0) { - /* parent */ - continue; - } else if (pid < 0) { - /* failed - give up until the next scan */ - break; - } - /* child */ - - if (strncmp(ut->ut_line, "/dev/", 5) != 0) - strcpy(tty_name, "/dev/"); - else - strcpy(tty_name, ""); - - strncat_a(tty_name, ut->ut_line); -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - tty_fd = - open (tty_name, O_WRONLY | O_NDELAY | O_NOCTTY); - if (tty_fd != -1) { - send_mesg_to_tty (tty_fd); - close (tty_fd); - sleep (10); - } - - if (ut->ut_pid > 1) { - kill (-ut->ut_pid, SIGHUP); - sleep (10); - kill (-ut->ut_pid, SIGKILL); - } - - SYSLOG ((LOG_NOTICE, - "logged off user '%s' on '%s'", - strndupa_a(ut->ut_user), - tty_name)); - - /* - * This child has done all it can, drop dead. - */ - exit (EXIT_SUCCESS); - } - - endutxent(); - -#ifndef DEBUG - sleep (60); -#endif - /* - * Reap any dead babies ... - */ - while (wait(NULL) != -1); - } - - return EXIT_FAILURE; -} -