From e762ab8b54eab539952a136296be9a9bd6132444 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 7 Feb 2023 18:37:23 +0100 Subject: [PATCH] Assume getutent(3) exists (remove dead code) Recently, we removed support for 'struct utmpx'. We did it because utmp and utmpx are identical, and while POSIX specifies utmpx (and not utmp), GNU/Linux documentation seems to favor utmp. Also, this project defaulted to utmp, so changing to utmpx would be more dangerous than keeping old defaults, even if it's supposed to be the same. Now, I just found more code that didn't make much sense: lib/utent.c provides definitions for getutent(3) and friends in case the system doesn't provide them, but we don't provide prototypes for those definitions, so code using the functions would have never compiled. Let's just remove these definitions as dead code. Fixes: 3be7b9d75a6b ("Remove traces of utmpx") Fixes: 170b76cdd1a9 ("Disable utmpx permanently") Cc: Serge Hallyn Signed-off-by: Alejandro Colomar --- configure.ac | 2 +- lib/Makefile.am | 3 +-- lib/utent.c | 70 ------------------------------------------------- po/POTFILES.in | 1 - 4 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 lib/utent.c diff --git a/configure.ac b/configure.ac index c89acb8d..8e978cf5 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,7 @@ AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])]) AC_CHECK_FUNCS(arc4random_buf futimes \ getentropy getrandom getspnam getusershell \ - getutent initgroups lckpwdf lutimes \ + initgroups lckpwdf lutimes \ setgroups updwtmp updwtmpx innetgr \ getspnam_r \ memset_explicit explicit_bzero) diff --git a/lib/Makefile.am b/lib/Makefile.am index b677697a..5d76205c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -66,8 +66,7 @@ libshadow_la_SOURCES = \ shadowio.c \ shadowio.h \ shadowmem.c \ - spawn.c \ - utent.c + spawn.c if WITH_TCB libshadow_la_SOURCES += tcbfuncs.c tcbfuncs.h diff --git a/lib/utent.c b/lib/utent.c deleted file mode 100644 index 988201b2..00000000 --- a/lib/utent.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SPDX-FileCopyrightText: 1993 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2005 , Tomasz Kłoczko - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -#ifndef HAVE_GETUTENT - -#include "defines.h" -#include -#include -#include - -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - -static int utmp_fd = -1; -static struct utmp utmp_buf; - -/* - * setutent - open or rewind the utmp file - */ - -void setutent (void) -{ - if (utmp_fd == -1) - if ((utmp_fd = open (_UTMP_FILE, O_RDWR)) == -1) - utmp_fd = open (_UTMP_FILE, O_RDONLY); - - if (utmp_fd != -1) - lseek (utmp_fd, (off_t) 0L, SEEK_SET); -} - -/* - * endutent - close the utmp file - */ - -void endutent (void) -{ - if (utmp_fd != -1) - close (utmp_fd); - - utmp_fd = -1; -} - -/* - * getutent - get the next record from the utmp file - */ - -struct utmp *getutent (void) -{ - if (utmp_fd == -1) - setutent (); - - if (utmp_fd == -1) - return 0; - - if (read (utmp_fd, &utmp_buf, sizeof utmp_buf) != sizeof utmp_buf) - return 0; - - return &utmp_buf; -} -#else -extern int ISO_C_forbids_an_empty_translation_unit; -#endif diff --git a/po/POTFILES.in b/po/POTFILES.in index 61b79dbd..568d51be 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -28,7 +28,6 @@ lib/shadowio.c lib/shadowmem.c lib/spawn.c lib/tcbfuncs.c -lib/utent.c libmisc/addgrps.c libmisc/age.c libmisc/audit_help.c