From fa048e4383f5d0f5621007e6798172fcfa441e8c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 9 Sep 2025 14:56:06 +0200 Subject: [PATCH] Remove support for serve protocol < 5 This was introduced in August 2018 (2825e05d21ecabc8b8524836baf0b9b05da993c6). --- .../serve-protocol/handshake-to-client.bin | Bin 16 -> 16 bytes src/libstore-tests/serve-protocol.cc | 4 +- .../nix/store/serve-protocol-connection.hh | 2 - .../include/nix/store/serve-protocol.hh | 1 - src/libstore/legacy-ssh-store.cc | 50 +++++------------- src/libstore/serve-protocol-connection.cc | 12 +---- src/nix/nix-store/nix-store.cc | 8 --- 7 files changed, 17 insertions(+), 60 deletions(-) diff --git a/src/libstore-tests/data/serve-protocol/handshake-to-client.bin b/src/libstore-tests/data/serve-protocol/handshake-to-client.bin index 15ba4b5e3d96e388637107542f6eb9f7e94ac708..465daa532c4bf88e1811456aed254613b752446c 100644 GIT binary patch literal 16 VcmX^8E+~Y7fq{XQ2}Ck5001MX0%rgK literal 16 ScmX^8E+~Wn1eibs0|NjffC6Fw diff --git a/src/libstore-tests/serve-protocol.cc b/src/libstore-tests/serve-protocol.cc index 01d6058cb..4cd7f101b 100644 --- a/src/libstore-tests/serve-protocol.cc +++ b/src/libstore-tests/serve-protocol.cc @@ -20,9 +20,9 @@ struct ServeProtoTest : VersionedProtoTest { /** * For serializers that don't care about the minimum version, we - * used the oldest one: 1.0. + * used the oldest one: 2.5. */ - ServeProto::Version defaultVersion = 2 << 8 | 0; + ServeProto::Version defaultVersion = 2 << 8 | 5; }; VERSIONED_CHARACTERIZATION_TEST( diff --git a/src/libstore/include/nix/store/serve-protocol-connection.hh b/src/libstore/include/nix/store/serve-protocol-connection.hh index fa50132c8..873277db9 100644 --- a/src/libstore/include/nix/store/serve-protocol-connection.hh +++ b/src/libstore/include/nix/store/serve-protocol-connection.hh @@ -82,8 +82,6 @@ struct ServeProto::BasicClientConnection BuildResult getBuildDerivationResponse(const StoreDirConfig & store); void narFromPath(const StoreDirConfig & store, const StorePath & path, std::function fun); - - void importPaths(const StoreDirConfig & store, std::function fun); }; struct ServeProto::BasicServerConnection diff --git a/src/libstore/include/nix/store/serve-protocol.hh b/src/libstore/include/nix/store/serve-protocol.hh index c8f3560d1..92e0b9a25 100644 --- a/src/libstore/include/nix/store/serve-protocol.hh +++ b/src/libstore/include/nix/store/serve-protocol.hh @@ -108,7 +108,6 @@ enum struct ServeProto::Command : uint64_t { QueryValidPaths = 1, QueryPathInfos = 2, DumpStorePath = 3, - ImportPaths = 4, ExportPaths = 5, BuildPaths = 6, QueryClosure = 7, diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index d42dca74a..f935de206 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -105,9 +105,6 @@ std::map LegacySSHStore::queryPathInfosUncached { auto conn(connections->get()); - /* No longer support missing NAR hash */ - assert(GET_PROTOCOL_MINOR(conn->remoteVersion) >= 4); - debug( "querying remote host '%s' for info on '%s'", config->authority.host, @@ -152,40 +149,21 @@ void LegacySSHStore::addToStore(const ValidPathInfo & info, Source & source, Rep auto conn(connections->get()); - if (GET_PROTOCOL_MINOR(conn->remoteVersion) >= 5) { - - conn->to << ServeProto::Command::AddToStoreNar << printStorePath(info.path) - << (info.deriver ? printStorePath(*info.deriver) : "") - << info.narHash.to_string(HashFormat::Base16, false); - ServeProto::write(*this, *conn, info.references); - conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs - << renderContentAddress(info.ca); - try { - copyNAR(source, conn->to); - } catch (...) { - conn->good = false; - throw; - } - conn->to.flush(); - - if (readInt(conn->from) != 1) - throw Error( - "failed to add path '%s' to remote host '%s'", printStorePath(info.path), config->authority.host); - - } else { - - conn->importPaths(*this, [&](Sink & sink) { - try { - copyNAR(source, sink); - } catch (...) { - conn->good = false; - throw; - } - sink << exportMagic << printStorePath(info.path); - ServeProto::write(*this, *conn, info.references); - sink << (info.deriver ? printStorePath(*info.deriver) : "") << 0 << 0; - }); + conn->to << ServeProto::Command::AddToStoreNar << printStorePath(info.path) + << (info.deriver ? printStorePath(*info.deriver) : "") + << info.narHash.to_string(HashFormat::Base16, false); + ServeProto::write(*this, *conn, info.references); + conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress(info.ca); + try { + copyNAR(source, conn->to); + } catch (...) { + conn->good = false; + throw; } + conn->to.flush(); + + if (readInt(conn->from) != 1) + throw Error("failed to add path '%s' to remote host '%s'", printStorePath(info.path), config->authority.host); } void LegacySSHStore::narFromPath(const StorePath & path, Sink & sink) diff --git a/src/libstore/serve-protocol-connection.cc b/src/libstore/serve-protocol-connection.cc index 908994f4e..a90b104a6 100644 --- a/src/libstore/serve-protocol-connection.cc +++ b/src/libstore/serve-protocol-connection.cc @@ -15,7 +15,7 @@ ServeProto::Version ServeProto::BasicClientConnection::handshake( if (magic != SERVE_MAGIC_2) throw Error("'nix-store --serve' protocol mismatch from '%s'", host); auto remoteVersion = readInt(from); - if (GET_PROTOCOL_MAJOR(remoteVersion) != 0x200) + if (GET_PROTOCOL_MAJOR(remoteVersion) != 0x200 || GET_PROTOCOL_MINOR(remoteVersion) < 5) throw Error("unsupported 'nix-store --serve' protocol version on '%s'", host); return std::min(remoteVersion, localVersion); } @@ -93,14 +93,4 @@ void ServeProto::BasicClientConnection::narFromPath( fun(from); } -void ServeProto::BasicClientConnection::importPaths(const StoreDirConfig & store, std::function fun) -{ - to << ServeProto::Command::ImportPaths; - fun(to); - to.flush(); - - if (readInt(from) != 1) - throw Error("remote machine failed to import closure"); -} - } // namespace nix diff --git a/src/nix/nix-store/nix-store.cc b/src/nix/nix-store/nix-store.cc index 4191ea0d6..31b288817 100644 --- a/src/nix/nix-store/nix-store.cc +++ b/src/nix/nix-store/nix-store.cc @@ -985,14 +985,6 @@ static void opServe(Strings opFlags, Strings opArgs) store->narFromPath(store->parseStorePath(readString(in)), out); break; - case ServeProto::Command::ImportPaths: { - if (!writeAllowed) - throw Error("importing paths is not allowed"); - store->importPaths(in, NoCheckSigs); // FIXME: should we skip sig checking? - out << 1; // indicate success - break; - } - case ServeProto::Command::ExportPaths: { readInt(in); // obsolete store->exportPaths(ServeProto::Serialise::read(*store, rconn), out);