If set_perms == set_perms_posix and the stay_setuid flag is not

set, set all uids to 0 and use set_perms_fallback().
This commit is contained in:
Todd C. Miller
2002-01-13 18:29:23 +00:00
parent 26f2a96558
commit 9eac6eeaa3

15
sudo.c
View File

@@ -255,6 +255,21 @@ main(argc, argv, envp)
/* Validate the user but don't search for pseudo-commands. */
validated = sudoers_lookup(pwflag);
/*
* If we have POSIX saved uids and the stay_setuid flag was not set,
* set the real, effective and saved uids to 0 and use set_perms_fallback()
* instead of set_perms_posix().
*/
#if defined(_SC_SAVED_IDS) && defined(_SC_VERSION)
if (!def_flag(I_STAY_SETUID) && set_perms == set_perms_posix) {
if (setuid(0)) {
perror("setuid(0)");
exit(1);
}
set_perms = set_perms_fallback;
}
#endif
/*
* Look up runas user passwd struct. If we are given a uid then
* there may be no corresponding passwd(5) entry (which is OK).