From cb1ffb7789365d77e310a267dcc63c7518127045 Mon Sep 17 00:00:00 2001 From: Madeline Haraj Date: Thu, 5 Aug 2021 21:22:36 -0400 Subject: [PATCH 1/2] Use the store path as the context of the result of fetchTree, not the real path --- src/libexpr/primops/fetchTree.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 730db84ed..872ebd83c 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -229,20 +229,21 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v, ? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).first.storePath : fetchers::downloadFile(state.store, *url, name, (bool) expectedHash).storePath; - auto path = state.store->toRealPath(storePath); + auto realPath = state.store->toRealPath(storePath); if (expectedHash) { auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash - : hashFile(htSHA256, path); + : hashFile(htSHA256, realPath); if (hash != *expectedHash) throw Error((unsigned int) 102, "hash mismatch in file downloaded from '%s':\n specified: %s\n got: %s", *url, expectedHash->to_string(Base32, true), hash.to_string(Base32, true)); } if (state.allowedPaths) - state.allowedPaths->insert(path); + state.allowedPaths->insert(realPath); + auto path = state.store->printStorePath(storePath); mkString(v, path, PathSet({path})); } From d56ddbb99965dc46cb80b05857588624c249aba6 Mon Sep 17 00:00:00 2001 From: Madeline Haraj Date: Fri, 6 Aug 2021 12:36:03 -0400 Subject: [PATCH 2/2] Fix disabled case in local store test --- tests/local-store.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/local-store.sh b/tests/local-store.sh index 4ec3d64b0..0247346f1 100644 --- a/tests/local-store.sh +++ b/tests/local-store.sh @@ -15,6 +15,5 @@ PATH1=$(nix path-info --store ./x $CORRECT_PATH) PATH2=$(nix path-info --store "$PWD/x" $CORRECT_PATH) [ $CORRECT_PATH == $PATH2 ] -# FIXME we could also test the query parameter version: -# PATH3=$(nix path-info --store "local?store=$PWD/x" $CORRECT_PATH) -# [ $CORRECT_PATH == $PATH3 ] +PATH3=$(nix path-info --store "local?root=$PWD/x" $CORRECT_PATH) +[ $CORRECT_PATH == $PATH3 ]