From 791efbf86f1e85adb7ba91f0201145fcb4b205a8 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 17 Jul 2025 05:37:50 -0500 Subject: [PATCH] setgid() should use gid not uid. (Spotted by ttiinn.) Only used by login and su outside of pending, so went unnoticed in the absence of mkroot tests running as root. --- lib/xwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xwrap.c b/lib/xwrap.c index aa036d4d..cc320af8 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -775,7 +775,7 @@ struct group *xgetgrnam(char *name) void xsetuser(struct passwd *pwd) { - if (initgroups(pwd->pw_name, pwd->pw_gid) || setgid(pwd->pw_uid) + if (initgroups(pwd->pw_name, pwd->pw_gid) || setgid(pwd->pw_gid) || setuid(pwd->pw_uid)) perror_exit("xsetuser '%s'", pwd->pw_name); } -- 2.39.5