Commit d1409f48 by Wil Shipley Committed by Patrick Steinhardt

config: ignore unreadable configuration files

Modified `config_file_open()` so it returns 0 if the config file is
not readable, which happens on global config files under macOS
sandboxing (note that for some reason `access(F_OK)` DOES work with
sandboxing, but it is lying). Without this read check sandboxed
applications on macOS can not open any repository, because
`config_file_read()` will return GIT_ERROR when it cannot read the
global /Users/username/.gitconfig file, and the upper layers will
just completely abort on GIT_ERROR when attempting to load the
global config file, so no repositories can be opened.
parent 27cb4e0e
......@@ -111,6 +111,15 @@ static int config_file_open(git_config_backend *cfg, git_config_level_t level, c
if (!git_path_exists(b->file.path))
return 0;
/*
* git silently ignores configuration files that are not
* readable. We emulate that behavior. This is particularly
* important for sandboxed applications on macOS where the
* git configuration files may not be readable.
*/
if (p_access(b->file.path, R_OK) < 0)
return GIT_ENOTFOUND;
if (res < 0 || (res = config_file_read(b->entries, repo, &b->file, level, 0)) < 0) {
git_config_entries_free(b->entries);
b->entries = NULL;
......
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