vendor/libgit2/src/sysdir.c in rugged-0.28.4.1 vs vendor/libgit2/src/sysdir.c in rugged-0.28.5

- old
+ new

@@ -80,18 +80,28 @@ #ifdef GIT_WIN32 return git_win32__find_global_dirs(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); if (error == GIT_ENOTFOUND) {