user_in_group: the user's group vector already includes the primary group.
There's no need to look up the name of user's primary group (pw_gid), we always include the primary group ID in the group vector.
This commit is contained in:
@@ -1177,21 +1177,13 @@ user_in_group(const struct passwd *pw, const char *group)
|
||||
else
|
||||
compare = strcmp;
|
||||
|
||||
/* Check the supplementary group vector. */
|
||||
/* Check the user's group vector, which includes the primary group. */
|
||||
for (i = 0; i < grlist->ngroups; i++) {
|
||||
if (compare(group, grlist->groups[i]) == 0) {
|
||||
matched = true;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check against user's primary (passwd file) group. */
|
||||
if ((grp = sudo_getgrgid(pw->pw_gid)) != NULL) {
|
||||
if (compare(group, grp->gr_name) == 0) {
|
||||
matched = true;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
Reference in New Issue
Block a user