src/rt: use the Git mirror of the MSys CVS repository rather than CVS
[msysgit.git] / src / rt / patches / 0007-only-override-the-variables-HOMEPATH-and-HOMEDRIVE-i.patch
blob40ed6132daf648ded995590c13bc521a01544e63
1 From dafcd879e192bba15c9016e993231bbce48bda6a Mon Sep 17 00:00:00 2001
2 From: Heiko Voigt <hvoigt@hvoigt.net>
3 Date: Tue, 12 May 2009 16:23:51 +0200
4 Subject: [PATCH] only override the variables HOMEPATH and HOMEDRIVE if they are not set
6 It seems that in old windows systems these variables were quite unreliable.
7 So they were overriden by using the information the function NetUserGetInfo
8 returned for the current user. As this does not seem to be true anymore
9 we do not override them if they exist in the default environment.
11 Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
12 ---
13 source/winsup/cygwin/uinfo.cc | 10 +++++++---
14 1 files changed, 7 insertions(+), 3 deletions(-)
16 diff --git a/msys/rt/src/winsup/cygwin/uinfo.cc b/msys/rt/src/winsup/cygwin/uinfo.cc
17 index 7f9b8a1..01f22e9 100644
18 --- a/msys/rt/src/winsup/cygwin/uinfo.cc
19 +++ b/msys/rt/src/winsup/cygwin/uinfo.cc
20 @@ -80,7 +80,9 @@ internal_getlogin (cygheap_user &user)
21 WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
23 /* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
24 - after changing user context! */
25 + after changing user context!
26 + As this does not be true anymore we only "correct" them
27 + in case they do not exist. */
28 sys_mbstowcs (wuser, user.name (), UNLEN + 1);
29 wlogsrv[0] = '\0';
30 if (user.logsrv ())
31 @@ -88,8 +90,10 @@ internal_getlogin (cygheap_user &user)
32 strcat (strcpy (buf, "\\\\"), user.logsrv ());
33 sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
35 - if (!NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)
36 - || (wlogsrv[0] && !NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui)))
37 + if (!(getenv ("HOMEPATH") && getenv ("HOMEDRIVE"))
38 + && (!NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)
39 + || (wlogsrv[0]
40 + && !NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui))))
42 sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
43 if (!buf[0])
44 --
45 1.6.3.GIT