Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-07-01 07:57:17 +0400
committerChristopher Faylor <me@cgf.cx>2002-07-01 07:57:17 +0400
commit8297bda005945c58140c7bbf5e1f18ad5baaa05a (patch)
treec140bec3eae5768fd7a2cca8b39675e112c27575
parentfad1c3a8e01e7403cff97f689fb66a2696ec306a (diff)
* uinfo.cc (cygheap_user::ontherange): Potentially set HOME from existing
homepath and homedrive cygheap_user fields (not currently used yet). Set HOME to / if no other alternative. (cygheap_user::test_uid): Simplify.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/uinfo.cc24
2 files changed, 21 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0fb306c65..5ccdb610d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
2002-06-30 Christopher Faylor <cgf@redhat.com>
+ * uinfo.cc (cygheap_user::ontherange): Potentially set HOME from
+ existing homepath and homedrive cygheap_user fields (not currently used
+ yet). Set HOME to / if no other alternative.
+ (cygheap_user::test_uid): Simplify.
+
+2002-06-30 Christopher Faylor <cgf@redhat.com>
+
* environ.cc (parse_options): Use setenv to potentially replace CYGWIN
value on export. Fixes broken behavior since November 2000 changes.
(regopt): Return indication of whether or not something has been parsed
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index cd39097d5..d8fb3829b 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -204,10 +204,14 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
if (what == CH_HOME)
{
char *p;
- if ((p = getenv ("HOMEDRIVE")))
+ if (homedrive)
+ newhomedrive = homedrive;
+ else if ((p = getenv ("HOMEDRIVE")))
newhomedrive = p;
- if ((p = getenv ("HOMEPATH")))
+ if (homepath)
+ newhomepath = homepath;
+ else if ((p = getenv ("HOMEPATH")))
newhomepath = p;
if ((p = getenv ("HOME")))
@@ -218,18 +222,20 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
pw = getpwnam (name ());
if (pw && pw->pw_dir && *pw->pw_dir)
{
- setenv ("HOME", pw->pw_dir, 1);
debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir);
+ setenv ("HOME", pw->pw_dir, 1);
}
- else if (newhomedrive && newhomepath)
+ else if (!newhomedrive || !newhomepath)
+ setenv ("HOME", "/", 1);
+ else
{
char home[MAX_PATH];
char buf[MAX_PATH + 1];
strcpy (buf, newhomedrive);
strcat (buf, newhomepath);
cygwin_conv_to_full_posix_path (buf, home);
- setenv ("HOME", home, 1);
debug_printf ("Set HOME (from HOMEDRIVE/HOMEPATH) to %s", home);
+ setenv ("HOME", home, 1);
}
}
}
@@ -285,11 +291,11 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
}
}
- if (newhomedrive)
+ if (newhomedrive && newhomedrive != homedrive)
cfree_and_set (homedrive, (newhomedrive == almost_null)
? almost_null : cstrdup (newhomedrive));
- if (newhomepath)
+ if (newhomepath && newhomepath != homepath)
cfree_and_set (homepath, cstrdup (newhomepath));
switch (what)
@@ -306,9 +312,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
const char *
cygheap_user::test_uid (char *&what, const char *name, size_t namelen)
{
- if (what)
- return what;
- if (!issetuid ())
+ if (!what && !issetuid ())
what = getwinenveq (name, namelen, HEAP_STR);
return what;
}