* cygheap.cc (cygheap_user::set_logsrv): Remove.
(cygheap_user::set_domain): Ditto. * cygheap.h (cygheap_user::set_logsrv): Remove declaration. (cygheap_user::set_domain): Ditto. (cygheap_user::env_domain): Declare new method. (cygheap_user::env_name): Ditto. * environ.cc (spenvs): Add two environment variables. * spawn.cc (spawn_guts): Call build_env after RevertToSelf. Always set ciresrv.mount_h. (cygheap_user::ontherange): Recalculate homedrive/homepath if they are empty. Use env_logsrv to get logon server. (cygheap_user::env_logsrv): Calculate server name here rather than relying on it having been previously calculated. (cygheap_user::env_domain): Ditto for domain name. (cygheap-user::env_name): New method. * syscalls.cc (seteuid32): Do not get or set the environment. Do not call LookupAccountSid nor internal_getlogin. Set cygheap->user name and sid from the passwd entry. * uinfo.cc (uinfo_init): Only call internal_getlogin when starting from a non Cygwin process and use the values returned in user. (internal_getlogin): Simplify to case where starting from a non Cygwin process. Store return values in user and return void. Do not set the Windows default environment. * dcrt0.cc (dll_crt0_1): Call uinfo_init only when needed. Do not set myself->uid nor reset user.sid. * spawn.cc (spawn_guts): Get the sid from cygheap->user. Always RevertToSelf(). Don't set uid in impersonated case. * cygheap.cc (cygheap_user::set_sid): Do not set orig_sig. (cygheap_user::set_orig_sid): New. * cygheap.h: Declare cygheap_user::set_sid. * winsup.h: Add argument to uinfo_init().
This commit is contained in:
@@ -567,8 +567,6 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
ciresrv.moreinfo->argc = newargv.argc;
|
||||
ciresrv.moreinfo->argv = newargv;
|
||||
ciresrv.hexec_proc = hexec_proc;
|
||||
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
|
||||
real_path.iscygexec ());
|
||||
|
||||
if (mode != _P_OVERLAY ||
|
||||
!DuplicateHandle (hMainProc, myself.shared_handle (), hMainProc,
|
||||
@@ -610,14 +608,14 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
char sa_buf[1024];
|
||||
|
||||
cygbench ("spawn-guts");
|
||||
ciresrv.mount_h = cygwin_mount_h;
|
||||
|
||||
if (!cygheap->user.impersonated || cygheap->user.token == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf);
|
||||
ciresrv.moreinfo->uid = getuid32 ();
|
||||
/* FIXME: This leaks a handle in the CreateProcessAsUser case since the
|
||||
child process doesn't know about cygwin_mount_h. */
|
||||
ciresrv.mount_h = cygwin_mount_h;
|
||||
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
|
||||
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
|
||||
real_path.iscygexec ());
|
||||
rc = CreateProcess (runpath, /* image name - with full path */
|
||||
one_line.buf, /* what was passed to exec */
|
||||
sec_attribs, /* process security attrs */
|
||||
@@ -631,16 +629,9 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
}
|
||||
else
|
||||
{
|
||||
cygsid sid;
|
||||
DWORD ret_len;
|
||||
if (!GetTokenInformation (cygheap->user.token, TokenUser, &sid,
|
||||
sizeof sid, &ret_len))
|
||||
{
|
||||
sid = NO_SID;
|
||||
system_printf ("GetTokenInformation: %E");
|
||||
}
|
||||
/* Retrieve security attributes before setting psid to NULL
|
||||
since it's value is needed by `sec_user'. */
|
||||
PSID sid = cygheap->user.sid ();
|
||||
|
||||
/* Set security attributes with sid */
|
||||
PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf, sid);
|
||||
|
||||
RevertToSelf ();
|
||||
@@ -655,7 +646,6 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
char wstname[1024];
|
||||
char dskname[1024];
|
||||
|
||||
ciresrv.moreinfo->uid = ILLEGAL_UID;
|
||||
hwst = GetProcessWindowStation ();
|
||||
SetUserObjectSecurity (hwst, &dsi, get_null_sd ());
|
||||
GetUserObjectInformation (hwst, UOI_NAME, wstname, 1024, &n);
|
||||
@@ -667,6 +657,8 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
si.lpDesktop = wstname;
|
||||
|
||||
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
|
||||
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
|
||||
real_path.iscygexec ());
|
||||
rc = CreateProcessAsUser (cygheap->user.token,
|
||||
runpath, /* image name - with full path */
|
||||
one_line.buf, /* what was passed to exec */
|
||||
|
Reference in New Issue
Block a user