libstore: asyncify Store::isTrustedClient
Change-Id: Iabf4aa6bf04e23179f03f5d0055560970809773e
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -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)}; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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)};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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)};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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"}; }
|
||||
|
||||
@@ -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
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user