summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2021-06-09 13:22:38 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2021-10-18 16:12:54 +0200
commit3f07f5345ec79702c3c769047452041b2c12953f (patch)
tree4fcf77cec69916e6a1c4ac4553d6eb5efe5d525f /apt-pkg/deb
parentc8e5008794f07afa1e9c139249c682eb5745fc25 (diff)
Add support for embedding PGP keys into Signed-By in deb822 sources
Extend the Signed-By field to handle embedded public key blocks, this allows shipping self-contained .sources files, making it substantially easier to provide third party repositories.
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debmetaindex.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index d78cea758..298ff5007 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -56,6 +56,23 @@ static std::string transformFingergrpintsWithFilenames(std::string const &finger
/*}}}*/
static std::string NormalizeSignedBy(std::string SignedBy, bool const SupportFilenames) /*{{{*/
{
+ // This is an embedded public pgp key, normalize spaces inside it and empty "." lines
+ if (SignedBy.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != std::string::npos) {
+ std::istringstream is(SignedBy);
+ std::ostringstream os;
+ std::string line;
+
+ while (std::getline(is, line)) {
+ line = APT::String::Strip(line);
+ // The special encoding for empty lines in deb822
+ if (line == ".")
+ line="";
+ os << line << std::endl;
+ }
+ std::clog << "OUTPUT " << os.str() << std::endl;
+ return os.str();
+ }
+
// we could go all fancy and allow short/long/string matches as gpgv/apt-key does,
// but fingerprints are harder to fake than the others and this option is set once,
// not interactively all the time so easy to type is not really a concern.