From 0496bc63a3ad1dcbc41d20225c6a0d50fbcf101d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 23 Nov 2024 19:50:44 +0100 Subject: gpgv: Add direct support for --assert-pubkey-algo --- apt-pkg/contrib/gpgv.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index dd4d5cfb6..611f4bfa7 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -301,6 +301,29 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, Args.push_back(statusfdstr); } + if (auto assertPubkeyAlgo = _config->Find("Apt::Key::assert-pubkey-algo"); not assertPubkeyAlgo.empty()) + { + FileFd dumpOptions; + pid_t child; + if (Debug) + std::clog << "Calling " << gpgv << " --dump-options" << std::endl; + const char* argv[] = {gpgv.c_str(), "--dump-options", nullptr}; + if (not Popen(argv, dumpOptions, child, FileFd::ReadOnly) && Debug) + std::clog << "Failed to call " << gpgv << " --dump-options" << std::endl; + for (std::string line; dumpOptions.ReadLine(line); ) + { + if (Debug) + std::clog << "Read line: " << line << std::endl; + if (APT::String::Strip(line) == "--assert-pubkey-algo") + { + Args.push_back("--assert-pubkey-algo=" + assertPubkeyAlgo); + break; + } + } + dumpOptions.Close(); + waitpid(child, NULL, 0); + } + Configuration::Item const *Opts; Opts = _config->Tree("Acquire::gpgv::Options"); if (Opts != 0) -- cgit v1.2.3-70-g09d2