summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAristo Chen <aristo.chen@canonical.com>2024-07-05 17:01:32 +0800
committerAristo Chen <aristo.chen@canonical.com>2024-07-12 11:28:47 +0800
commit4b537e415aa3888ffe029664bc8238078bdc880a (patch)
tree2248c5428c5fbc8c70c24ca60bc3c642e1fa71a1
parenta8367745eac915281cc2b9fb98813e9225d1e55c (diff)
Do not return error if `Signed-By` value in source list is empty
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
-rw-r--r--apt-pkg/deb/debmetaindex.cc2
-rwxr-xr-xtest/integration/test-signed-by-option48
2 files changed, 50 insertions, 0 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 515893133..266313bef 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -817,6 +817,8 @@ bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy)
else
{
auto const normalSignedBy = NormalizeSignedBy(pSignedBy, true);
+ if (normalSignedBy.empty() == true)
+ return true;
if (normalSignedBy != SignedBy)
return _error->Error(_("Conflicting values set for option %s regarding source %s %s: %s != %s"), "Signed-By", URI.c_str(), Dist.c_str(), SignedBy.c_str(), normalSignedBy.c_str());
}
diff --git a/test/integration/test-signed-by-option b/test/integration/test-signed-by-option
index 58e4c4b19..8e1e9a8c2 100755
--- a/test/integration/test-signed-by-option
+++ b/test/integration/test-signed-by-option
@@ -71,3 +71,51 @@ sed -i s/^xSigned-By/Signed-By/ rootdir/etc/apt/sources.list.d/deb822.sources
testsuccess apt update -o Debug::Acquire::gpgv=1
# make sure we did not leave leftover files (LP: #1995247)
testsuccessequal "" ls "${TMPDIR}"
+
+rm -f rootdir/etc/apt/sources.list.d/*
+
+msgtest 'Check that a repository with' 'only the fisrt entry has no Signed-By value works'
+cat > rootdir/etc/apt/sources.list.d/example.sources << EOF
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component
+
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component2
+Signed-By: 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
+EOF
+testsuccess --nomsg aptcache policy
+
+msgtest 'Check that a repository with' 'only the second entry has no Signed-By value works'
+cat > rootdir/etc/apt/sources.list.d/example.sources << EOF
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component
+Signed-By: 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
+
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component2
+EOF
+testsuccess --nomsg aptcache policy
+
+cat > rootdir/etc/apt/sources.list.d/example.sources << EOF
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component
+Signed-By: 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
+
+Types: deb
+URIs: http://example.org/
+Suites: suite
+Components: component2
+Signed-By: DE66AECA9151AFA1877EC31DE8525D47528144E2
+EOF
+testfailuremsg 'E: Conflicting values set for option Signed-By regarding source http://example.org/ suite: 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE != DE66AECA9151AFA1877EC31DE8525D47528144E2
+E: The list of sources could not be read.' aptget update --print-uris