From: Alejandro Colomar Date: Fri, 15 Nov 2024 14:24:05 +0000 (+0100) Subject: lib/, src/: Rename variables X-Git-Tag: 4.17.3~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7be3b4c2a8f93272e23499b529aba9a19f831649;p=thirdparty%2Fshadow.git lib/, src/: Rename variables 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 Signed-off-by: Alejandro Colomar --- diff --git a/lib/addgrps.c b/lib/addgrps.c index 603197543..2fb4a3166 100644 --- a/lib/addgrps.c +++ b/lib/addgrps.c @@ -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 */ diff --git a/src/newgrp.c b/src/newgrp.c index ada65fb81..7a4e1a8ad 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -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"); /*