mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
do an initgroups() before running a command, unless the target user
is root.
This commit is contained in:
14
sudo.c
14
sudo.c
@@ -936,6 +936,20 @@ void set_perms(perm, sudo_mode)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize group vector only if
|
||||
* we are going to be a non-root user.
|
||||
*/
|
||||
if (strcmp(runas_user, "root") != 0 &&
|
||||
initgroups(runas_user, pw_ent->pw_gid)
|
||||
== -1) {
|
||||
(void) fprintf(stderr,
|
||||
"%s: cannot set group vector ",
|
||||
Argv[0]);
|
||||
perror("");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setuid(pw_ent->pw_uid)) {
|
||||
(void) fprintf(stderr,
|
||||
"%s: cannot set uid to %d: ",
|
||||
|
Reference in New Issue
Block a user