* 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'.
This commit is contained in:
Christopher Faylor
2002-06-16 23:34:43 +00:00
parent 45e9463a38
commit e40670ee48
7 changed files with 51 additions and 26 deletions

View File

@ -441,7 +441,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
si.cbReserved2 = sizeof(ch);
/* Remove impersonation */
if (cygheap->user.impersonated && cygheap->user.token != INVALID_HANDLE_VALUE)
if (cygheap->user.issetuid ())
RevertToSelf ();
ch.parent = hParent;
@ -490,8 +490,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
ForceCloseHandle(subproc_ready);
ForceCloseHandle(forker_finished);
/* Restore impersonation */
if (cygheap->user.impersonated
&& cygheap->user.token != INVALID_HANDLE_VALUE)
if (cygheap->user.issetuid ())
ImpersonateLoggedOnUser (cygheap->user.token);
cygheap_setup_for_child_cleanup (newheap, &ch, 0);
return -1;
@ -519,7 +518,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
strcpy(forked->progname, myself->progname);
/* Restore impersonation */
if (cygheap->user.impersonated && cygheap->user.token != INVALID_HANDLE_VALUE)
if (cygheap->user.issetuid ())
ImpersonateLoggedOnUser (cygheap->user.token);
ProtectHandle (pi.hThread);