@@ -3514,6 +3514,22 @@ static PSID get_current_user_sid(void)
35143514 return result ;
35153515}
35163516
3517+ static int acls_supported (const char * path )
3518+ {
3519+ size_t offset = offset_1st_component (path );
3520+ WCHAR wroot [MAX_PATH ];
3521+ DWORD file_system_flags ;
3522+
3523+ if (offset &&
3524+ xutftowcs_path_ex (wroot , path , MAX_PATH , offset ,
3525+ MAX_PATH , 0 ) > 0 &&
3526+ GetVolumeInformationW (wroot , NULL , 0 , NULL , NULL ,
3527+ & file_system_flags , NULL , 0 ))
3528+ return !!(file_system_flags & FILE_PERSISTENT_ACLS );
3529+
3530+ return 0 ;
3531+ }
3532+
35173533int is_path_owned_by_current_sid (const char * path )
35183534{
35193535 WCHAR wpath [MAX_PATH ];
@@ -3569,7 +3585,14 @@ int is_path_owned_by_current_sid(const char *path)
35693585 * okay, too.
35703586 */
35713587 result = 1 ;
3572- else if (git_env_bool ("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES" , 0 )) {
3588+ else if (IsWellKnownSid (sid , WinWorldSid ) &&
3589+ git_env_bool ("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES" , 0 ) &&
3590+ !acls_supported (path )) {
3591+ /*
3592+ * On FAT32 volumes, ownership is not actually recorded.
3593+ */
3594+ warning ("'%s' is on a file system that does not record ownership" , path );
3595+ } else if (git_env_bool ("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES" , 0 )) {
35733596 LPSTR str1 , str2 , to_free1 = NULL , to_free2 = NULL ;
35743597
35753598 if (ConvertSidToStringSidA (sid , & str1 ))
0 commit comments