Skip to content

Commit

Permalink
Fix #1921
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Apr 13, 2018
1 parent 4fd28be commit d34fa2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libstore/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3687,7 +3687,7 @@ void SubstitutionGoal::tryNext()
only after we've downloaded the path. */
if (worker.store.requireSigs
&& !sub->isTrusted
&& !info->checkSignatures(worker.store, worker.store.publicKeys))
&& !info->checkSignatures(worker.store, worker.store.getPublicKeys()))
{
printError("warning: substituter '%s' does not have a valid signature for path '%s'",
sub->getUri(), storePath);
Expand Down
12 changes: 10 additions & 2 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ LocalStore::LocalStore(const Params & params)
, trashDir(realStoreDir + "/trash")
, tempRootsDir(stateDir + "/temproots")
, fnTempRoots(fmt("%s/%d", tempRootsDir, getpid()))
, publicKeys(getDefaultPublicKeys())
{
auto state(_state.lock());

Expand Down Expand Up @@ -964,12 +963,21 @@ void LocalStore::invalidatePath(State & state, const Path & path)
}


const PublicKeys & LocalStore::getPublicKeys()
{
auto state(_state.lock());
if (!state->publicKeys)
state->publicKeys = std::make_unique<PublicKeys>(getDefaultPublicKeys());
return *state->publicKeys;
}


void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
{
assert(info.narHash);

if (requireSigs && checkSigs && !info.checkSignatures(*this, publicKeys))
if (requireSigs && checkSigs && !info.checkSignatures(*this, getPublicKeys()))
throw Error("cannot add path '%s' because it lacks a valid signature", info.path);

addTempRoot(info.path);
Expand Down
4 changes: 3 additions & 1 deletion src/libstore/local-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ private:
minFree but not much below availAfterGC, then there is no
point in starting a new GC. */
uint64_t availAfterGC = std::numeric_limits<uint64_t>::max();

std::unique_ptr<PublicKeys> publicKeys;
};

Sync<State, std::recursive_mutex> _state;
Expand All @@ -100,7 +102,7 @@ private:
settings.requireSigs,
"require-sigs", "whether store paths should have a trusted signature on import"};

PublicKeys publicKeys;
const PublicKeys & getPublicKeys();

public:

Expand Down

0 comments on commit d34fa2b

Please sign in to comment.