Skip to content

Commit d588de7

Browse files
authored
Merge pull request libgit2#5191 from eaigner/master
config: check if we are running in a sandboxed environment
2 parents ac17154 + 952fbbf commit d588de7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/sysdir.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,25 @@ static int git_sysdir_guess_global_dirs(git_buf *out)
8282
#else
8383
int error;
8484
uid_t uid, euid;
85+
const char *sandbox_id;
8586

8687
uid = getuid();
8788
euid = geteuid();
8889

90+
/**
91+
* If APP_SANDBOX_CONTAINER_ID is set, we are running in a
92+
* sandboxed environment on macOS.
93+
*/
94+
sandbox_id = getenv("APP_SANDBOX_CONTAINER_ID");
95+
8996
/*
9097
* In case we are running setuid, use the configuration
9198
* of the effective user.
99+
*
100+
* If we are running in a sandboxed environment on macOS,
101+
* we have to get the HOME dir from the password entry file.
92102
*/
93-
if (uid == euid)
103+
if (!sandbox_id && uid == euid)
94104
error = git__getenv(out, "HOME");
95105
else
96106
error = get_passwd_home(out, euid);

0 commit comments

Comments
 (0)