Skip to content

Commit d118041

Browse files
committed
Merge pull request #2725 from native-api/homedir_seclogons
Ignore Vista+ HOMEDRIVE/HOMEPATH default for non-shell logons
2 parents ff83990 + a7dfb01 commit d118041

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

compat/mingw.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2813,6 +2813,18 @@ static size_t append_system_bin_dirs(char *path, size_t size)
28132813
}
28142814
#endif
28152815

2816+
static int is_system32_path(const char *path)
2817+
{
2818+
WCHAR system32[MAX_LONG_PATH], wpath[MAX_LONG_PATH];
2819+
2820+
if (xutftowcs_long_path(wpath, path) < 0 ||
2821+
!GetSystemDirectoryW(system32, ARRAY_SIZE(system32)) ||
2822+
_wcsicmp(system32, wpath))
2823+
return 0;
2824+
2825+
return 1;
2826+
}
2827+
28162828
static void setup_windows_environment(void)
28172829
{
28182830
char *tmp = getenv("TMPDIR");
@@ -2853,7 +2865,8 @@ static void setup_windows_environment(void)
28532865
strbuf_addstr(&buf, tmp);
28542866
if ((tmp = getenv("HOMEPATH"))) {
28552867
strbuf_addstr(&buf, tmp);
2856-
if (is_directory(buf.buf))
2868+
if (!is_system32_path(buf.buf) &&
2869+
is_directory(buf.buf))
28572870
setenv("HOME", buf.buf, 1);
28582871
else
28592872
tmp = NULL; /* use $USERPROFILE */

0 commit comments

Comments
 (0)