Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
Choose a head branch
1.2.y
1.3.y
1.4.y
1.5.y
attic/cmake
bugfix/acquire-error
bugfix/acquire-priority-queue
bugfix/apt-key-config-many-fd
bugfix/apt-key-config
bugfix/apt-key-config2
bugfix/big-lock
bugfix/clog
bugfix/cmake
bugfix/cross-arch-candidate
bugfix/fix-or-in-build-dep-parsing
bugfix/gcc
bugfix/gpg-versions
bugfix/happy-eyeballs
bugfix/https-proxy-environ
bugfix/internal-seek
bugfix/lp-1653094-https-quote
bugfix/portable-docbook
bugfix/proxy-popen
bugfix/run-update-scripts-if-not-all-failed
bugfix/sane-quoting
bugfix/sha1-deprecated
bugfix/sigint
bugfix/translate-common-manpage-stuff
bugfix/verify-trust-chain
bugfix/versionhash-overflow
bugfix/748936-correct-arch-patterns
cmake-no-globbing
cmake-prepare
coverty_scan
debian/experimental-no-abi-break
debian/experimental
debian/jessie
debian/sid-gcc5
debian/sid
debian/wheezy
feature/apt-cache-policy-show-current-state
feature/blake2b
feature/configurable-hash-trust
feature/extended-cache
feature/force-compressor
feature/freeze-config-optiom
feature/http-https
feature/https-http-part2
feature/https-proxy
feature/move-methods
feature/noinstall-notautomic
feature/rpm
feature/seccomp
for-1.2/apt-key
for-1.2/locale
for-1.2/1.4
for-1.6/gcov-error-file
jessie-backports
lp1615482
lp1686470
master-pu
master
misc/error-message-rework
misc/forward-string-view
misc/include-cleanup
misc/increase-manual-scores
misc/rework-filefd-lzma
misc/select-to-poll
misc/thread-local
misc/unused
misc/wait-online
performance/cachegen
performance/crc16-sliced
performance/hex2num
performance/no-packagetable
performance/no-useless-buffering
performance/perfect-hash
performance/perfect-hash2
performance/random
performance/store-string-size
performance/tagfile
performance/trie
portability/fink
portability/freebsd
portability/macos
pu/cmake-fixes
pu/compressed-indexes
pu/dpkg-1.19
pu/drop-store-symlinks
pu/happy-eyeballs
pu/happy-eyeballs2a
pu/happy-eyeballs2
pu/method-socket
pu/mmap-no-executable
pu/ninja
pu/proxy-auto-detect
pu/rules-requires-root-no
pu/seccomp-sigaction
pu/transient-error-fixes
pu/transitional-transport-https
refactor/gpgv
reformat-test
shippable
strip-zero-epochs-from-hash
travis-docker
travis-llvm
travis-test2
travis-test3
ubuntu/master
ubuntu/trusty
ubuntu/zesty
Nothing to show
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 03, 2016
Allow to specify - as APT_CONFIG for stdin
If - is specified as a config file, we will use stdin instead, after
seeking to 0. This will be used to implement configuration passing
for apt-key.
gpgv: Pass current config to apt-key on a file-based stdin
This allows apt-key to read the current config file. The file is
created and directly unlinked, so we do not have to keep track of
it and do the same stuff we do for the split gpgv files.
Showing with 49 additions and 3 deletions.
  1. +7 −2 apt-pkg/contrib/configuration.cc
  2. +41 −0 apt-pkg/contrib/gpgv.cc
  3. +1 −1 apt-pkg/init.cc
@@ -681,8 +681,13 @@ static void leaveCurrentScope(std::stack<std::string> &Stack, std::string &Paren
bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectional,
unsigned const &Depth)
{
- // Open the stream for reading
- ifstream F(FName.c_str(),ios::in);
+ if (FName == "-") {
+ lseek(STDIN_FILENO, 0, SEEK_SET);
+ }
+
+ ifstream FStream(FName.c_str(),ios::in);
+ istream &F = FName == "-" ? cin : FStream;
+
if (F.fail() == true)
return _error->Errno("ifstream::ifstream",_("Opening configuration file %s"),FName.c_str());
View
@@ -18,9 +18,11 @@
#include <stddef.h>
#include <algorithm>
+#include <fstream>
#include <iostream>
#include <string>
#include <vector>
+#include <ext/stdio_filebuf.h>
#include <apti18n.h>
/*}}}*/
@@ -32,6 +34,22 @@ static char * GenerateTemporaryFileTemplate(const char *basename) /*{{{*/
return strdup(out.c_str());
}
/*}}}*/
+static int OpenAnonymousTemporaryFile(const char *basename) /*{{{*/
+{
+ char * filename = GenerateTemporaryFileTemplate(basename);
+
+ if (filename == nullptr)
+ return -1;
+
+ int const fd = mkstemp(filename);
+ if (fd == -1)
+ return -1;
+
+ unlink(filename);
+ free(filename);
+ return fd;
+}
+ /*}}}*/
// ExecGPGV - returns the command needed for verify /*{{{*/
// ---------------------------------------------------------------------
/* Generating the commandline for calling gpg is somehow complicated as
@@ -98,6 +116,29 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
char * sig = NULL;
char * data = NULL;
+ int confFd = OpenAnonymousTemporaryFile("apt.conf");
+
+ if (confFd == -1) {
+ ioprintf(std::cerr, "Couldn't create tempfile names for passing config to apt-key during verification of %s", File.c_str());
+ exit(EINTERNAL);
+ }
+
+ __gnu_cxx::stdio_filebuf<char> filebuf(confFd, std::ios::out);
+ std::ostream configStream(&filebuf);
+ {
+ _config->Dump(configStream);
+ configStream.flush();
+
+ if (configStream.fail() == true) {
+ ioprintf(std::cerr, "Couldn't write temporary apt config file to pass to apt-key");
+ exit(EINTERNAL);
+ }
+
+ setenv("APT_CONFIG", "-", 1);
+ // Dup the conf fd to stdin, so we can pass it to apt-key anonymously
+ dup2(confFd, STDIN_FILENO);
+ }
+
if (releaseSignature == DETACHED)
{
Args.push_back(FileGPG.c_str());
View
@@ -128,7 +128,7 @@ bool pkgInitConfig(Configuration &Cnf)
const char *Cfg = getenv("APT_CONFIG");
if (Cfg != 0 && strlen(Cfg) != 0)
{
- if (RealFileExists(Cfg) == true)
+ if (RealFileExists(Cfg) == true || strcmp(Cfg, "-") == 0)
Res &= ReadConfigFile(Cnf,Cfg);
else
_error->WarningE("RealFileExists",_("Unable to read %s"),Cfg);

No commit comments for this range