mirror of https://github.com/omar-polo/gmid.git
when switching user also set the groups
This commit is contained in:
parent
b24c6fcc1c
commit
872a717687
7
gmid.c
7
gmid.c
|
@ -296,9 +296,10 @@ drop_priv(void)
|
|||
}
|
||||
|
||||
if (pw != NULL) {
|
||||
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1)
|
||||
fatal("setresuid(%d): %s", pw->pw_uid,
|
||||
strerror(errno));
|
||||
if (setgroups(1, &pw->pw_gid) == -1 ||
|
||||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1 ||
|
||||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1)
|
||||
fatal("cannot drop privileges");
|
||||
}
|
||||
|
||||
if (getuid() == 0)
|
||||
|
|
Loading…
Reference in New Issue