libstore: weaken the top-level fallback temp dir to 0755 for macOS

Under macOS, the first level of directory has actually mode 0755 instead
of 0700 as macOS often do not possess the right primitives to chroot
inside of these directories, leading to
https://github.com/NixOS/nix/pull/11031.

Thanks to Emily for the heads-up on this type of matter.

Change-Id: I9d4e53717f61c9d573ff176f820610612804fbc3
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2025-06-28 17:37:43 +02:00
parent ac80a11300
commit 33122e79df
+11 -2
View File
@@ -459,8 +459,17 @@ try {
auto globalTmp = defaultTempDir();
createDirs(globalTmp);
auto nixBuildsTmp =
createTempDir(globalTmp, fmt("nix-builds-%s", geteuid()), false, false, 0700);
#if __APPLE__
/* macOS filesystem namespacing does not exist, to avoid breaking builds, we need to weaken
* the mode bits on the top-level directory. This avoids issues like
* https://github.com/NixOS/nix/pull/11031. */
constexpr int toplevelDirMode = 0755;
#else
constexpr int toplevelDirMode = 0700;
#endif
auto nixBuildsTmp = createTempDir(
globalTmp, fmt("nix-builds-%s", geteuid()), false, false, toplevelDirMode
);
warn(
"Failed to use the system-wide build directory '%s', falling back to a temporary "
"directory inside '%s'",