]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Assume getutent(3) exists (remove dead code)
authorAlejandro Colomar <alx@kernel.org>
Tue, 7 Feb 2023 17:37:23 +0000 (18:37 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 8 Feb 2023 16:21:34 +0000 (17:21 +0100)
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 <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
configure.ac
lib/Makefile.am
lib/utent.c [deleted file]
po/POTFILES.in

index c89acb8de69a245d76f391f85f5a8fa2f6867b04..8e978cf5dfccef9719e552baac261fafc2dd4ca6 100644 (file)
@@ -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)
index b677697a2688824ca82556d6f92772cb6611666f..5d76205cff8fb7beb52b5c23656c55c0ed431c14 100644 (file)
@@ -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 (file)
index 988201b..0000000
+++ /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 <config.h>
-
-#ifndef        HAVE_GETUTENT
-
-#include "defines.h"
-#include <stdio.h>
-#include <fcntl.h>
-#include <utmp.h>
-
-#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
index 61b79dbde7369d7328aae9b53a6c81dfdfc4daef..568d51bece49db49750f76eb5b7891c117df7ba7 100644 (file)
@@ -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