libstore: always load localstore public keys

it's dirt cheap to do on average, the complexity of sticking this under
a lock is not worth it. we may want to split this into not loading both
kinds of keys since private keys are rarely needed, but since only root
or the daemon are likely to have access to them it shouldn't be urgent.

Change-Id: I691aed100c9cc4ca32ab7e99a37b5be7d5c25e93
This commit is contained in:
eldritch horrors
2025-01-20 20:00:22 +00:00
parent 7720e6c43e
commit ba728e46be
2 changed files with 5 additions and 16 deletions
+3 -10
View File
@@ -173,6 +173,7 @@ void migrateCASchema(SQLite& db, Path schemaPath, AutoCloseFD& lockFd)
LocalStore::LocalStore(LocalStoreConfig config)
: Store(config)
, config_(std::move(config))
, publicKeys(getDefaultPublicKeys())
, dbDir(config_.stateDir + "/db")
, linksDir(config_.realStoreDir + "/.links")
, reservedSpacePath(dbDir + "/reserved")
@@ -1181,22 +1182,14 @@ void LocalStore::invalidatePath(State & state, const StorePath & path)
}
}
const PublicKeys & LocalStore::getPublicKeys()
{
auto state(_state.lock());
if (!state->publicKeys)
state->publicKeys = std::make_unique<PublicKeys>(getDefaultPublicKeys());
return *state->publicKeys;
}
bool LocalStore::pathInfoIsUntrusted(const ValidPathInfo & info)
{
return config_.requireSigs && !info.checkSignatures(*this, getPublicKeys());
return config_.requireSigs && !info.checkSignatures(*this, publicKeys);
}
bool LocalStore::realisationIsUntrusted(const Realisation & realisation)
{
return config_.requireSigs && !realisation.checkSignatures(getPublicKeys());
return config_.requireSigs && !realisation.checkSignatures(publicKeys);
}
void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
+2 -6
View File
@@ -80,6 +80,8 @@ private:
*/
AutoCloseFD globalLock;
const PublicKeys publicKeys;
struct State
{
/**
@@ -110,8 +112,6 @@ private:
* point in starting a new GC.
*/
uint64_t availAfterGC = std::numeric_limits<uint64_t>::max();
std::unique_ptr<PublicKeys> publicKeys;
};
Sync<State> _state;
@@ -129,10 +129,6 @@ public:
LocalStoreConfig & config() override { return config_; }
const LocalStoreConfig & config() const override { return config_; }
private:
const PublicKeys & getPublicKeys();
protected:
/**