* cygheap.h (enum impersonation): New enum.
(cygheap_user::token): Delete. (cygheap_user::impersonated): Delete. (cygheap_user::external_token): New member. (cygheap_user::internal_token): New member. (cygheap_user::impersonation_state): New member. (cygheap_user::issetuid): Modify. (cygheap_user::token): New method. (cygheap_user::deimpersonate): New method. (cygheap_user::reimpersonate): New method. (cygheap_user::has_impersonation_tokens): New method. (cygheap_user::close_impersonation_tokens): New method. * dtable.cc (dtable::vfork_child_dup): Use new cygheap_user methods. * fhandler_socket.cc (fhandler_socket::dup): Ditto. * fork.cc (fork_child): Ditto. (fork_parent): Ditto. * grp.cc (internal_getgroups): Ditto. * security.cc (verify_token): Ditto. (check_file_access): Ditto. (cygwin_set_impersonation_token): Detect conflicts. Set user.external_token. * spawn.cc (spawn_guts): Use new cygheap_user methods. * syscalls.cc (seteuid32): Rearrange to use the two tokens in cygheap_user. (setegid32): Use new cygheap_user methods. * uinfo.cc: (internal_getlogin): Ditto.
This commit is contained in:
@@ -621,8 +621,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
cygbench ("spawn-guts");
|
||||
|
||||
cygheap->fdtab.set_file_pointers_for_exec ();
|
||||
if (cygheap->user.issetuid ())
|
||||
RevertToSelf ();
|
||||
cygheap->user.deimpersonate ();
|
||||
/* When ruid != euid we create the new process under the current original
|
||||
account and impersonate in child, this way maintaining the different
|
||||
effective vs. real ids.
|
||||
@@ -678,7 +677,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
|
||||
real_path.iscygexec ());
|
||||
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
|
||||
rc = CreateProcessAsUser (cygheap->user.token,
|
||||
rc = CreateProcessAsUser (cygheap->user.token (),
|
||||
runpath, /* image name - with full path */
|
||||
one_line.buf, /* what was passed to exec */
|
||||
sec_attribs, /* process security attrs */
|
||||
@@ -692,8 +691,8 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
}
|
||||
/* Restore impersonation. In case of _P_OVERLAY this isn't
|
||||
allowed since it would overwrite child data. */
|
||||
if (mode != _P_OVERLAY && cygheap->user.issetuid ())
|
||||
ImpersonateLoggedOnUser (cygheap->user.token);
|
||||
if (mode != _P_OVERLAY)
|
||||
cygheap->user.reimpersonate ();
|
||||
|
||||
MALLOC_CHECK;
|
||||
if (envblock)
|
||||
|
Reference in New Issue
Block a user