summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-02 07:51:02 +0200
committerGitHub <noreply@github.com>2019-08-02 07:51:02 +0200
commitd588de7cd624031bb0a641c12fdfdfc8cf9164ff (patch)
treecb6856e918c33e381a06257c4578e6496ed49755
parentac171542a6d2e6ad39f2e778c4ca26604b187d04 (diff)
parent952fbbfbfc624c66405e4ab26e0588d3eaddc5e7 (diff)
downloadlibgit2-d588de7cd624031bb0a641c12fdfdfc8cf9164ff.tar.gz
Merge pull request #5191 from eaigner/master
config: check if we are running in a sandboxed environment
-rw-r--r--src/sysdir.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sysdir.c b/src/sysdir.c
index e07ba7199..9e86dc88c 100644
--- a/src/sysdir.c
+++ b/src/sysdir.c
@@ -82,15 +82,25 @@ static int git_sysdir_guess_global_dirs(git_buf *out)
#else
int error;
uid_t uid, euid;
+ const char *sandbox_id;
uid = getuid();
euid = geteuid();
+ /**
+ * If APP_SANDBOX_CONTAINER_ID is set, we are running in a
+ * sandboxed environment on macOS.
+ */
+ sandbox_id = getenv("APP_SANDBOX_CONTAINER_ID");
+
/*
* In case we are running setuid, use the configuration
* of the effective user.
+ *
+ * If we are running in a sandboxed environment on macOS,
+ * we have to get the HOME dir from the password entry file.
*/
- if (uid == euid)
+ if (!sandbox_id && uid == euid)
error = git__getenv(out, "HOME");
else
error = get_passwd_home(out, euid);