* cygheap.h (cygheap_user::userprofile_env_buf): New static member.

* environ.cc (build_env): Add debugging statement.
(spenvs): Switch functions for USERDOMAIN and USERNAME.
* spawn.cc (spawn_guts): Move environment initialization prior to
cygheap_setup_for_child or environment info will never be copied to child.
This commit is contained in:
Christopher Faylor 2002-06-14 21:46:19 +00:00
parent b56d7e7937
commit 6d171b4482
5 changed files with 20 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2002-06-14 Christopher Faylor <cgf@redhat.com>
* cygheap.h (cygheap_user::userprofile_env_buf): New static member.
* environ.cc (build_env): Add debugging statement.
(spenvs): Switch functions for USERDOMAIN and USERNAME.
* spawn.cc (spawn_guts): Move environment initialization prior to
cygheap_setup_for_child or environment info will never be copied to
child.
2002-06-14 Christopher Faylor <cgf@redhat.com> 2002-06-14 Christopher Faylor <cgf@redhat.com>
* cygheap.h (cygheap_user): Add static members to hold home{drive,path} * cygheap.h (cygheap_user): Add static members to hold home{drive,path}

View File

@ -109,6 +109,9 @@ class cygheap_user
info may live. */ info may live. */
static char homepath_env_buf[MAX_PATH + 1]; /* Where the HOMEPATH environment static char homepath_env_buf[MAX_PATH + 1]; /* Where the HOMEPATH environment
variable info may live. */ variable info may live. */
static char userprofile_env_buf[MAX_PATH + 1]; /* Where the USERPROFILE
environment variable info
may live. */
public: public:
__uid32_t orig_uid; /* Remains intact even after impersonation */ __uid32_t orig_uid; /* Remains intact even after impersonation */
__gid32_t orig_gid; /* Ditto */ __gid32_t orig_gid; /* Ditto */

View File

@ -765,8 +765,8 @@ static NO_COPY spenv spenvs[] =
{"LOGONSERVER=", &cygheap_user::env_logsrv}, {"LOGONSERVER=", &cygheap_user::env_logsrv},
{"SYSTEMDRIVE=", NULL}, {"SYSTEMDRIVE=", NULL},
{"SYSTEMROOT=", NULL}, {"SYSTEMROOT=", NULL},
{"USERDOMAIN=", &cygheap_user::env_name}, {"USERDOMAIN=", &cygheap_user::env_domain},
{"USERNAME=", &cygheap_user::env_domain}, {"USERNAME=", &cygheap_user::env_name},
{"USERPROFILE=", &cygheap_user::env_userprofile}, {"USERPROFILE=", &cygheap_user::env_userprofile},
}; };
@ -939,6 +939,7 @@ build_env (const char * const *envp, char *&envblock, int &envc,
of buffer */ of buffer */
} }
debug_printf ("envp %p, envc %d", newenv, envc);
return newenv; return newenv;
} }

View File

@ -613,9 +613,9 @@ spawn_guts (const char * prog_arg, const char *const *argv,
if (!cygheap->user.impersonated || cygheap->user.token == INVALID_HANDLE_VALUE) if (!cygheap->user.impersonated || cygheap->user.token == INVALID_HANDLE_VALUE)
{ {
PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf); PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf);
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc, ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
real_path.iscygexec ()); real_path.iscygexec ());
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
rc = CreateProcess (runpath, /* image name - with full path */ rc = CreateProcess (runpath, /* image name - with full path */
one_line.buf, /* what was passed to exec */ one_line.buf, /* what was passed to exec */
sec_attribs, /* process security attrs */ sec_attribs, /* process security attrs */
@ -656,9 +656,9 @@ spawn_guts (const char * prog_arg, const char *const *argv,
strcat (wstname, dskname); strcat (wstname, dskname);
si.lpDesktop = wstname; si.lpDesktop = wstname;
newheap = cygheap_setup_for_child (&ciresrv, cygheap->fdtab.need_fixup_before ());
ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc, ciresrv.moreinfo->envp = build_env (envp, envblock, ciresrv.moreinfo->envc,
real_path.iscygexec ()); 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 */ runpath, /* image name - with full path */
one_line.buf, /* what was passed to exec */ one_line.buf, /* what was passed to exec */

View File

@ -190,6 +190,7 @@ cuserid (char *src)
char cygheap_user::homepath_env_buf[MAX_PATH + 1]; char cygheap_user::homepath_env_buf[MAX_PATH + 1];
char cygheap_user::homedrive_env_buf[3]; char cygheap_user::homedrive_env_buf[3];
char cygheap_user::userprofile_env_buf[MAX_PATH + 1];
const char * const char *
cygheap_user::ontherange (homebodies what, struct passwd *pw) cygheap_user::ontherange (homebodies what, struct passwd *pw)
@ -335,12 +336,11 @@ cygheap_user::env_domain ()
const char * const char *
cygheap_user::env_userprofile () cygheap_user::env_userprofile ()
{ {
static char buf[512]; /* FIXME: This shouldn't be static. */
if (strcasematch (name (), "SYSTEM") || !env_domain () || !env_logsrv ()) if (strcasematch (name (), "SYSTEM") || !env_domain () || !env_logsrv ())
return NULL; return NULL;
if (get_registry_hive_path (sid (), buf)) if (get_registry_hive_path (sid (), userprofile_env_buf))
return buf; return userprofile_env_buf;
else else
return NULL; return NULL;
} }