mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Remove support for daemon protocol version < 18
Version 18 was introduced in November 2016 (4b8f1b0ec0).
This commit is contained in:
parent
7658f00bb1
commit
137a55122c
2 changed files with 74 additions and 148 deletions
|
|
@ -572,21 +572,19 @@ static void performOp(
|
||||||
case WorkerProto::Op::BuildPaths: {
|
case WorkerProto::Op::BuildPaths: {
|
||||||
auto drvs = WorkerProto::Serialise<DerivedPaths>::read(*store, rconn);
|
auto drvs = WorkerProto::Serialise<DerivedPaths>::read(*store, rconn);
|
||||||
BuildMode mode = bmNormal;
|
BuildMode mode = bmNormal;
|
||||||
if (GET_PROTOCOL_MINOR(conn.protoVersion) >= 15) {
|
mode = WorkerProto::Serialise<BuildMode>::read(*store, rconn);
|
||||||
mode = WorkerProto::Serialise<BuildMode>::read(*store, rconn);
|
|
||||||
|
|
||||||
/* Repairing is not atomic, so disallowed for "untrusted"
|
/* Repairing is not atomic, so disallowed for "untrusted"
|
||||||
clients.
|
clients.
|
||||||
|
|
||||||
FIXME: layer violation in this message: the daemon code (i.e.
|
FIXME: layer violation in this message: the daemon code (i.e.
|
||||||
this file) knows whether a client/connection is trusted, but it
|
this file) knows whether a client/connection is trusted, but it
|
||||||
does not how how the client was authenticated. The mechanism
|
does not how how the client was authenticated. The mechanism
|
||||||
need not be getting the UID of the other end of a Unix Domain
|
need not be getting the UID of the other end of a Unix Domain
|
||||||
Socket.
|
Socket.
|
||||||
*/
|
*/
|
||||||
if (mode == bmRepair && !trusted)
|
if (mode == bmRepair && !trusted)
|
||||||
throw Error("repairing is not allowed because you are not in 'trusted-users'");
|
throw Error("repairing is not allowed because you are not in 'trusted-users'");
|
||||||
}
|
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
store->buildPaths(drvs, mode);
|
store->buildPaths(drvs, mode);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
|
|
@ -805,13 +803,11 @@ static void performOp(
|
||||||
clientSettings.buildCores = readInt(conn.from);
|
clientSettings.buildCores = readInt(conn.from);
|
||||||
clientSettings.useSubstitutes = readInt(conn.from);
|
clientSettings.useSubstitutes = readInt(conn.from);
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn.protoVersion) >= 12) {
|
unsigned int n = readInt(conn.from);
|
||||||
unsigned int n = readInt(conn.from);
|
for (unsigned int i = 0; i < n; i++) {
|
||||||
for (unsigned int i = 0; i < n; i++) {
|
auto name = readString(conn.from);
|
||||||
auto name = readString(conn.from);
|
auto value = readString(conn.from);
|
||||||
auto value = readString(conn.from);
|
clientSettings.overrides.emplace(name, value);
|
||||||
clientSettings.overrides.emplace(name, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
|
|
@ -876,19 +872,12 @@ static void performOp(
|
||||||
auto path = store->parseStorePath(readString(conn.from));
|
auto path = store->parseStorePath(readString(conn.from));
|
||||||
std::shared_ptr<const ValidPathInfo> info;
|
std::shared_ptr<const ValidPathInfo> info;
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
try {
|
info = store->queryPathInfo(path);
|
||||||
info = store->queryPathInfo(path);
|
|
||||||
} catch (InvalidPath &) {
|
|
||||||
if (GET_PROTOCOL_MINOR(conn.protoVersion) < 17)
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
if (info) {
|
if (info) {
|
||||||
if (GET_PROTOCOL_MINOR(conn.protoVersion) >= 17)
|
conn.to << 1;
|
||||||
conn.to << 1;
|
|
||||||
WorkerProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info));
|
WorkerProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info));
|
||||||
} else {
|
} else {
|
||||||
assert(GET_PROTOCOL_MINOR(conn.protoVersion) >= 17);
|
|
||||||
conn.to << 0;
|
conn.to << 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1063,7 +1052,7 @@ void processConnection(ref<Store> store, FdSource && from, FdSink && to, Trusted
|
||||||
auto [protoVersion, features] =
|
auto [protoVersion, features] =
|
||||||
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
||||||
|
|
||||||
if (protoVersion < 0x10a)
|
if (protoVersion < 256 + 18)
|
||||||
throw Error("the Nix client version is too old");
|
throw Error("the Nix client version is too old");
|
||||||
|
|
||||||
WorkerProto::BasicServerConnection conn;
|
WorkerProto::BasicServerConnection conn;
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,8 @@ void RemoteStore::initConnection(Connection & conn)
|
||||||
try {
|
try {
|
||||||
auto [protoVersion, features] =
|
auto [protoVersion, features] =
|
||||||
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
||||||
|
if (protoVersion < 256 + 18)
|
||||||
|
throw Error("the Nix daemon version is too old");
|
||||||
conn.protoVersion = protoVersion;
|
conn.protoVersion = protoVersion;
|
||||||
conn.features = features;
|
conn.features = features;
|
||||||
} catch (SerialisationError & e) {
|
} catch (SerialisationError & e) {
|
||||||
|
|
@ -109,24 +111,22 @@ void RemoteStore::setOptions(Connection & conn)
|
||||||
<< 0 /* obsolete print build trace */
|
<< 0 /* obsolete print build trace */
|
||||||
<< settings.buildCores << settings.useSubstitutes;
|
<< settings.buildCores << settings.useSubstitutes;
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn.protoVersion) >= 12) {
|
std::map<std::string, nix::Config::SettingInfo> overrides;
|
||||||
std::map<std::string, nix::Config::SettingInfo> overrides;
|
settings.getSettings(overrides, true); // libstore settings
|
||||||
settings.getSettings(overrides, true); // libstore settings
|
fileTransferSettings.getSettings(overrides, true);
|
||||||
fileTransferSettings.getSettings(overrides, true);
|
overrides.erase(settings.keepFailed.name);
|
||||||
overrides.erase(settings.keepFailed.name);
|
overrides.erase(settings.keepGoing.name);
|
||||||
overrides.erase(settings.keepGoing.name);
|
overrides.erase(settings.tryFallback.name);
|
||||||
overrides.erase(settings.tryFallback.name);
|
overrides.erase(settings.maxBuildJobs.name);
|
||||||
overrides.erase(settings.maxBuildJobs.name);
|
overrides.erase(settings.maxSilentTime.name);
|
||||||
overrides.erase(settings.maxSilentTime.name);
|
overrides.erase(settings.buildCores.name);
|
||||||
overrides.erase(settings.buildCores.name);
|
overrides.erase(settings.useSubstitutes.name);
|
||||||
overrides.erase(settings.useSubstitutes.name);
|
overrides.erase(loggerSettings.showTrace.name);
|
||||||
overrides.erase(loggerSettings.showTrace.name);
|
overrides.erase(experimentalFeatureSettings.experimentalFeatures.name);
|
||||||
overrides.erase(experimentalFeatureSettings.experimentalFeatures.name);
|
overrides.erase("plugin-files");
|
||||||
overrides.erase("plugin-files");
|
conn.to << overrides.size();
|
||||||
conn.to << overrides.size();
|
for (auto & i : overrides)
|
||||||
for (auto & i : overrides)
|
conn.to << i.first << i.second.value;
|
||||||
conn.to << i.first << i.second.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ex = conn.processStderrReturn();
|
auto ex = conn.processStderrReturn();
|
||||||
if (ex)
|
if (ex)
|
||||||
|
|
@ -167,15 +167,7 @@ bool RemoteStore::isValidPathUncached(const StorePath & path)
|
||||||
StorePathSet RemoteStore::queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute)
|
StorePathSet RemoteStore::queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute)
|
||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 12) {
|
return conn->queryValidPaths(*this, &conn.daemonException, paths, maybeSubstitute);
|
||||||
StorePathSet res;
|
|
||||||
for (auto & i : paths)
|
|
||||||
if (isValidPath(i))
|
|
||||||
res.insert(i);
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
return conn->queryValidPaths(*this, &conn.daemonException, paths, maybeSubstitute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet RemoteStore::queryAllValidPaths()
|
StorePathSet RemoteStore::queryAllValidPaths()
|
||||||
|
|
@ -189,21 +181,10 @@ StorePathSet RemoteStore::queryAllValidPaths()
|
||||||
StorePathSet RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
|
StorePathSet RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
|
||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 12) {
|
conn->to << WorkerProto::Op::QuerySubstitutablePaths;
|
||||||
StorePathSet res;
|
WorkerProto::write(*this, *conn, paths);
|
||||||
for (auto & i : paths) {
|
conn.processStderr();
|
||||||
conn->to << WorkerProto::Op::HasSubstitutes << printStorePath(i);
|
return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||||
conn.processStderr();
|
|
||||||
if (readInt(conn->from))
|
|
||||||
res.insert(i);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
conn->to << WorkerProto::Op::QuerySubstitutablePaths;
|
|
||||||
WorkerProto::write(*this, *conn, paths);
|
|
||||||
conn.processStderr();
|
|
||||||
return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, SubstitutablePathInfos & infos)
|
void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, SubstitutablePathInfos & infos)
|
||||||
|
|
@ -213,45 +194,24 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
||||||
|
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 12) {
|
conn->to << WorkerProto::Op::QuerySubstitutablePathInfos;
|
||||||
|
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 22) {
|
||||||
for (auto & i : pathsMap) {
|
StorePathSet paths;
|
||||||
SubstitutablePathInfo info;
|
for (auto & path : pathsMap)
|
||||||
conn->to << WorkerProto::Op::QuerySubstitutablePathInfo << printStorePath(i.first);
|
paths.insert(path.first);
|
||||||
conn.processStderr();
|
WorkerProto::write(*this, *conn, paths);
|
||||||
unsigned int reply = readInt(conn->from);
|
} else
|
||||||
if (reply == 0)
|
WorkerProto::write(*this, *conn, pathsMap);
|
||||||
continue;
|
conn.processStderr();
|
||||||
auto deriver = readString(conn->from);
|
size_t count = readNum<size_t>(conn->from);
|
||||||
if (deriver != "")
|
for (size_t n = 0; n < count; n++) {
|
||||||
info.deriver = parseStorePath(deriver);
|
SubstitutablePathInfo & info(infos[parseStorePath(readString(conn->from))]);
|
||||||
info.references = WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
auto deriver = readString(conn->from);
|
||||||
info.downloadSize = readLongLong(conn->from);
|
if (deriver != "")
|
||||||
info.narSize = readLongLong(conn->from);
|
info.deriver = parseStorePath(deriver);
|
||||||
infos.insert_or_assign(i.first, std::move(info));
|
info.references = WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||||
}
|
info.downloadSize = readLongLong(conn->from);
|
||||||
|
info.narSize = readLongLong(conn->from);
|
||||||
} else {
|
|
||||||
|
|
||||||
conn->to << WorkerProto::Op::QuerySubstitutablePathInfos;
|
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 22) {
|
|
||||||
StorePathSet paths;
|
|
||||||
for (auto & path : pathsMap)
|
|
||||||
paths.insert(path.first);
|
|
||||||
WorkerProto::write(*this, *conn, paths);
|
|
||||||
} else
|
|
||||||
WorkerProto::write(*this, *conn, pathsMap);
|
|
||||||
conn.processStderr();
|
|
||||||
size_t count = readNum<size_t>(conn->from);
|
|
||||||
for (size_t n = 0; n < count; n++) {
|
|
||||||
SubstitutablePathInfo & info(infos[parseStorePath(readString(conn->from))]);
|
|
||||||
auto deriver = readString(conn->from);
|
|
||||||
if (deriver != "")
|
|
||||||
info.deriver = parseStorePath(deriver);
|
|
||||||
info.references = WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
|
||||||
info.downloadSize = readLongLong(conn->from);
|
|
||||||
info.narSize = readLongLong(conn->from);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -466,36 +426,20 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, Repair
|
||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) < 18) {
|
conn->to << WorkerProto::Op::AddToStoreNar << printStorePath(info.path)
|
||||||
auto source2 = sinkToSource([&](Sink & sink) {
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
sink << 1 // == path follows
|
<< info.narHash.to_string(HashFormat::Base16, false);
|
||||||
;
|
WorkerProto::write(*this, *conn, info.references);
|
||||||
copyNAR(source, sink);
|
conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress(info.ca)
|
||||||
sink << exportMagic << printStorePath(info.path);
|
<< repair << !checkSigs;
|
||||||
WorkerProto::write(*this, *conn, info.references);
|
|
||||||
sink << (info.deriver ? printStorePath(*info.deriver) : "") << 0 // == no legacy signature
|
|
||||||
<< 0 // == no path follows
|
|
||||||
;
|
|
||||||
});
|
|
||||||
conn->importPaths(*this, &conn.daemonException, *source2);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
if (GET_PROTOCOL_MINOR(conn->protoVersion) >= 23) {
|
||||||
conn->to << WorkerProto::Op::AddToStoreNar << printStorePath(info.path)
|
conn.withFramedSink([&](Sink & sink) { copyNAR(source, sink); });
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
} else if (GET_PROTOCOL_MINOR(conn->protoVersion) >= 21) {
|
||||||
<< info.narHash.to_string(HashFormat::Base16, false);
|
conn.processStderr(0, &source);
|
||||||
WorkerProto::write(*this, *conn, info.references);
|
} else {
|
||||||
conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress(info.ca)
|
copyNAR(source, conn->to);
|
||||||
<< repair << !checkSigs;
|
conn.processStderr(0, nullptr);
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) >= 23) {
|
|
||||||
conn.withFramedSink([&](Sink & sink) { copyNAR(source, sink); });
|
|
||||||
} else if (GET_PROTOCOL_MINOR(conn->protoVersion) >= 21) {
|
|
||||||
conn.processStderr(0, &source);
|
|
||||||
} else {
|
|
||||||
copyNAR(source, conn->to);
|
|
||||||
conn.processStderr(0, nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -618,15 +562,8 @@ void RemoteStore::buildPaths(
|
||||||
|
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << WorkerProto::Op::BuildPaths;
|
conn->to << WorkerProto::Op::BuildPaths;
|
||||||
assert(GET_PROTOCOL_MINOR(conn->protoVersion) >= 13);
|
|
||||||
WorkerProto::write(*this, *conn, drvPaths);
|
WorkerProto::write(*this, *conn, drvPaths);
|
||||||
if (GET_PROTOCOL_MINOR(conn->protoVersion) >= 15)
|
conn->to << buildMode;
|
||||||
conn->to << buildMode;
|
|
||||||
else
|
|
||||||
/* Old daemons did not take a 'buildMode' parameter, so we
|
|
||||||
need to validate it here on the client side. */
|
|
||||||
if (buildMode != bmNormal)
|
|
||||||
throw Error("repairing or checking is not supported when building through the Nix daemon");
|
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
readInt(conn->from);
|
readInt(conn->from);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue