2
0
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:
Todd C. Miller
1998-01-23 00:28:00 +00:00
parent b51df9a118
commit 7d5c340f98

14
sudo.c
View File

@@ -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: ",