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:
authorCorinna Vinschen <corinna@vinschen.de>2001-10-29 14:53:52 +0300
committerCorinna Vinschen <corinna@vinschen.de>2001-10-29 14:53:52 +0300
commitac19c8dcf619a7bc78490800540fe45f82aa8086 (patch)
tree14054a2364ae07bf7c2aa7cb61cc7dcbf56abab3 /winsup/cygwin/uinfo.cc
parent711ded6d2866e00b42e4d7c1136b201944e16578 (diff)
* uinfo.cc (internal_getlogin): Set environment variable $HOME
from either /etc/passwd or $HOMEDRIVE/$HOMEPATH if necessary.
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r--winsup/cygwin/uinfo.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 25994c702..29f119720 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -33,6 +33,7 @@ details. */
struct passwd *
internal_getlogin (cygheap_user &user)
{
+ char buf[512];
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
struct passwd *pw = NULL;
@@ -47,7 +48,6 @@ internal_getlogin (cygheap_user &user)
{
LPWKSTA_USER_INFO_1 wui;
NET_API_STATUS ret;
- char buf[512];
char *env;
user.set_logsrv (NULL);
@@ -212,7 +212,28 @@ internal_getlogin (cygheap_user &user)
}
}
debug_printf ("Cygwins Username: %s", user.name ());
- return pw ?: getpwnam(user.name ());
+ if (!pw)
+ pw = getpwnam(user.name ());
+ if (!getenv ("HOME"))
+ {
+ const char *homedrive, *homepath;
+ 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);
+ }
+ else if ((homedrive = getenv ("HOMEDRIVE"))
+ && (homepath = getenv ("HOMEPATH")))
+ {
+ char home[MAX_PATH];
+ strcpy (buf, homedrive);
+ strcat (buf, homepath);
+ cygwin_conv_to_full_posix_path (buf, home);
+ setenv ("HOME", home, 1);
+ debug_printf ("Set HOME (from HOMEDRIVE/HOMEPATH) to %s", home);
+ }
+ }
+ return pw;
}
void