Skip to content

Commit c527fe0

Browse files
authored
Merge pull request NixOS#12347 from DeterminateSystems/fix-12339
EvalState::resolveLookupPathPath(): Call resolveSymlinks() before pathExists()
2 parents 4166f59 + 00d9e7e commit c527fe0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libexpr/eval.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,7 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
31143114
}
31153115
}
31163116

3117-
if (path.pathExists())
3117+
if (path.resolveSymlinks().pathExists())
31183118
return finish(std::move(path));
31193119
else {
31203120
logWarning({

tests/functional/restricted.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ nix-instantiate --restrict-eval ./simple.nix -I src1=./simple.nix -I src2=./conf
2323
(! nix-instantiate --restrict-eval --eval -E 'builtins.readFile ./simple.nix')
2424
nix-instantiate --restrict-eval --eval -E 'builtins.readFile ./simple.nix' -I src=../..
2525

26-
expectStderr 1 nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' | grepQuiet "was not found in the Nix search path"
26+
expectStderr 1 nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' | grepQuiet "forbidden in restricted mode"
2727
nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' -I src=.
2828

2929
p=$(nix eval --raw --expr "builtins.fetchurl file://${_NIX_TEST_SOURCE_DIR}/restricted.sh" --impure --restrict-eval --allowed-uris "file://${_NIX_TEST_SOURCE_DIR}")

0 commit comments

Comments
 (0)