Skip to content

Commit 6151fe5

Browse files
committed
libstore/unix/derivation-builder: error earlier when sandbox path is inaccessible
1 parent 2a96ae2 commit 6151fe5

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/libstore/unix/build/derivation-builder.cc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,24 @@ 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+
auto maybeSt = maybeLstat(outside);
1006+
if (!maybeSt) {
1007+
if (!optional) {
1008+
throw SysError("path '%s' is configured as part of the `sandbox-paths` option, but is inaccessible", outside);
1009+
}
1010+
}
1011+
1012+
pathsInChroot[inside] = {outside, optional};
9991013
}
10001014
if (hasPrefix(store.storeDir, tmpDirInSandbox))
10011015
{

0 commit comments

Comments
 (0)