git: ff7252cdafbd - main - tools/regression/priv: Don't call setgroups() with the effective GID

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Wed, 17 Sep 2025 12:19:24 UTC
The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=ff7252cdafbd9dab104a5e7b33b8bb84117a8789

commit ff7252cdafbd9dab104a5e7b33b8bb84117a8789
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-08-29 17:00:07 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-09-17 12:16:08 +0000

    tools/regression/priv: Don't call setgroups() with the effective GID
    
    The 'setgroups(0, NULL);' stance works the same on all versions of
    FreeBSD, getting rid of all supplementary groups.  The replaced code
    would force the effective GID to also be a supplementary group.
    
    Fixes:          9da2fe96ff2e ("kern: fix setgroups(2) and getgroups(2) to match other platforms")
    MFC after:      5 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52289
---
 tools/regression/priv/main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/regression/priv/main.c b/tools/regression/priv/main.c
index dbcb5759f6b9..979e6ed65284 100644
--- a/tools/regression/priv/main.c
+++ b/tools/regression/priv/main.c
@@ -423,12 +423,10 @@ setup_file(const char *test, char *fpathp, uid_t uid, gid_t gid, mode_t mode)
 static void
 set_creds(const char *test, uid_t uid, gid_t gid)
 {
-	gid_t gids[1] = { gid };
-
 	if (setgid(gid) < 0)
 		err(-1, "test %s: setegid(%d)", test, gid);
-	if (setgroups(sizeof(gids)/sizeof(gid_t), gids) < 0)
-		err(-1, "test %s: setgroups(%d)", test, gid);
+	if (setgroups(0, NULL) < 0)
+		err(-1, "test %s: setgroups(NULL)", test);
 	if (setuid(uid) < 0)
 		err(-1, "test %s: seteuid(%d)", test, uid);
 }