Skip to content

Commit 2b57c11

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: be more informative when ownership check fails on FAT32
The FAT file system has no concept of ACLs. Therefore, it cannot store any ownership information anyway, and the `GetNamedSecurityInfoW()` call pretends that everything is owned "by the world". Let's special-case that scenario and tell the user what's going on, at least when they set `GIT_TEST_DEBUG_UNSAFE_DIRECTORIES`. This addresses #3886 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8dbbc2a commit 2b57c11

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

compat/mingw.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,22 @@ static PSID get_current_user_sid(void)
26712671
return result;
26722672
}
26732673

2674+
static int acls_supported(const char *path)
2675+
{
2676+
size_t offset = offset_1st_component(path);
2677+
WCHAR wroot[MAX_PATH];
2678+
DWORD file_system_flags;
2679+
2680+
if (offset &&
2681+
xutftowcs_path_ex(wroot, path, MAX_PATH, offset,
2682+
MAX_PATH, 0) > 0 &&
2683+
GetVolumeInformationW(wroot, NULL, 0, NULL, NULL,
2684+
&file_system_flags, NULL, 0))
2685+
return !!(file_system_flags & FILE_PERSISTENT_ACLS);
2686+
2687+
return 0;
2688+
}
2689+
26742690
int is_path_owned_by_current_sid(const char *path)
26752691
{
26762692
WCHAR wpath[MAX_PATH];
@@ -2728,7 +2744,14 @@ int is_path_owned_by_current_sid(const char *path)
27282744
* okay, too.
27292745
*/
27302746
result = 1;
2731-
else if (git_env_bool("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES", 0)) {
2747+
else if (IsWellKnownSid(sid, WinWorldSid) &&
2748+
git_env_bool("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES", 0) &&
2749+
!acls_supported(path)) {
2750+
/*
2751+
* On FAT32 volumes, ownership is not actually recorded.
2752+
*/
2753+
warning("'%s' is on a file system that does not record ownership", path);
2754+
} else if (git_env_bool("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES", 0)) {
27322755
LPSTR str1, str2, to_free1 = NULL, to_free2 = NULL;
27332756

27342757
if (ConvertSidToStringSidA(sid, &str1))

0 commit comments

Comments
 (0)