From: Todd C. Miller Date: Fri, 26 Oct 2018 16:24:38 +0000 (-0600) Subject: Check the user's primary gid from the passwd file too. X-Git-Tag: SUDO_1_8_26^2~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3cb22b4674b000a2833d29da730933824b1539e;p=sudo Check the user's primary gid from the passwd file too. --- diff --git a/lib/util/regress/getgrouplist/getgrouplist_test.c b/lib/util/regress/getgrouplist/getgrouplist_test.c index 02edabdfa..a88d80b13 100644 --- a/lib/util/regress/getgrouplist/getgrouplist_test.c +++ b/lib/util/regress/getgrouplist/getgrouplist_test.c @@ -52,14 +52,16 @@ main(int argc, char *argv[]) char *username; int i, j, errors = 0, ntests = 0; int ngroups; + gid_t basegid; initprogname(argc > 0 ? argv[0] : "getgrouplist_test"); if ((pw = getpwuid(0)) == NULL) sudo_fatal_nodebug("getpwuid(0)"); + basegid = pw->pw_gid; if ((username = strdup(pw->pw_name)) == NULL) sudo_fatal_nodebug(NULL); - if (sudo_getgrouplist2(pw->pw_name, pw->pw_gid, &groups, &ngroups) == -1) + if (sudo_getgrouplist2(username, basegid, &groups, &ngroups) == -1) sudo_fatal_nodebug("sudo_getgroulist2"); for (i = 0; i < ngroups; i++) { @@ -73,6 +75,10 @@ main(int argc, char *argv[]) continue; } + /* Check user's primary gid from the passwd file. */ + if (grp->gr_gid == basegid) + continue; + /* Verify group membership. */ for (j = 0; grp->gr_mem[j] != NULL; j++) { if (strcmp(username, grp->gr_mem[j]) == 0) {