From: Todd C. Miller Date: Thu, 27 Jan 1994 00:52:18 +0000 (+0000) Subject: now use setreuid() X-Git-Tag: SUDO_1_3_0~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b566c24c628ab510a66012e3713001673fe4be9;p=sudo now use setreuid() --- diff --git a/check.c b/check.c index 16c55bb73..4a24a6b99 100644 --- a/check.c +++ b/check.c @@ -82,10 +82,10 @@ void check_user() exit(1); } rtn = check_timestamp(); - if (setruid(uid)) { /* don't want to be root longer than - * necessary */ + /* don't want to be root longer than necessary */ + if (setreuid(uid, (uid_t)-1)) { #ifndef _AIX - perror("setruid(uid)"); + perror("setreuid()"); exit(1); #endif } @@ -97,10 +97,10 @@ void check_user() exit(1); } update_timestamp(); - if (setruid(uid)) { /* don't want to be root longer than - * necessary */ + /* don't want to be root longer than necessary */ + if (setreuid(uid, (uid_t)-1)) { #ifndef _AIX - perror("setruid(uid)"); + perror("setreuid()"); exit(1); #endif } diff --git a/sudo.c b/sudo.c index e96a2210a..123a88a3d 100644 --- a/sudo.c +++ b/sudo.c @@ -131,9 +131,9 @@ main(argc, argv, envp) exit(1); } rtn = validate(); - if (setruid(uid)) { + if (setreuid(uid, (uid_t)-1)) { #ifndef _AIX - perror("setruid(uid)"); + perror("setreuid()"); exit(1); #endif } diff --git a/sudo.h b/sudo.h index 7e24d81ef..1dcd021e0 100644 --- a/sudo.h +++ b/sudo.h @@ -289,19 +289,12 @@ extern char **Envp; #endif extern int errno; -/* - * Emulate setruid() under linux - */ -#ifdef linux -#define setruid(__RUID) (setreuid((uid_t) (__RUID), (uid_t) -1)) -#endif /* linux */ - /* * This is to placate hpux */ #ifdef hpux -#define setruid(__RUID) (setresuid((uid_t) (__RUID), (uid_t) -1, (uid_t) -1)) -#define getdtablesize() (sysconf(_SC_OPEN_MAX)) +#define setreuid(__RUID, __EUID) (setresuid(__RUID, __EUID, (uid_t) -1)) +#define getdtablesize() (sysconf(_SC_OPEN_MAX)) #ifndef USE_CWD #define USE_CWD #endif /* USE_CWD */