File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -992,10 +992,21 @@ void DerivationBuilderImpl::startBuilder()
992992 i.pop_back ();
993993 }
994994 size_t p = i.find (' =' );
995- if (p == std::string::npos)
996- pathsInChroot[i] = {i, optional};
997- else
998- pathsInChroot[i.substr (0 , p)] = {i.substr (p + 1 ), optional};
995+
996+ std::string inside, outside;
997+ if (p == std::string::npos) {
998+ inside = i;
999+ outside = i;
1000+ } else {
1001+ inside = i.substr (0 , p);
1002+ outside = i.substr (p + 1 );
1003+ }
1004+
1005+ if (!optional && !maybeLstat (outside)) {
1006+ throw SysError (" path '%s' is configured as part of the `sandbox-paths` option, but is inaccessible" , outside);
1007+ }
1008+
1009+ pathsInChroot[inside] = {outside, optional};
9991010 }
10001011 if (hasPrefix (store.storeDir , tmpDirInSandbox))
10011012 {
Original file line number Diff line number Diff line change @@ -96,3 +96,8 @@ nix-sandbox-build symlink-derivation.nix -A test_sandbox_paths \
9696 --option extra-sandbox-paths " /dir=$TEST_ROOT " \
9797 --option extra-sandbox-paths " /symlinkDir=$symlinkDir " \
9898 --option extra-sandbox-paths " /symlink=$symlinkcert "
99+
100+ # Nonexistent sandbox paths should error early in the build process
101+ expectStderr 1 nix-sandbox-build --option extra-sandbox-paths ' /does-not-exist' \
102+ -E ' with import ' " ${config_nix} " ' ; mkDerivation { name = "trivial"; buildCommand = "echo > $out"; }' |
103+ grepQuiet " path '/does-not-exist' is configured as part of the \` sandbox-paths\` option, but is inaccessible"
You can’t perform that action at this time.
0 commit comments