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(
18851885 git_fs_path_owner_t owner_type )
18861886{
18871887 PSID owner_sid = NULL , user_sid = NULL ;
1888+ BOOL is_admin , admin_owned ;
18881889 int error ;
18891890
18901891 if (mock_owner ) {
@@ -1905,12 +1906,22 @@ int git_fs_path_owner_is(
19051906 }
19061907 }
19071908
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 ;
19141925 }
19151926
19161927 * out = false;
@@ -1962,6 +1973,7 @@ int git_fs_path_owner_is(
19621973
19631974 return 0 ;
19641975}
1976+
19651977#endif
19661978
19671979int 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 {
740740 /** The file must be owned by the system account. */
741741 GIT_FS_PATH_OWNER_ADMINISTRATOR = (1 << 1 ),
742742
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+
743750 /** The file may be owned by another user. */
744- GIT_FS_PATH_OWNER_OTHER = (1 << 2 )
751+ GIT_FS_PATH_OWNER_OTHER = (1 << 3 )
745752} git_fs_path_owner_t ;
746753
747754/**
You can’t perform that action at this time.
0 commit comments