From: Alejandro Colomar Date: Mon, 24 Feb 2025 23:05:11 +0000 (+0100) Subject: configure.ac, contrib/, src/: Remove dead code X-Git-Tag: 4.18.0-rc1~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0054a7253682bca9e1710f496e2a3b6cc05a1519;p=thirdparty%2Fshadow.git configure.ac, contrib/, src/: Remove dead code Both glibc and musl provide getusershell(3). It's an API from 4.3BSD, according to the manual page, so let's assume it exists everywhere that we would care, even if it's not in POSIX. Reported-by: Chris Hofstaedtler Signed-off-by: Alejandro Colomar --- diff --git a/configure.ac b/configure.ac index b079429a1..c03757912 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ dnl shadow now uses the libc's shadow implementation AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])]) AC_CHECK_FUNCS(arc4random_buf futimes \ - getentropy getrandom getusershell \ + getentropy getrandom \ lckpwdf lutimes \ updwtmpx innetgr \ getspnam_r \ diff --git a/contrib/adduser.c b/contrib/adduser.c index 8efec7aa3..bca3883e2 100644 --- a/contrib/adduser.c +++ b/contrib/adduser.c @@ -128,7 +128,6 @@ #define EXPIRE_VALS_SET /* If defined, 'normal' users can't change * password expiry values (if running suid root) */ -#define HAVE_GETUSERSHELL /* FIXME: Isn't this defined in config.h too? */ #define LOGGING /* If we want to log various things to syslog */ #define MAX_USRNAME 8 /* Longer usernames seem to work on my system.... * But they're probably a poor idea */ @@ -315,13 +314,13 @@ main (void) { char *sh; int ok = 0; -#ifdef HAVE_GETUSERSHELL + setusershell (); while ((sh = getusershell ()) != NULL) if (streq(shell, sh)) ok = 1; endusershell (); -#endif + if (!ok) { if (getuid () == 0) diff --git a/src/chsh.c b/src/chsh.c index ecd5749ab..b45dca714 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -196,9 +196,8 @@ static bool shell_is_listed (const char *sh) static bool shell_is_listed (const char *sh) { bool found = false; - -#ifdef HAVE_GETUSERSHELL char *cp; + setusershell (); while ((cp = getusershell ())) { if (streq(cp, sh)) { @@ -207,30 +206,7 @@ static bool shell_is_listed (const char *sh) } } endusershell (); -#else - char *buf = NULL; - FILE *fp; - size_t n = 0; - - fp = fopen (SHELLS_FILE, "r"); - if (NULL == fp) { - return false; - } - while (getline (&buf, &n, fp) != -1) { - if (buf[0] != '/') { - continue; - } - - if (streq(buf, sh)) { - found = true; - break; - } - } - - free(buf); - fclose (fp); -#endif return found; } #endif /* with HAVE_VENDORDIR */