From 9eac6eeaa3f27feb2e90a82fa74fd73fdf0da0b4 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 13 Jan 2002 18:29:23 +0000 Subject: [PATCH] If set_perms == set_perms_posix and the stay_setuid flag is not set, set all uids to 0 and use set_perms_fallback(). --- sudo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sudo.c b/sudo.c index 7249d535f..6313aed9b 100644 --- a/sudo.c +++ b/sudo.c @@ -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). -- 2.50.1