libstore/build: adjust setupConfiguredCertificateAuthority

Always use tmpDir on darwin. Call setupConfiguredCertificateAuthority even if useChroot = 1 on non-linux.
Even though macOS builds are not executed in a chroot, enabling the sandbox
sets `useChroot = 1`. Basically, useChroot is set when the sandbox is enabled,
not really when a chroot build is executed

Change-Id: I8d4c1e617abcc05dfabd998a8ce94bb11587f9d1
This commit is contained in:
WeetHet
2025-08-18 13:08:42 +00:00
committed by Stanislav Alekseev
parent ce6dcf18d6
commit 1f47ecef4e
+13 -10
View File
@@ -911,7 +911,15 @@ void LocalDerivationGoal::setupConfiguredCertificateAuthority()
{
if (settings.caFile != "") {
if (pathAccessible(settings.caFile)) {
auto prefix = useChroot ? chrootRootDir : tmpDir;
auto prefix = useChroot ?
#if __linux__
chrootRootDir
#elif __APPLE__
tmpDir
#else
#error "Your platform has no known behavior under `useChroot` flag"
#endif
: tmpDir;
debug(
"rendering visible configured CA '%s' in the builder (prefix directory: '%s')",
settings.caFile,
@@ -1102,6 +1110,10 @@ void LocalDerivationGoal::runChild()
} catch (SysError &) { }
}
if (!derivationType->isSandboxed()) {
setupConfiguredCertificateAuthority();
}
#if __linux__
if (useChroot) {
@@ -1242,8 +1254,6 @@ void LocalDerivationGoal::runChild()
"non-functional."
);
}
setupConfiguredCertificateAuthority();
}
for (auto & i : ss) pathsInChroot.emplace(i, i);
@@ -1399,13 +1409,6 @@ void LocalDerivationGoal::runChild()
}
#endif
if (!useChroot) {
/* When chroot is not used, FODs still requires a CA to be available as well. */
if (!derivationType->isSandboxed()) {
setupConfiguredCertificateAuthority();
}
}
if (chdir(tmpDirInSandbox.c_str()) == -1)
throw SysError("changing into '%1%'", tmpDir);