]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Remove HAVE_GETGROUPS ifdefs 479/head
authorAlejandro Colomar <alx.manpages@gmail.com>
Mon, 27 Dec 2021 19:50:06 +0000 (20:50 +0100)
committerAlejandro Colomar <alx.manpages@gmail.com>
Mon, 27 Dec 2021 20:17:50 +0000 (21:17 +0100)
getgroups(2) has been in POSIX since POSIX.1-2001.  It is also in
in SVr4 and in 4.3BSD (see getgroups(2) and getgroups(3p)).
We can assume that this function is always available.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
configure.ac
src/groups.c
src/id.c

index a94e897fa691a25f6809eee26dd793238c301197..fa4bc1fcc614ab1a24b412966776f4582071ba37 100644 (file)
@@ -51,7 +51,7 @@ AC_CHECK_HEADERS(crypt.h errno.h fcntl.h limits.h unistd.h sys/time.h utmp.h \
 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 l64a fchmod fchown fsync futimes getgroups \
+AC_CHECK_FUNCS(arc4random_buf l64a fchmod fchown fsync futimes \
        gethostname getentropy getrandom getspnam gettimeofday getusershell \
        getutent initgroups lchown lckpwdf lstat lutimes memcpy memset \
        setgroups sigaction strchr updwtmp updwtmpx innetgr getpwnam_r \
index 70e3fcb23546c5182dbd0728480d40e608b75489..540e26dcd56a7878e5cd7658eb82ff7f1af28900 100644 (file)
@@ -107,18 +107,12 @@ static void print_groups (const char *member)
  */
 int main (int argc, char **argv)
 {
-#ifdef HAVE_GETGROUPS
        long sys_ngroups;
        GETGROUPS_T *groups;
-#else
-       char *logname;
-       char *getlogin ();
-#endif
 
-#ifdef HAVE_GETGROUPS
        sys_ngroups = sysconf (_SC_NGROUPS_MAX);
        groups = (GETGROUPS_T *) malloc (sizeof (GETGROUPS_T) * sys_ngroups);
-#endif
+
        (void) setlocale (LC_ALL, "");
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
@@ -137,7 +131,6 @@ int main (int argc, char **argv)
                 * current user.
                 */
 
-#ifdef HAVE_GETGROUPS
                int i;
                int pri_grp; /* TODO: should be GETGROUPS_T */
                /*
@@ -196,18 +189,6 @@ int main (int argc, char **argv)
                        }
                }
                (void) putchar ('\n');
-#else
-               /*
-                * This system does not have the getgroups() system call, so
-                * I must check the groups file directly.
-                */
-               logname = getlogin ();
-               if (NULL != logname) {
-                       print_groups (logname);
-               } else {
-                       exit (EXIT_FAILURE);
-               }
-#endif
        } else {
 
                /*
index 4462ae098438e016be25002459f9739e49b00251..a135e1a65d39c46cccc7e16720ac88dfda73e1cf 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -52,11 +52,7 @@ static void usage (void);
 
 static void usage (void)
 {
-#ifdef HAVE_GETGROUPS
        (void) fputs (_("Usage: id [-a]\n"), stderr);
-#else
-       (void) fputs (_("Usage: id\n"), stderr);
-#endif
        exit (EXIT_FAILURE);
 }
 
@@ -73,11 +69,9 @@ static void usage (void)
  * gid_t for everything. Some systems have a small and fixed NGROUPS,
  * usually about 16 or 32. Others use bigger values.
  */
-#ifdef HAVE_GETGROUPS
        GETGROUPS_T *groups;
        int ngroups;
        bool aflg = 0;
-#endif
        struct passwd *pw;
        struct group *gr;
 
@@ -92,8 +86,8 @@ static void usage (void)
         * work if the system library is recompiled.
         */
        sys_ngroups = sysconf (_SC_NGROUPS_MAX);
-#ifdef HAVE_GETGROUPS
        groups = (GETGROUPS_T *) malloc (sizeof (GETGROUPS_T) * sys_ngroups);
+
        /*
         * See if the -a flag has been given to print out the concurrent
         * group set.
@@ -106,11 +100,6 @@ static void usage (void)
                        aflg = true;
                }
        }
-#else
-       if (argc > 1) {
-               usage ();
-       }
-#endif
 
        ruid = getuid ();
        euid = geteuid ();
@@ -161,7 +150,7 @@ static void usage (void)
                        (void) printf (" EGID=%lu", (unsigned long) egid);
                }
        }
-#ifdef HAVE_GETGROUPS
+
        /*
         * Print out the concurrent group set if the user has requested it.
         * The group numbers will be printed followed by their names.
@@ -195,7 +184,6 @@ static void usage (void)
                }
        }
        free (groups);
-#endif
 
        /*
         * Finish off the line.