summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/cygheap.h2
-rw-r--r--winsup/cygwin/environ.cc23
-rw-r--r--winsup/cygwin/uinfo.cc22
4 files changed, 47 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 74fe8438e..0533bf774 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,16 @@
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.
2004-10-07 Christopher Faylor <cgf@timesys.com>
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index b8203bf08..80abe6e2c 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -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 ()
{
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 6bd5f2f68..90c828e72 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -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)
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 757ca2000..6fca2fde8 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -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)
{