when switching user also set the groups

This commit is contained in:
Omar Polo 2022-11-27 10:05:13 +00:00
parent b24c6fcc1c
commit 872a717687
1 changed files with 4 additions and 3 deletions

7
gmid.c
View File

@ -296,9 +296,10 @@ drop_priv(void)
} }
if (pw != NULL) { if (pw != NULL) {
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) if (setgroups(1, &pw->pw_gid) == -1 ||
fatal("setresuid(%d): %s", pw->pw_uid, setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1 ||
strerror(errno)); setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1)
fatal("cannot drop privileges");
} }
if (getuid() == 0) if (getuid() == 0)