libstore: refuse to serialise ancient protocols
We don't want to deal with these at all, let's stop doing so. (marking this one as the fix commit since its immediate predecessors aren't the complete fix) Fixes: https://git.lix.systems/lix-project/lix/issues/325 Change-Id: Ieea1b0b8ac0f903d1e24e5b3e63cfe12eeec119d
This commit is contained in:
parent
985ce8a865
commit
c22a7f50cb
6 changed files with 25 additions and 39 deletions
|
@ -264,14 +264,8 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||
TrustedFlag trusted, RecursiveFlag recursive, WorkerProto::Version clientVersion,
|
||||
Source & from, BufferedSink & to, WorkerProto::Op op)
|
||||
{
|
||||
WorkerProto::ReadConn rconn {
|
||||
.from = from,
|
||||
.version = clientVersion,
|
||||
};
|
||||
WorkerProto::WriteConn wconn {
|
||||
.to = to,
|
||||
.version = clientVersion,
|
||||
};
|
||||
WorkerProto::ReadConn rconn{from, clientVersion};
|
||||
WorkerProto::WriteConn wconn{to, clientVersion};
|
||||
|
||||
switch (op) {
|
||||
|
||||
|
@ -1030,10 +1024,7 @@ void processConnection(
|
|||
auto temp = trusted
|
||||
? store->isTrustedClient()
|
||||
: std::optional { NotTrusted };
|
||||
WorkerProto::WriteConn wconn {
|
||||
.to = to,
|
||||
.version = clientVersion,
|
||||
};
|
||||
WorkerProto::WriteConn wconn {to, clientVersion};
|
||||
WorkerProto::write(*store, wconn, temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,10 +68,7 @@ struct RemoteStore::Connection
|
|||
*/
|
||||
operator WorkerProto::ReadConn ()
|
||||
{
|
||||
return WorkerProto::ReadConn {
|
||||
.from = from,
|
||||
.version = daemonVersion,
|
||||
};
|
||||
return WorkerProto::ReadConn {from, daemonVersion};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,10 +81,7 @@ struct RemoteStore::Connection
|
|||
*/
|
||||
operator WorkerProto::WriteConn ()
|
||||
{
|
||||
return WorkerProto::WriteConn {
|
||||
.to = to,
|
||||
.version = daemonVersion,
|
||||
};
|
||||
return WorkerProto::WriteConn {to, daemonVersion};
|
||||
}
|
||||
|
||||
virtual ~Connection();
|
||||
|
|
|
@ -466,7 +466,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
|
|||
sink
|
||||
<< exportMagic
|
||||
<< printStorePath(info.path);
|
||||
WorkerProto::WriteConn nested { .to = sink, .version = conn->daemonVersion };
|
||||
WorkerProto::WriteConn nested { sink, conn->daemonVersion };
|
||||
WorkerProto::write(*this, nested, info.references);
|
||||
sink
|
||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||
|
@ -511,14 +511,13 @@ void RemoteStore::addMultipleToStore(
|
|||
RepairFlag repair,
|
||||
CheckSigsFlag checkSigs)
|
||||
{
|
||||
auto remoteVersion = getProtocol();
|
||||
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
sink << pathsToCopy.size();
|
||||
for (auto & [pathInfo, pathSource] : pathsToCopy) {
|
||||
WorkerProto::Serialise<ValidPathInfo>::write(*this,
|
||||
WorkerProto::WriteConn {
|
||||
.to = sink,
|
||||
.version = 16,
|
||||
},
|
||||
WorkerProto::WriteConn {sink, remoteVersion},
|
||||
pathInfo);
|
||||
pathSource->drainInto(sink);
|
||||
}
|
||||
|
|
|
@ -368,15 +368,14 @@ void Store::addMultipleToStore(
|
|||
RepairFlag repair,
|
||||
CheckSigsFlag checkSigs)
|
||||
{
|
||||
auto remoteVersion = getProtocol();
|
||||
|
||||
auto expected = readNum<uint64_t>(source);
|
||||
for (uint64_t i = 0; i < expected; ++i) {
|
||||
// FIXME we should not be using the worker protocol here, let
|
||||
// alone the worker protocol with a hard-coded version!
|
||||
// FIXME we should not be using the worker protocol here at all!
|
||||
auto info = WorkerProto::Serialise<ValidPathInfo>::read(*this,
|
||||
WorkerProto::ReadConn {
|
||||
.from = source,
|
||||
.version = 16,
|
||||
});
|
||||
WorkerProto::ReadConn {source, remoteVersion}
|
||||
);
|
||||
info.ultimate = false;
|
||||
addToStore(info, source, repair, checkSigs);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,10 @@ struct WorkerProto
|
|||
struct ReadConn {
|
||||
Source & from;
|
||||
Version version;
|
||||
|
||||
ReadConn(Source & from, Version version) : from(from), version(version) {
|
||||
assert(version >= MIN_SUPPORTED_WORKER_PROTO_VERSION);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -81,6 +85,10 @@ struct WorkerProto
|
|||
struct WriteConn {
|
||||
Sink & to;
|
||||
Version version;
|
||||
|
||||
WriteConn(Sink & to, Version version) : to(to), version(version) {
|
||||
assert(version >= MIN_SUPPORTED_WORKER_PROTO_VERSION);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,10 +39,8 @@ public:
|
|||
StringSource from { expected };
|
||||
Proto::template Serialise<T>::read(
|
||||
*LibStoreTest::store,
|
||||
typename Proto::ReadConn {
|
||||
.from = from,
|
||||
.version = version,
|
||||
});
|
||||
typename Proto::ReadConn {from, version}
|
||||
);
|
||||
});
|
||||
|
||||
ASSERT_EQ(got, value);
|
||||
|
@ -60,10 +58,7 @@ public:
|
|||
StringSink to;
|
||||
Proto::write(
|
||||
*LibStoreTest::store,
|
||||
typename Proto::WriteConn {
|
||||
.to = to,
|
||||
.version = version,
|
||||
},
|
||||
typename Proto::WriteConn {to, version},
|
||||
value);
|
||||
|
||||
if (testAccept())
|
||||
|
|
Loading…
Reference in a new issue