diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-04 16:01:01 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-07 10:37:54 -0400 |
| commit | 5bc01a7ddbb765616b52d4504036fbbb0e483e8e (patch) | |
| tree | 87abef86759ecde17a76bb0ab6a39555ac4e09e8 /src/util/fs_path.c | |
| parent | 433f0166c946257214758b94d9ddbb8516e4fb98 (diff) | |
| download | libgit2-5bc01a7ddbb765616b52d4504036fbbb0e483e8e.tar.gz | |
fs: allow ownership match if user is in admin group
Allow the user ownership to match if the file is owned by the admin
group and the user is in the admin group, even if the current process is
not running as administrator directly.
Diffstat (limited to 'src/util/fs_path.c')
| -rw-r--r-- | src/util/fs_path.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/util/fs_path.c b/src/util/fs_path.c index 7ff6b27af..1eb41ef84 100644 --- a/src/util/fs_path.c +++ b/src/util/fs_path.c @@ -1885,6 +1885,7 @@ int git_fs_path_owner_is( git_fs_path_owner_t owner_type) { PSID owner_sid = NULL, user_sid = NULL; + BOOL is_admin, admin_owned; int error; if (mock_owner) { @@ -1905,12 +1906,22 @@ int git_fs_path_owner_is( } } - if ((owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0) { - if (IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) || - IsWellKnownSid(owner_sid, WinLocalSystemSid)) { - *out = true; - goto done; - } + admin_owned = + IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) || + IsWellKnownSid(owner_sid, WinLocalSystemSid); + + if (admin_owned && + (owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0) { + *out = true; + goto done; + } + + if (admin_owned && + (owner_type & GIT_FS_PATH_USER_IS_ADMINISTRATOR) != 0 && + CheckTokenMembership(NULL, owner_sid, &is_admin) && + is_admin) { + *out = true; + goto done; } *out = false; @@ -1962,6 +1973,7 @@ int git_fs_path_owner_is( return 0; } + #endif int git_fs_path_owner_is_current_user(bool *out, const char *path) |
