]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
configure.ac, lib/, src/: Use gid_t instead of GETGROUPS_T
authorAlejandro Colomar <alx@kernel.org>
Sat, 16 Nov 2024 12:08:12 +0000 (13:08 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Jan 2025 13:58:13 +0000 (07:58 -0600)
Autoconf's NEWS file says

*** AC_FUNC_GETGROUPS and AC_TYPE_GETGROUPS no longer run test programs.
  These macros were testing for OS bugs that we believe are at least
  twenty years in the past.  Most operating systems are now trusted to
  provide an accurate prototype for getgroups in unistd.h, and to
  implement it as specified in POSIX.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
configure.ac
lib/addgrps.c
src/newgrp.c

index 5281fa4f4c8fb03d04d0f2284e647bc840431f2f..6c19eedefdb205a249ba47fcb9b10347d8bfa75b 100644 (file)
@@ -66,7 +66,6 @@ AC_CHECK_MEMBERS([struct utmpx.ut_name,
                   struct utmpx.ut_xtime],,,[[#include <utmpx.h>]])
 
 dnl Checks for library functions.
-AC_TYPE_GETGROUPS
 AC_FUNC_UTIME_NULL
 AC_REPLACE_FUNCS(putgrent putpwent putspent)
 AC_REPLACE_FUNCS(sgetgrent sgetpwent sgetspent)
index 29cb1f232467841358a0ccaa02b5de0f3c7938cc..bfdaf2edcf654279ef0c571c104583613e2a7cbe 100644 (file)
@@ -17,6 +17,7 @@
 #include <grp.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
 
 #include "alloc/malloc.h"
 #include "alloc/reallocf.h"
@@ -33,9 +34,9 @@
 int
 add_groups(const char *list)
 {
-       GETGROUPS_T  *gids;
        char    *g, *p, *dup;
        FILE *shadow_logfd = log_get_logfd();
+       gid_t   *gids;
        size_t  n;
        ssize_t n0;
 
@@ -43,7 +44,7 @@ add_groups(const char *list)
        if (n0 == -1)
                return -1;
 
-       gids = MALLOC(n0, GETGROUPS_T);
+       gids = MALLOC(n0, gid_t);
        if (gids == NULL)
                return -1;
 
@@ -51,7 +52,7 @@ add_groups(const char *list)
        if (n0 == -1)
                goto free_gids;
 
-       gids = REALLOCF(gids, n0 + strchrscnt(list, ",:") + 1, GETGROUPS_T);
+       gids = REALLOCF(gids, n0 + strchrscnt(list, ",:") + 1, gid_t);
        if (gids == NULL)
                return -1;
 
index 7a4e1a8ada344381cb35eca0f504706321cd23f2..ee31b56b2c2009f3199f8a34483a6b94d7cf10d7 100644 (file)
@@ -14,7 +14,7 @@
 #include <grp.h>
 #include <pwd.h>
 #include <stdio.h>
-#include <assert.h>
+#include <sys/types.h>
 
 #include "agetpass.h"
 #include "alloc/x/xmalloc.h"
@@ -31,6 +31,8 @@
 #include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
+#include <assert.h>
+
 
 /*
  * Global variables
@@ -40,7 +42,7 @@ static const char *Prog;
 extern char **newenvp;
 
 static size_t  ngroups;
-static /*@null@*/ /*@only@*/GETGROUPS_T  *gids;
+static /*@null@*/ /*@only@*/gid_t  *gids;
 
 static bool is_newgrp;
 
@@ -560,7 +562,7 @@ int main (int argc, char **argv)
        if (ngroups == -1)
                goto fail_gg;
 
-       gids = XMALLOC(ngroups, GETGROUPS_T);
+       gids = XMALLOC(ngroups, gid_t);
 
        ngroups = getgroups(ngroups, gids);
        if (ngroups == -1) {
@@ -681,7 +683,7 @@ fail_gg:
         * If the group doesn't fit, I'll complain loudly and skip this
         * part.
         */
-       gids = XREALLOC(gids, ngroups + 1, GETGROUPS_T);
+       gids = XREALLOC(gids, ngroups + 1, gid_t);
 
        LSEARCH(&gid, gids, &ngroups);