diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-04 16:03:10 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-06 14:34:06 -0400 |
commit | b2264f45b1190a11506d1171a714b58131e8bed2 (patch) | |
tree | 0f7ce85c95dcc06600611e778b654da4a24d60f6 | |
parent | 258e38b02f2a78e8cb5323a05ac8a4365a7cd532 (diff) | |
download | libgit2-b2264f45b1190a11506d1171a714b58131e8bed2.tar.gz |
repo: allow admin owned configs by admin users
Allow users in the administrator group to use git configs that are owned
by administrators.
-rw-r--r-- | src/repository.c | 5 | ||||
-rw-r--r-- | tests/repo/open.c | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/repository.c b/src/repository.c index 6119c1c70..5e1083aed 100644 --- a/src/repository.c +++ b/src/repository.c @@ -509,10 +509,13 @@ static int validate_ownership(const char *repo_path) { git_config *config = NULL; validate_ownership_data data = { repo_path, GIT_STR_INIT, false }; + git_fs_path_owner_t owner_level = + GIT_FS_PATH_OWNER_CURRENT_USER | + GIT_FS_PATH_USER_IS_ADMINISTRATOR; bool is_safe; int error; - if ((error = git_fs_path_owner_is_current_user(&is_safe, repo_path)) < 0) { + if ((error = git_fs_path_owner_is(&is_safe, repo_path, owner_level)) < 0) { if (error == GIT_ENOTFOUND) error = 0; diff --git a/tests/repo/open.c b/tests/repo/open.c index cb044a0d4..634ba59d2 100644 --- a/tests/repo/open.c +++ b/tests/repo/open.c @@ -489,6 +489,13 @@ void test_repo_open__validates_dir_ownership(void) git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR); cl_git_fail(git_repository_open(&repo, "empty_standard_repo")); +#ifdef GIT_WIN32 + /* When the user is an administrator, succeed on Windows. */ + git_fs_path__set_owner(GIT_FS_PATH_USER_IS_ADMINISTRATOR); + cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); + git_repository_free(repo); +#endif + /* When an unknown user owns the repo config, fail */ git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER); cl_git_fail(git_repository_open(&repo, "empty_standard_repo")); @@ -511,6 +518,13 @@ void test_repo_open__validates_bare_repo_ownership(void) git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR); cl_git_fail(git_repository_open(&repo, "testrepo.git")); +#ifdef GIT_WIN32 + /* When the user is an administrator, succeed on Windows. */ + git_fs_path__set_owner(GIT_FS_PATH_USER_IS_ADMINISTRATOR); + cl_git_pass(git_repository_open(&repo, "testrepo.git")); + git_repository_free(repo); +#endif + /* When an unknown user owns the repo config, fail */ git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER); cl_git_fail(git_repository_open(&repo, "testrepo.git")); |