1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 11:41:15 +02:00

Fix the error when accessing a forbidden path in pure eval

If we’re in pure eval mode, then tell that in the error message rather
than (wrongly) speaking about restricted mode.

Fix https://github.com/NixOS/nix/issues/5611
This commit is contained in:
regnat 2021-11-25 14:48:01 +01:00
parent 1f7584d24c
commit c47027f3a1
2 changed files with 10 additions and 3 deletions

View file

@ -519,8 +519,12 @@ Path EvalState::checkSourcePath(const Path & path_)
}
}
if (!found)
throw RestrictedPathError("access to absolute path '%1%' is forbidden in restricted mode", abspath);
if (!found) {
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%", abspath, modeInformation);
}
/* Resolve symlinks. */
debug(format("checking access to '%s'") % abspath);