Skip to content

Commit f1412ec

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

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
@@ -2816,6 +2816,18 @@ static size_t append_system_bin_dirs(char *path, size_t size)
28162816
}
28172817
#endif
28182818

2819+
static int is_system32_path(const char *path)
2820+
{
2821+
WCHAR system32[MAX_LONG_PATH], wpath[MAX_LONG_PATH];
2822+
2823+
if (xutftowcs_long_path(wpath, path) < 0 ||
2824+
!GetSystemDirectoryW(system32, ARRAY_SIZE(system32)) ||
2825+
_wcsicmp(system32, wpath))
2826+
return 0;
2827+
2828+
return 1;
2829+
}
2830+
28192831
static void setup_windows_environment(void)
28202832
{
28212833
char *tmp = getenv("TMPDIR");
@@ -2856,7 +2868,8 @@ static void setup_windows_environment(void)
28562868
strbuf_addstr(&buf, tmp);
28572869
if ((tmp = getenv("HOMEPATH"))) {
28582870
strbuf_addstr(&buf, tmp);
2859-
if (is_directory(buf.buf))
2871+
if (!is_system32_path(buf.buf) &&
2872+
is_directory(buf.buf))
28602873
setenv("HOME", buf.buf, 1);
28612874
else
28622875
tmp = NULL; /* use $USERPROFILE */

0 commit comments

Comments
 (0)