]> git.proxmox.com Git - libgit2.git/blobdiff - src/sysdir.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / src / sysdir.c
index e07ba7199d8ad77f615760966af5353bf9c1d598..6dc78c8fd997dd90c2d0c66e4c29bcdf4dd60bef 100644 (file)
@@ -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);
@@ -206,25 +216,6 @@ int git_sysdir_get(const git_buf **out, git_sysdir_t which)
        return 0;
 }
 
-int git_sysdir_get_str(
-       char *out,
-       size_t outlen,
-       git_sysdir_t which)
-{
-       const git_buf *path = NULL;
-
-       GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
-       GIT_ERROR_CHECK_ERROR(git_sysdir_get(&path, which));
-
-       if (!out || path->size >= outlen) {
-               git_error_set(GIT_ERROR_NOMEMORY, "buffer is too short for the path");
-               return GIT_EBUFS;
-       }
-
-       git_buf_copy_cstr(out, outlen, path);
-       return 0;
-}
-
 #define PATH_MAGIC "$PATH"
 
 int git_sysdir_set(git_sysdir_t which, const char *search_path)
@@ -307,8 +298,11 @@ static int git_sysdir_find_in_dirlist(
        }
 
 done:
+       if (name)
+               git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
+       else
+               git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label);
        git_buf_dispose(path);
-       git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
        return GIT_ENOTFOUND;
 }