diff options
author | Julian Andres Klode <jak@debian.org> | 2016-08-03 18:50:37 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-08-03 19:00:01 +0200 |
commit | 98f884ebec556bafe6f9650e105fc7c60580e730 (patch) | |
tree | 5158ee02fb6ad8c087b8b0dadd6857bd1d6f0a98 /apt-pkg | |
parent | 81ee750f90bb4d21a0441196ce105f6848633616 (diff) | |
download | apt-98f884ebec556bafe6f9650e105fc7c60580e730.tar.gz |
ExecGPGV: Pass current config state to apt-key via temp file
Create a temporary configuration file with a dump of our
configuration and pass that to apt-key.
LP: #1607283
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/gpgv.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 4247a1562..8796195b8 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -18,6 +18,7 @@ #include <stddef.h> #include <algorithm> +#include <fstream> #include <iostream> #include <string> #include <vector> @@ -105,6 +106,28 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, std::vector<std::string> dataHeader; char * sig = NULL; char * data = NULL; + char * conf = nullptr; + + // Dump the configuration so apt-key picks up the correct Dir values + { + conf = GenerateTemporaryFileTemplate("apt.conf"); + if (conf == nullptr) { + ioprintf(std::cerr, "Couldn't create tempfile names for passing config to apt-key"); + local_exit(EINTERNAL); + } + int confFd = mkstemp(conf); + if (confFd == -1) { + ioprintf(std::cerr, "Couldn't create temporary file %s for passing config to apt-key", conf); + local_exit(EINTERNAL); + } + local_exit.files.push_back(conf); + + std::ofstream confStream(conf); + close(confFd); + _config->Dump(confStream); + confStream.close(); + setenv("APT_CONFIG", conf, 1); + } if (releaseSignature == DETACHED) { |