]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Rename variables
authorAlejandro Colomar <alx@kernel.org>
Fri, 15 Nov 2024 14:24:05 +0000 (15:24 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Jan 2025 13:58:13 +0000 (07:58 -0600)
Since 'list' is used for a comma/colon-separated-value list, grouplist
is incorrect and inconsistent.  grouplist is not a list, but an array.
Use the more common convention of just using plural.  Also, use 'gids'
to distinguish it from other group representations.

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

index 603197543ef9a9de19f5e3d6672be639f95a6c7f..2fb4a3166f597bf92d5a4786ff646fcad7a5802c 100644 (file)
@@ -33,7 +33,7 @@
 int
 add_groups(const char *list)
 {
-       GETGROUPS_T *grouplist;
+       GETGROUPS_T  *gids;
        char *g, *p;
        char buf[1024];
        FILE *shadow_logfd = log_get_logfd();
@@ -50,16 +50,16 @@ add_groups(const char *list)
        if (n0 == -1)
                return -1;
 
-       grouplist = MALLOC(n0, GETGROUPS_T);
-       if (grouplist == NULL)
+       gids = MALLOC(n0, GETGROUPS_T);
+       if (gids == NULL)
                return -1;
 
-       n0 = getgroups(n0, grouplist);
+       n0 = getgroups(n0, gids);
        if (n0 == -1)
                goto free_gids;
 
-       grouplist = REALLOCF(grouplist, n0 + strchrscnt(list, ",:") + 1, GETGROUPS_T);
-       if (grouplist == NULL)
+       gids = REALLOCF(gids, n0 + strchrscnt(list, ",:") + 1, GETGROUPS_T);
+       if (gids == NULL)
                return -1;
 
        n = n0;
@@ -73,19 +73,19 @@ add_groups(const char *list)
                        continue;
                }
 
-               LSEARCH(&grp->gr_gid, grouplist, &n);
+               LSEARCH(&grp->gr_gid, gids, &n);
        }
 
-       if (setgroups(n, grouplist) == -1) {
+       if (setgroups(n, gids) == -1) {
                fprintf(shadow_logfd, "setgroups: %s\n", strerror(errno));
                goto free_gids;
        }
 
-       free (grouplist);
+       free(gids);
        return 0;
 
 free_gids:
-       free(grouplist);
+       free(gids);
        return -1;
 }
 #else                          /* !USE_PAM */
index ada65fb8121e48f9192a654fb51588bf9591fcc8..7a4e1a8ada344381cb35eca0f504706321cd23f2 100644 (file)
@@ -40,7 +40,7 @@ static const char *Prog;
 extern char **newenvp;
 
 static size_t  ngroups;
-static /*@null@*/ /*@only@*/GETGROUPS_T *grouplist;
+static /*@null@*/ /*@only@*/GETGROUPS_T  *gids;
 
 static bool is_newgrp;
 
@@ -560,9 +560,9 @@ int main (int argc, char **argv)
        if (ngroups == -1)
                goto fail_gg;
 
-       grouplist = XMALLOC(ngroups, GETGROUPS_T);
+       gids = XMALLOC(ngroups, GETGROUPS_T);
 
-       ngroups = getgroups(ngroups, grouplist);
+       ngroups = getgroups(ngroups, gids);
        if (ngroups == -1) {
 fail_gg:
                perror("getgroups");
@@ -629,7 +629,7 @@ fail_gg:
         * database. However getgroups() will return the group. So
         * if she is listed there already it is ok to grant membership.
         */
-       is_member = (LFIND(&grp->gr_gid, grouplist, ngroups) != NULL);
+       is_member = (LFIND(&grp->gr_gid, gids, ngroups) != NULL);
 
        /*
         * For split groups (due to limitations of NIS), check all
@@ -681,11 +681,11 @@ fail_gg:
         * If the group doesn't fit, I'll complain loudly and skip this
         * part.
         */
-       grouplist = XREALLOC(grouplist, ngroups + 1, GETGROUPS_T);
+       gids = XREALLOC(gids, ngroups + 1, GETGROUPS_T);
 
-       LSEARCH(&gid, grouplist, &ngroups);
+       LSEARCH(&gid, gids, &ngroups);
 
-       if (setgroups(ngroups, grouplist) == -1)
+       if (setgroups(ngroups, gids) == -1)
                perror("setgroups");
 
        /*