From: Todd C. Miller Date: Sat, 30 Dec 2000 03:59:40 +0000 (+0000) Subject: Don't try and build saved uid version of set_perms on systems w/o them. X-Git-Tag: SUDO_1_6_4~216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=572b4cf39aede0f6639d9e98a6300cea2ed712a7;p=sudo Don't try and build saved uid version of set_perms on systems w/o them. Rename set_perms_saved_uid() -> set_perms_posix() Make set_perms_setreuid simply be set_perms_fallback() and simply include the appropriate function at compile time (setreuid() vs. setuid()). --- diff --git a/set_perms.c b/set_perms.c index 05ab947b5..525e0d0e6 100644 --- a/set_perms.c +++ b/set_perms.c @@ -69,13 +69,14 @@ static const char rcsid[] = "$Sudo$"; static void runas_setup __P((void)); static void fatal __P((char *)); +#if defined(_SC_SAVED_IDS) && defined(_SC_VERSION) /* * Set real and effective uids and gids based on perm. * Since we have POSIX saved IDs we can get away with just * toggling the effective uid/gid unless we are headed for an exec(). */ void -set_perms_saved_uid(perm, sudo_mode) +set_perms_posix(perm, sudo_mode) int perm; int sudo_mode; { @@ -132,14 +133,16 @@ set_perms_saved_uid(perm, sudo_mode) break; } } +#endif /* _SC_SAVED_IDS && _SC_VERSION */ +#ifdef HAVE_SETREUID /* * Set real and effective uids and gids based on perm. * We always retain a real or effective uid of 0 unless * we are headed for an exec(). */ void -set_perms_setreuid(perm, sudo_mode) +set_perms_fallback(perm, sudo_mode) int perm; int sudo_mode; { @@ -199,7 +202,8 @@ set_perms_setreuid(perm, sudo_mode) } } -#ifndef HAVE_SETREUID +#else + /* * Set real and effective uids and gids based on perm. * NOTE: does not support the "stay_setuid" option. diff --git a/sudo.c b/sudo.c index c464d1112..5b2447b70 100644 --- a/sudo.c +++ b/sudo.c @@ -856,14 +856,10 @@ initial_setup() /* Set set_perms pointer to the correct function */ #if defined(_SC_SAVED_IDS) && defined(_SC_VERSION) if (sysconf(_SC_SAVED_IDS) == 1 && sysconf(_SC_VERSION) >= 199009) - set_perms = set_perms_saved_uid; + set_perms = set_perms_posix; else #endif -#ifdef HAVE_SETREUID - set_perms = set_perms_setreuid; -#else - set_perms = set_perms_fallback; -#endif + set_perms = set_perms_fallback; } #ifdef HAVE_LOGIN_CAP_H diff --git a/sudo.h b/sudo.h index 330c99b51..f34274b04 100644 --- a/sudo.h +++ b/sudo.h @@ -199,8 +199,7 @@ int find_path __P((char *, char **, char *)); void check_user __P((void)); void verify_user __P((struct passwd *, char *)); int sudoers_lookup __P((int)); -void set_perms_saved_uid __P((int, int)); -void set_perms_setreuid __P((int, int)); +void set_perms_posix __P((int, int)); void set_perms_fallback __P((int, int)); void remove_timestamp __P((int)); int check_secureware __P((char *));