From 508f476c18c897c3f686492cae933f59a8d12ab6 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 17 Jun 2025 23:49:52 +0200 Subject: [PATCH] libstore: don't crash when talking to old ssh:// remotes protocol version 0x204 dates back to nix 2.0 in 2017. that's old enough to not worry and drop the gratuitous assertion crash we see it instead. Change-Id: I8cf23373d4daabccab61f1cbb670947479f0d2bc --- lix/libstore/legacy-ssh-store.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lix/libstore/legacy-ssh-store.cc b/lix/libstore/legacy-ssh-store.cc index a1d3b9621..f3f4925fc 100644 --- a/lix/libstore/legacy-ssh-store.cc +++ b/lix/libstore/legacy-ssh-store.cc @@ -151,6 +151,13 @@ struct LegacySSHStore final : public Store if (GET_PROTOCOL_MAJOR(conn->remoteVersion) != 0x200) throw Error("unsupported 'nix-store --serve' protocol version on '%s'", host); + /* No longer support protocols this old*/ + if (GET_PROTOCOL_MINOR(conn->remoteVersion) < 4) { + throw Error( + "remote '%s' is too old (protocol version %x)", host, conn->remoteVersion + ); + } + } catch (EndOfFile & e) { throw Error("cannot connect to '%1%'", host); } @@ -170,9 +177,6 @@ struct LegacySSHStore final : public Store try { auto conn(TRY_AWAIT(connections->get())); - /* No longer support missing NAR hash */ - assert(GET_PROTOCOL_MINOR(conn->remoteVersion) >= 4); - debug("querying remote host '%s' for info on '%s'", host, printStorePath(path)); *conn->to << ServeProto::Command::QueryPathInfos << PathSet{printStorePath(path)}; @@ -292,12 +296,9 @@ private: void putBuildSettings(Connection & conn) { *conn.to << settings.maxSilentTime << settings.buildTimeout; - if (GET_PROTOCOL_MINOR(conn.remoteVersion) >= 2) { - *conn.to << settings.maxLogSize; - } - if (GET_PROTOCOL_MINOR(conn.remoteVersion) >= 3) - *conn.to << 0 // buildRepeat hasn't worked for ages anyway - << 0; + *conn.to << settings.maxLogSize; + *conn.to << 0 // buildRepeat hasn't worked for ages anyway + << 0; if (GET_PROTOCOL_MINOR(conn.remoteVersion) >= 7) { *conn.to << ((int) settings.keepFailed);