multiuser: Change all groups in setup_environment.

We need to change all groups, not just the primary group.
Otherwise, other groups will be left intact, which may
include groups the new user doesn't have permissions for.
This commit is contained in:
Augustin Cavalier
2025-07-02 17:20:01 -04:00
parent 27e99e3a64
commit e6de99eb01
+3
View File
@@ -202,6 +202,9 @@ setup_environment(struct passwd* passwd, bool preserveEnvironment, bool chngdir)
if (passwd->pw_gid && setgid(passwd->pw_gid) != 0)
return errno;
if (initgroups(passwd->pw_name, passwd->pw_gid) != 0)
return errno;
if (passwd->pw_uid && setuid(passwd->pw_uid) != 0)
return errno;