Skip to content

Commit 918a3ce

Browse files
committed
libexpr: Use Store::requireStoreObjectAccessor instead or toRealPath in fetch
This forces the code to go through proper abstractions instead of the raw filesystem API. This issue is evident from this reproducer: nix eval --expr 'builtins.fetchurl { url = "https://example.com"; sha256 = ""; }' --json --eval-store "dummy://?read-only=false" error: … while calling the 'fetchurl' builtin at «string»:1:1: 1| builtins.fetchurl { url = "https://example.com"; sha256 = ""; } | ^ error: opening file '/nix/store/r4f87yrl98f2m6v9z8ai2rbg4qwlcakq-example.com': No such file or directory
1 parent 69c005e commit 918a3ce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libexpr/primops/fetchTree.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,11 @@ static void fetch(
588588

589589
if (expectedHash) {
590590
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
591-
: hashFile(HashAlgorithm::SHA256, state.store->toRealPath(storePath));
591+
: hashPath(
592+
{state.store->requireStoreObjectAccessor(storePath)},
593+
FileSerialisationMethod::Flat,
594+
HashAlgorithm::SHA256)
595+
.hash;
592596
if (hash != *expectedHash) {
593597
state
594598
.error<EvalError>(

0 commit comments

Comments
 (0)