* cygheap.h (class cygheap_user): Add psystemroot member and
env_systemroot method. * environ.cc (struct spenv): Add add_always member. (spenvs): Accomodate new add_always member. Add cygheap_user::env_systemroot method to SYSTEMROOT entry. (build_env): Check add_always member when adding missing environment variables from spenvs. * uinfo.cc (cygheap_user::env_systemroot): New method.
This commit is contained in:
parent
9286b55306
commit
60cb120f3e
|
@ -1,3 +1,14 @@
|
|||
2004-10-07 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* cygheap.h (class cygheap_user): Add psystemroot member and
|
||||
env_systemroot method.
|
||||
* environ.cc (struct spenv): Add add_always member.
|
||||
(spenvs): Accomodate new add_always member. Add
|
||||
cygheap_user::env_systemroot method to SYSTEMROOT entry.
|
||||
(build_env): Check add_always member when adding missing environment
|
||||
variables from spenvs.
|
||||
* uinfo.cc (cygheap_user::env_systemroot): New method.
|
||||
|
||||
2004-10-07 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* dcrt0.cc (dll_crt0_0): Drop duplicated line.
|
||||
|
|
|
@ -106,6 +106,7 @@ class cygheap_user
|
|||
char *pdomain; /* Logon domain of the user */
|
||||
char *homedrive; /* User's home drive */
|
||||
char *homepath; /* User's home path */
|
||||
char *psystemroot; /* Value of SYSTEMROOT */
|
||||
char *pwinname; /* User's name as far as Windows knows it */
|
||||
char *puserprof; /* User profile */
|
||||
cygsid effec_cygsid; /* buffer for user's SID */
|
||||
|
@ -146,6 +147,7 @@ public:
|
|||
const char *env_userprofile (const char *, size_t);
|
||||
const char *env_domain (const char *, size_t);
|
||||
const char *env_name (const char *, size_t);
|
||||
const char *env_systemroot (const char *, size_t);
|
||||
|
||||
const char *logsrv ()
|
||||
{
|
||||
|
|
|
@ -819,7 +819,9 @@ struct spenv
|
|||
{
|
||||
const char *name;
|
||||
size_t namelen;
|
||||
bool add_always; /* If true, always add to env if missing */
|
||||
const char * (cygheap_user::*from_cygheap) (const char *, size_t);
|
||||
|
||||
char *retrieve (bool, const char * const = NULL)
|
||||
__attribute__ ((regparm (3)));
|
||||
};
|
||||
|
@ -829,14 +831,14 @@ struct spenv
|
|||
/* Keep this list in upper case and sorted */
|
||||
static NO_COPY spenv spenvs[] =
|
||||
{
|
||||
{NL ("HOMEDRIVE="), &cygheap_user::env_homedrive},
|
||||
{NL ("HOMEPATH="), &cygheap_user::env_homepath},
|
||||
{NL ("LOGONSERVER="), &cygheap_user::env_logsrv},
|
||||
{NL ("SYSTEMDRIVE="), NULL},
|
||||
{NL ("SYSTEMROOT="), NULL},
|
||||
{NL ("USERDOMAIN="), &cygheap_user::env_domain},
|
||||
{NL ("USERNAME="), &cygheap_user::env_name},
|
||||
{NL ("USERPROFILE="), &cygheap_user::env_userprofile},
|
||||
{NL ("HOMEDRIVE="), false, &cygheap_user::env_homedrive},
|
||||
{NL ("HOMEPATH="), false, &cygheap_user::env_homepath},
|
||||
{NL ("LOGONSERVER="), false, &cygheap_user::env_logsrv},
|
||||
{NL ("SYSTEMDRIVE="), false, NULL},
|
||||
{NL ("SYSTEMROOT="), true, &cygheap_user::env_systemroot},
|
||||
{NL ("USERDOMAIN="), false, &cygheap_user::env_domain},
|
||||
{NL ("USERNAME="), false, &cygheap_user::env_name},
|
||||
{NL ("USERPROFILE="), false, &cygheap_user::env_userprofile},
|
||||
};
|
||||
|
||||
char *
|
||||
|
@ -928,9 +930,8 @@ build_env (const char * const *envp, char *&envblock, int &envc,
|
|||
|
||||
assert ((srcp - envp) == n);
|
||||
/* Fill in any required-but-missing environment variables. */
|
||||
if (cygheap->user.issetuid ())
|
||||
for (unsigned i = 0; i < SPENVS_SIZE; i++)
|
||||
if (!saw_spenv[i])
|
||||
for (unsigned i = 0; i < SPENVS_SIZE; i++)
|
||||
if (!saw_spenv[i] && (spenvs[i].add_always || cygheap->user.issetuid ()))
|
||||
{
|
||||
*dstp = spenvs[i].retrieve (no_envblock);
|
||||
if (*dstp && !no_envblock && *dstp != env_dontadd)
|
||||
|
|
|
@ -449,6 +449,28 @@ cygheap_user::env_name (const char *name, size_t namelen)
|
|||
return pwinname;
|
||||
}
|
||||
|
||||
const char *
|
||||
cygheap_user::env_systemroot (const char *name, size_t namelen)
|
||||
{
|
||||
if (!psystemroot)
|
||||
{
|
||||
int size = GetWindowsDirectory (NULL, 0);
|
||||
if (size > 0)
|
||||
{
|
||||
psystemroot = (char *) cmalloc (HEAP_STR, ++size);
|
||||
size = GetWindowsDirectory (psystemroot, size);
|
||||
if (size <= 0)
|
||||
{
|
||||
cfree (psystemroot);
|
||||
psystemroot = NULL;
|
||||
}
|
||||
}
|
||||
if (size <= 0)
|
||||
debug_printf ("GetWindowsDirectory(), %E");
|
||||
}
|
||||
return psystemroot;
|
||||
}
|
||||
|
||||
char *
|
||||
pwdgrp::next_str (char c)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue