mirror of
https://github.com/NixOS/nix
synced 2025-07-03 22:51:47 +02:00
Fix showing an appropriate RestrictedPathError
This commit is contained in:
parent
c1a202c348
commit
1970d6db12
4 changed files with 29 additions and 11 deletions
|
@ -461,10 +461,18 @@ EvalState::EvalState(
|
|||
, sPrefix(symbols.create("prefix"))
|
||||
, repair(NoRepair)
|
||||
, emptyBindings(0)
|
||||
, rootFS(makeFSInputAccessor(CanonPath::root,
|
||||
, rootFS(
|
||||
makeFSInputAccessor(
|
||||
CanonPath::root,
|
||||
evalSettings.restrictEval || evalSettings.pureEval
|
||||
? std::optional<std::set<CanonPath>>(std::set<CanonPath>())
|
||||
: std::nullopt))
|
||||
: std::nullopt,
|
||||
[](const CanonPath & path) -> RestrictedPathError {
|
||||
auto modeInformation = evalSettings.pureEval
|
||||
? "in pure eval mode (use '--impure' to override)"
|
||||
: "in restricted mode";
|
||||
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
||||
}))
|
||||
, corepkgsFS(makeMemoryInputAccessor())
|
||||
, store(store)
|
||||
, buildStore(buildStore ? buildStore : store)
|
||||
|
|
|
@ -20,7 +20,6 @@ MakeError(Abort, EvalError);
|
|||
MakeError(TypeError, EvalError);
|
||||
MakeError(UndefinedVarError, Error);
|
||||
MakeError(MissingArgumentError, EvalError);
|
||||
MakeError(RestrictedPathError, Error);
|
||||
|
||||
|
||||
/* Position objects. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue