]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
configure.ac, contrib/, src/: Remove dead code
authorAlejandro Colomar <alx@kernel.org>
Mon, 24 Feb 2025 23:05:11 +0000 (00:05 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 27 May 2025 07:42:39 +0000 (09:42 +0200)
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 <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
configure.ac
contrib/adduser.c
src/chsh.c

index b079429a19c5c3fa889ae7166e1c1d749e46582f..c037579122105cbd87b9eda8b5525d5c7f2c489a 100644 (file)
@@ -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 \
index 8efec7aa3f583739325a88d9154c6c31fd8e91f1..bca3883e2e57462fc93ad04736c41fdea20ef53d 100644 (file)
 #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)
index ecd5749ab053807e728f39e9dc65396f2203c0ae..b45dca7143777ef5e122889c5af983ff7800deb6 100644 (file)
@@ -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 */