Commit b2264f45 by Edward Thomson

repo: allow admin owned configs by admin users

Allow users in the administrator group to use git configs that are owned
by administrators.
parent 258e38b0
...@@ -509,10 +509,13 @@ static int validate_ownership(const char *repo_path) ...@@ -509,10 +509,13 @@ static int validate_ownership(const char *repo_path)
{ {
git_config *config = NULL; git_config *config = NULL;
validate_ownership_data data = { repo_path, GIT_STR_INIT, false }; 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; bool is_safe;
int error; 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) if (error == GIT_ENOTFOUND)
error = 0; error = 0;
......
...@@ -489,6 +489,13 @@ void test_repo_open__validates_dir_ownership(void) ...@@ -489,6 +489,13 @@ void test_repo_open__validates_dir_ownership(void)
git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR); git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR);
cl_git_fail(git_repository_open(&repo, "empty_standard_repo")); 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 */ /* When an unknown user owns the repo config, fail */
git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER); git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER);
cl_git_fail(git_repository_open(&repo, "empty_standard_repo")); cl_git_fail(git_repository_open(&repo, "empty_standard_repo"));
...@@ -511,6 +518,13 @@ void test_repo_open__validates_bare_repo_ownership(void) ...@@ -511,6 +518,13 @@ void test_repo_open__validates_bare_repo_ownership(void)
git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR); git_fs_path__set_owner(GIT_FS_PATH_OWNER_ADMINISTRATOR);
cl_git_fail(git_repository_open(&repo, "testrepo.git")); 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 */ /* When an unknown user owns the repo config, fail */
git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER); git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER);
cl_git_fail(git_repository_open(&repo, "testrepo.git")); cl_git_fail(git_repository_open(&repo, "testrepo.git"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment