From 4e35e5079f589700b4b5f1fc00787144bc1c58bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 24 May 2023 11:07:26 +0200 Subject: Ensure that Snapshots: no doesn't get overriden by host-name config --- apt-pkg/deb/debmetaindex.cc | 10 +++------- test/integration/test-snapshot | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index ddc246349..4bd7dfa78 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -1261,9 +1261,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ #define APT_EMPTY_SERVER \ if (server.empty() == false) \ { \ - if (server != "no") \ - return server; \ - return ""; \ + return server; \ } #define APT_CHECK_SERVER(X, Y) \ if (not Rls->Get##X().empty()) \ @@ -1321,12 +1319,10 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ // Lookup a fallback based on the host. For a.b.c, this will try a.b.c, .b.c, and .c to allow generalization for cc.archive.ubuntu.com for (std::string Host = ArchiveURI.Host; not Host.empty() && Server.empty(); Host = Host.find(".", 1) != Host.npos ? Host.substr(Host.find(".", 1)) : "") Server = _config->Find("Acquire::Snapshots::URI::Host::" + Host); - if (Server == "no") - Server = ""; } - if (Server.empty()) + if (Server.empty() || Server == "no") { - if (filename.empty()) + if (Server != "no" && filename.empty()) return _error->Error("Cannot identify snapshot server for %s %s - run update without snapshot id first", URI.c_str(), Dist.c_str()); return _error->Error("Snapshots not supported for %s %s", URI.c_str(), Dist.c_str()); } diff --git a/test/integration/test-snapshot b/test/integration/test-snapshot index e32b91daf..2bf7d70d4 100755 --- a/test/integration/test-snapshot +++ b/test/integration/test-snapshot @@ -173,6 +173,10 @@ testfailuremsg "E: Snapshots not supported for http://localhost:${APTHTTPPORT}/ E: Snapshots not supported for http://localhost:${APTHTTPPORT}/ stable E: The list of sources could not be read." aptget update --print-uris -S BANANA +testfailuremsg "E: Snapshots not supported for http://localhost:${APTHTTPPORT}/ stable +E: Snapshots not supported for http://localhost:${APTHTTPPORT}/ stable +E: The list of sources could not be read." aptget update --print-uris -S BANANA -o Acquire::Snapshots::URI::Host::localhost="https://example.org/snapshots/@PATH@/@SNAPSHOTID@/" + msgmsg "Snapshot URI configured in apt.conf" sed -i '/^Snapshots: / d' $(find rootdir/var/lib/apt/lists -name '*Release') releasechanger 'Label' 'Testcases' -- cgit v1.2.3-70-g09d2