2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-04 00:05:11 +00:00

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()).
This commit is contained in:
Todd C. Miller
2000-12-30 03:59:40 +00:00
parent 9318379d83
commit 572b4cf39a
3 changed files with 10 additions and 11 deletions

View File

@@ -69,13 +69,14 @@ static const char rcsid[] = "$Sudo$";
static void runas_setup __P((void)); static void runas_setup __P((void));
static void fatal __P((char *)); static void fatal __P((char *));
#if defined(_SC_SAVED_IDS) && defined(_SC_VERSION)
/* /*
* Set real and effective uids and gids based on perm. * Set real and effective uids and gids based on perm.
* Since we have POSIX saved IDs we can get away with just * Since we have POSIX saved IDs we can get away with just
* toggling the effective uid/gid unless we are headed for an exec(). * toggling the effective uid/gid unless we are headed for an exec().
*/ */
void void
set_perms_saved_uid(perm, sudo_mode) set_perms_posix(perm, sudo_mode)
int perm; int perm;
int sudo_mode; int sudo_mode;
{ {
@@ -132,14 +133,16 @@ set_perms_saved_uid(perm, sudo_mode)
break; break;
} }
} }
#endif /* _SC_SAVED_IDS && _SC_VERSION */
#ifdef HAVE_SETREUID
/* /*
* Set real and effective uids and gids based on perm. * Set real and effective uids and gids based on perm.
* We always retain a real or effective uid of 0 unless * We always retain a real or effective uid of 0 unless
* we are headed for an exec(). * we are headed for an exec().
*/ */
void void
set_perms_setreuid(perm, sudo_mode) set_perms_fallback(perm, sudo_mode)
int perm; int perm;
int sudo_mode; 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. * Set real and effective uids and gids based on perm.
* NOTE: does not support the "stay_setuid" option. * NOTE: does not support the "stay_setuid" option.

8
sudo.c
View File

@@ -856,14 +856,10 @@ initial_setup()
/* Set set_perms pointer to the correct function */ /* Set set_perms pointer to the correct function */
#if defined(_SC_SAVED_IDS) && defined(_SC_VERSION) #if defined(_SC_SAVED_IDS) && defined(_SC_VERSION)
if (sysconf(_SC_SAVED_IDS) == 1 && sysconf(_SC_VERSION) >= 199009) if (sysconf(_SC_SAVED_IDS) == 1 && sysconf(_SC_VERSION) >= 199009)
set_perms = set_perms_saved_uid; set_perms = set_perms_posix;
else else
#endif #endif
#ifdef HAVE_SETREUID set_perms = set_perms_fallback;
set_perms = set_perms_setreuid;
#else
set_perms = set_perms_fallback;
#endif
} }
#ifdef HAVE_LOGIN_CAP_H #ifdef HAVE_LOGIN_CAP_H

3
sudo.h
View File

@@ -199,8 +199,7 @@ int find_path __P((char *, char **, char *));
void check_user __P((void)); void check_user __P((void));
void verify_user __P((struct passwd *, char *)); void verify_user __P((struct passwd *, char *));
int sudoers_lookup __P((int)); int sudoers_lookup __P((int));
void set_perms_saved_uid __P((int, int)); void set_perms_posix __P((int, int));
void set_perms_setreuid __P((int, int));
void set_perms_fallback __P((int, int)); void set_perms_fallback __P((int, int));
void remove_timestamp __P((int)); void remove_timestamp __P((int));
int check_secureware __P((char *)); int check_secureware __P((char *));