int
add_groups(const char *list)
{
- GETGROUPS_T *grouplist;
+ GETGROUPS_T *gids;
char *g, *p;
char buf[1024];
FILE *shadow_logfd = log_get_logfd();
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;
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 */
extern char **newenvp;
static size_t ngroups;
-static /*@null@*/ /*@only@*/GETGROUPS_T *grouplist;
+static /*@null@*/ /*@only@*/GETGROUPS_T *gids;
static bool is_newgrp;
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");
* 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
* 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");
/*