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:3be7b9d75a
("Remove traces of utmpx") Fixes:170b76cdd1
("Disable utmpx permanently") Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
f301a4ca19
commit
e762ab8b54
@ -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 \
|
AC_CHECK_FUNCS(arc4random_buf futimes \
|
||||||
getentropy getrandom getspnam getusershell \
|
getentropy getrandom getspnam getusershell \
|
||||||
getutent initgroups lckpwdf lutimes \
|
initgroups lckpwdf lutimes \
|
||||||
setgroups updwtmp updwtmpx innetgr \
|
setgroups updwtmp updwtmpx innetgr \
|
||||||
getspnam_r \
|
getspnam_r \
|
||||||
memset_explicit explicit_bzero)
|
memset_explicit explicit_bzero)
|
||||||
|
@ -66,8 +66,7 @@ libshadow_la_SOURCES = \
|
|||||||
shadowio.c \
|
shadowio.c \
|
||||||
shadowio.h \
|
shadowio.h \
|
||||||
shadowmem.c \
|
shadowmem.c \
|
||||||
spawn.c \
|
spawn.c
|
||||||
utent.c
|
|
||||||
|
|
||||||
if WITH_TCB
|
if WITH_TCB
|
||||||
libshadow_la_SOURCES += tcbfuncs.c tcbfuncs.h
|
libshadow_la_SOURCES += tcbfuncs.c tcbfuncs.h
|
||||||
|
70
lib/utent.c
70
lib/utent.c
@ -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
|
|
@ -28,7 +28,6 @@ lib/shadowio.c
|
|||||||
lib/shadowmem.c
|
lib/shadowmem.c
|
||||||
lib/spawn.c
|
lib/spawn.c
|
||||||
lib/tcbfuncs.c
|
lib/tcbfuncs.c
|
||||||
lib/utent.c
|
|
||||||
libmisc/addgrps.c
|
libmisc/addgrps.c
|
||||||
libmisc/age.c
|
libmisc/age.c
|
||||||
libmisc/audit_help.c
|
libmisc/audit_help.c
|
||||||
|
Loading…
Reference in New Issue
Block a user