summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-06-16 23:34:43 +0000
committerChristopher Faylor <me@cgf.cx>2002-06-16 23:34:43 +0000
commite40670ee488a5dcea90a57efb58ecd04ee39a302 (patch)
treef56b9f45a0723b621407cd4e009be6ef54f32a26 /winsup/cygwin/syscalls.cc
parent45e9463a38af63cd024f3a568b9c61be4df2b0d1 (diff)
downloadcygnal-e40670ee488a5dcea90a57efb58ecd04ee39a302.tar.gz
cygnal-e40670ee488a5dcea90a57efb58ecd04ee39a302.tar.bz2
cygnal-e40670ee488a5dcea90a57efb58ecd04ee39a302.zip
* cygheap.h (cygheap_user::issetuid): New method.
* dtable.cc (dtable::vfork_child_dup): Use new method to determine if we are in "setuid mode." * fork.cc (fork_parent): Ditto. * spawn.cc (spawn_guts): Ditto. * syscalls.cc (seteuid32): Ditto. (setegid32): Ditto. * environ.cc (spenv::retrieve): (Suggested by Pierre Humblet) Do potential recalculation of cygheap_user stuff when in setuid mode. Return special value when environment variable exists but should not be added. (build_env): Don't add retrieved value to dstp if it is 'dont_add'.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 1f6fab536..1bce92f0b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2093,9 +2093,8 @@ seteuid32 (__uid32_t uid)
failed:
cygheap->user.token = sav_token;
cygheap->user.impersonated = sav_impersonated;
- if ( cygheap->user.token != INVALID_HANDLE_VALUE &&
- cygheap->user.impersonated &&
- !ImpersonateLoggedOnUser (cygheap->user.token))
+ if (cygheap->user.issetuid ()
+ && !ImpersonateLoggedOnUser (cygheap->user.token))
system_printf ("Impersonating in seteuid failed: %E");
return -1;
}
@@ -2144,8 +2143,7 @@ setegid32 (__gid32_t gid)
myself->gid = gid;
/* If impersonated, update primary group and revert */
- if (cygheap->user.token != INVALID_HANDLE_VALUE
- && cygheap->user.impersonated)
+ if (cygheap->user.issetuid ())
{
if (!SetTokenInformation (cygheap->user.token,
TokenPrimaryGroup,
@@ -2166,8 +2164,7 @@ setegid32 (__gid32_t gid)
"TokenPrimaryGroup): %E");
CloseHandle (ptok);
}
- if (cygheap->user.token != INVALID_HANDLE_VALUE
- && cygheap->user.impersonated
+ if (cygheap->user.issetuid ()
&& !ImpersonateLoggedOnUser (cygheap->user.token))
system_printf ("Impersonating in setegid failed: %E");
return 0;