File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -1885,6 +1885,7 @@ int git_fs_path_owner_is(
1885
1885
git_fs_path_owner_t owner_type )
1886
1886
{
1887
1887
PSID owner_sid = NULL , user_sid = NULL ;
1888
+ BOOL is_admin , admin_owned ;
1888
1889
int error ;
1889
1890
1890
1891
if (mock_owner ) {
@@ -1905,12 +1906,22 @@ int git_fs_path_owner_is(
1905
1906
}
1906
1907
}
1907
1908
1908
- if ((owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR ) != 0 ) {
1909
- if (IsWellKnownSid (owner_sid , WinBuiltinAdministratorsSid ) ||
1910
- IsWellKnownSid (owner_sid , WinLocalSystemSid )) {
1911
- * out = true;
1912
- goto done ;
1913
- }
1909
+ admin_owned =
1910
+ IsWellKnownSid (owner_sid , WinBuiltinAdministratorsSid ) ||
1911
+ IsWellKnownSid (owner_sid , WinLocalSystemSid );
1912
+
1913
+ if (admin_owned &&
1914
+ (owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR ) != 0 ) {
1915
+ * out = true;
1916
+ goto done ;
1917
+ }
1918
+
1919
+ if (admin_owned &&
1920
+ (owner_type & GIT_FS_PATH_USER_IS_ADMINISTRATOR ) != 0 &&
1921
+ CheckTokenMembership (NULL , owner_sid , & is_admin ) &&
1922
+ is_admin ) {
1923
+ * out = true;
1924
+ goto done ;
1914
1925
}
1915
1926
1916
1927
* out = false;
@@ -1962,6 +1973,7 @@ int git_fs_path_owner_is(
1962
1973
1963
1974
return 0 ;
1964
1975
}
1976
+
1965
1977
#endif
1966
1978
1967
1979
int git_fs_path_owner_is_current_user (bool * out , const char * path )
Original file line number Diff line number Diff line change @@ -740,8 +740,15 @@ typedef enum {
740
740
/** The file must be owned by the system account. */
741
741
GIT_FS_PATH_OWNER_ADMINISTRATOR = (1 << 1 ),
742
742
743
+ /**
744
+ * The file may be owned by a system account if the current
745
+ * user is in an administrator group. Windows only; this is
746
+ * a noop on non-Windows systems.
747
+ */
748
+ GIT_FS_PATH_USER_IS_ADMINISTRATOR = (1 << 2 ),
749
+
743
750
/** The file may be owned by another user. */
744
- GIT_FS_PATH_OWNER_OTHER = (1 << 2 )
751
+ GIT_FS_PATH_OWNER_OTHER = (1 << 3 )
745
752
} git_fs_path_owner_t ;
746
753
747
754
/**
You can’t perform that action at this time.
0 commit comments