From 920f5fd4dda16374a6c25ae91c5f17ed749c067c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri, 22 May 2015 12:18:23 +0200 Subject: Fix import-from-derivation in restricted eval mode This relaxes restricted mode to allow access to anything in the store. In the future, it would be better to allow access to only paths that have been constructed in the current evaluation (so a hard-coded /nix/store/blabla in a Nix expression would still be rejected). However, note that reading /nix/store itself is still rejected, so you can't use this so get access to things you don't know about. --- src/libexpr/eval.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 301f991b7ab9..88cf9f45342c 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -292,10 +292,17 @@ Path EvalState::checkSourcePath(const Path & path_) if (path == i.second || isInDir(path, i.second)) return path; + /* To support import-from-derivation, allow access to anything in + the store. FIXME: only allow access to paths that have been + constructed by this evaluation. */ + if (isInStore(path)) return path; + +#if 0 /* Hack to support the chroot dependencies of corepkgs (see corepkgs/config.nix.in). */ if (path == settings.nixPrefix && isStorePath(settings.nixPrefix)) return path; +#endif throw RestrictedPathError(format("access to path ‘%1%’ is forbidden in restricted mode") % path_); } -- cgit 1.4.1