Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set GIT_EOWNER when safe.directory is not configured #6427

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/libgit2/repository.c
Expand Up @@ -580,10 +580,14 @@ static int validate_ownership(git_repository *repo)
break;
}

if (is_safe ||
(error = validate_ownership_config(&is_safe, validation_paths[0])) < 0)
if (is_safe)
goto done;

error = validate_ownership_config(&is_safe, validation_paths[0]);
if (error < 0 && error != GIT_ENOTFOUND)
goto done;
error = 0;

if (!is_safe) {
git_error_set(GIT_ERROR_CONFIG,
"repository path '%s' is not owned by current user",
Expand Down
2 changes: 1 addition & 1 deletion tests/libgit2/repo/open.c
Expand Up @@ -543,7 +543,7 @@ void test_repo_open__can_allowlist_dirs_with_problematic_ownership(void)
cl_git_pass(cl_rename("empty_standard_repo/.gitted", "empty_standard_repo/.git"));

git_fs_path__set_owner(GIT_FS_PATH_OWNER_OTHER);
cl_git_fail(git_repository_open(&repo, "empty_standard_repo"));
cl_git_fail_with(GIT_EOWNER, git_repository_open(&repo, "empty_standard_repo"));

/* Add safe.directory options to the global configuration */
git_str_joinpath(&config_path, clar_sandbox_path(), "__global_config");
Expand Down