libstore: asyncify Store::isTrustedClient

Change-Id: Iabf4aa6bf04e23179f03f5d0055560970809773e
This commit is contained in:
eldritch horrors
2025-03-05 16:42:11 +01:00
parent 12e9b8da0f
commit 4cd14a30bc
15 changed files with 28 additions and 26 deletions
+1 -1
View File
@@ -305,7 +305,7 @@ connected:
// stores), we assume we are. This is necessary for backwards
// compat.
bool trustedOrLegacy = ({
std::optional trusted = sshStore->isTrustedClient();
std::optional trusted = aio.blockOn(sshStore->isTrustedClient());
!trusted || *trusted;
});
+2 -2
View File
@@ -1276,8 +1276,8 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
return {result::current_exception()};
}
std::optional<TrustedFlag> isTrustedClient() override
{ return NotTrusted; }
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{ return {result::success(NotTrusted)}; }
};
+1 -1
View File
@@ -1057,7 +1057,7 @@ void processConnection(
// We and the underlying store both need to trust the client for
// it to be trusted.
auto temp = trusted
? store->isTrustedClient()
? aio.blockOn(store->isTrustedClient())
: std::optional { NotTrusted };
WorkerProto::WriteConn wconn {clientVersion};
to << WorkerProto::write(*store, wconn, temp);
+2 -2
View File
@@ -42,9 +42,9 @@ struct DummyStore final : public Store
/**
* The dummy store is incapable of *not* trusting! :)
*/
virtual std::optional<TrustedFlag> isTrustedClient() override
virtual kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return Trusted;
return {result::success(Trusted)};
}
static std::set<std::string> uriSchemes() {
+2 -2
View File
@@ -172,9 +172,9 @@ protected:
*
* \todo try to expose our HTTP authentication status.
*/
std::optional<TrustedFlag> isTrustedClient() override
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return std::nullopt;
return {result::success(std::nullopt)};
}
};
+2 -2
View File
@@ -451,9 +451,9 @@ public:
* The legacy ssh protocol doesn't support checking for trusted-user.
* Try using ssh-ng:// instead if you want to know.
*/
std::optional<TrustedFlag> isTrustedClient() override
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return std::nullopt;
return {result::success(std::nullopt)};
}
std::shared_ptr<const Realisation> queryRealisationUncached(const DrvOutput &) override
+2 -2
View File
@@ -99,9 +99,9 @@ protected:
return paths;
}
std::optional<TrustedFlag> isTrustedClient() override
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return Trusted;
return {result::success(Trusted)};
}
};
+2 -2
View File
@@ -1745,9 +1745,9 @@ kj::Promise<Result<unsigned int>> LocalStore::getProtocol()
return {result::success(PROTOCOL_VERSION)};
}
std::optional<TrustedFlag> LocalStore::isTrustedClient()
kj::Promise<Result<std::optional<TrustedFlag>>> LocalStore::isTrustedClient()
{
return Trusted;
return {result::success(Trusted)};
}
+1 -1
View File
@@ -300,7 +300,7 @@ public:
kj::Promise<Result<unsigned int>> getProtocol() override;
std::optional<TrustedFlag> isTrustedClient() override;
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override;
void addSignatures(const StorePath & storePath, const StringSet & sigs) override;
+6 -4
View File
@@ -952,11 +952,13 @@ try {
co_return result::current_exception();
}
std::optional<TrustedFlag> RemoteStore::isTrustedClient()
{
kj::Promise<Result<std::optional<TrustedFlag>>> RemoteStore::isTrustedClient()
try {
auto conn(getConnection());
return conn->remoteTrustsUs;
}
co_return conn->remoteTrustsUs;
} catch (...) {
co_return result::current_exception();}
RemoteStore::Connection::~Connection()
+1 -1
View File
@@ -169,7 +169,7 @@ public:
kj::Promise<Result<unsigned int>> getProtocol() override;
std::optional<TrustedFlag> isTrustedClient() override;
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override;
struct Connection;
+2 -2
View File
@@ -526,9 +526,9 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
*
* \todo try to expose our S3 authentication status.
*/
std::optional<TrustedFlag> isTrustedClient() override
kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return std::nullopt;
return {result::success(std::nullopt)};
}
static std::set<std::string> uriSchemes() { return {"s3"}; }
+1 -1
View File
@@ -880,7 +880,7 @@ public:
* @note This is the opposite of the StoreConfig::isTrusted
* store setting. That is about whether *we* trust the store.
*/
virtual std::optional<TrustedFlag> isTrustedClient() = 0;
virtual kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() = 0;
virtual Path toRealPath(const Path & storePath)
+1 -1
View File
@@ -146,7 +146,7 @@ struct CmdDoctor : StoreCommand
void checkTrustedUser(ref<Store> store)
{
auto trustedMay = store->isTrustedClient();
auto trustedMay = aio().blockOn(store->isTrustedClient());
std::string_view trustedness = trustedMay ? (*trustedMay ? "trusted" : "not trusted") : "unknown trust";
checkInfo(fmt("You are %s by store uri: %s", trustedness, store->getUri()));
}
+2 -2
View File
@@ -28,7 +28,7 @@ struct CmdPingStore : StoreCommand, MixJSON
aio().blockOn(store->connect());
if (auto version = store->getVersion())
notice("Version: %s", *version);
if (auto trusted = store->isTrustedClient())
if (auto trusted = aio().blockOn(store->isTrustedClient()))
notice("Trusted: %s", *trusted);
} else {
nlohmann::json res;
@@ -40,7 +40,7 @@ struct CmdPingStore : StoreCommand, MixJSON
aio().blockOn(store->connect());
if (auto version = store->getVersion())
res["version"] = *version;
if (auto trusted = store->isTrustedClient())
if (auto trusted = aio().blockOn(store->isTrustedClient()))
res["trusted"] = *trusted;
}
}