mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Merge pull request #88 from DeterminateSystems/fh-846-improve-nix-error-when-sandbox-path-doesnt-exist
libstore/unix/derivation-builder: error earlier when sandbox path is inaccessible
This commit is contained in:
commit
e98cad60b2
2 changed files with 20 additions and 4 deletions
|
|
@ -992,10 +992,21 @@ void DerivationBuilderImpl::startBuilder()
|
||||||
i.pop_back();
|
i.pop_back();
|
||||||
}
|
}
|
||||||
size_t p = i.find('=');
|
size_t p = i.find('=');
|
||||||
if (p == std::string::npos)
|
|
||||||
pathsInChroot[i] = {i, optional};
|
std::string inside, outside;
|
||||||
else
|
if (p == std::string::npos) {
|
||||||
pathsInChroot[i.substr(0, p)] = {i.substr(p + 1), optional};
|
inside = i;
|
||||||
|
outside = i;
|
||||||
|
} else {
|
||||||
|
inside = i.substr(0, p);
|
||||||
|
outside = i.substr(p + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!optional && !maybeLstat(outside)) {
|
||||||
|
throw SysError("path '%s' is configured as part of the `sandbox-paths` option, but is inaccessible", outside);
|
||||||
|
}
|
||||||
|
|
||||||
|
pathsInChroot[inside] = {outside, optional};
|
||||||
}
|
}
|
||||||
if (hasPrefix(store.storeDir, tmpDirInSandbox))
|
if (hasPrefix(store.storeDir, tmpDirInSandbox))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -96,3 +96,8 @@ nix-sandbox-build symlink-derivation.nix -A test_sandbox_paths \
|
||||||
--option extra-sandbox-paths "/dir=$TEST_ROOT" \
|
--option extra-sandbox-paths "/dir=$TEST_ROOT" \
|
||||||
--option extra-sandbox-paths "/symlinkDir=$symlinkDir" \
|
--option extra-sandbox-paths "/symlinkDir=$symlinkDir" \
|
||||||
--option extra-sandbox-paths "/symlink=$symlinkcert"
|
--option extra-sandbox-paths "/symlink=$symlinkcert"
|
||||||
|
|
||||||
|
# Nonexistent sandbox paths should error early in the build process
|
||||||
|
expectStderr 1 nix-sandbox-build --option extra-sandbox-paths '/does-not-exist' \
|
||||||
|
-E 'with import '"${config_nix}"'; mkDerivation { name = "trivial"; buildCommand = "echo > $out"; }' |
|
||||||
|
grepQuiet "path '/does-not-exist' is configured as part of the \`sandbox-paths\` option, but is inaccessible"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue