summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcmdline/apt-key37
-rw-r--r--debian/apt.dirs1
-rw-r--r--debian/changelog4
-rw-r--r--doc/apt-key.8.xml24
-rw-r--r--doc/apt.ent13
-rw-r--r--doc/examples/configure-index7
-rw-r--r--methods/gpgv.cc98
7 files changed, 126 insertions, 58 deletions
diff --git a/cmdline/apt-key b/cmdline/apt-key
index 24010edf3..1950723f3 100755
--- a/cmdline/apt-key
+++ b/cmdline/apt-key
@@ -5,10 +5,8 @@ unset GREP_OPTIONS
# We don't use a secret keyring, of course, but gpg panics and
# implodes if there isn't one available
-
GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg"
-GPG="$GPG_CMD --keyring /etc/apt/trusted.gpg"
-
+GPG="$GPG_CMD"
MASTER_KEYRING=""
ARCHIVE_KEYRING_URI=""
@@ -115,7 +113,7 @@ update() {
usage() {
- echo "Usage: apt-key [command] [arguments]"
+ echo "Usage: apt-key [--keyring file] [command] [arguments]"
echo
echo "Manage apt's list of trusted keys"
echo
@@ -129,8 +127,39 @@ usage() {
echo " apt-key finger - list fingerprints"
echo " apt-key adv - pass advanced options to gpg (download key)"
echo
+ echo "If no specific keyring file is given the command applies to all keyring files."
}
+# Determine on which keyring we want to work
+if [ "$1" = "--keyring" ]; then
+ echo "keyfile given"
+ shift
+ TRUSTEDFILE="$1"
+ if [ -r "$TRUSTEDFILE" ]; then
+ GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE"
+ else
+ echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable"
+ exit 1
+ fi
+ shift
+else
+ echo "generate list"
+ TRUSTEDFILE="/etc/apt/trusted.gpg"
+ if [ -r "$TRUSTEDFILE" ]; then
+ GPG="$GPG --keyring $TRUSTEDFILE"
+ fi
+ GPG="$GPG --primary-keyring $TRUSTEDFILE"
+ TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
+ if [ -d "$TRUSTEDPARTS" ]; then
+ echo "parts active"
+ for trusted in $(run-parts --list $TRUSTEDPARTS --regex '^.*\.gpg$'); do
+ echo "part -> $trusted"
+ GPG="$GPG --keyring $trusted"
+ done
+ fi
+fi
+echo "COMMAND: $GPG"
+
command="$1"
if [ -z "$command" ]; then
usage
diff --git a/debian/apt.dirs b/debian/apt.dirs
index fb6716c35..66556e453 100644
--- a/debian/apt.dirs
+++ b/debian/apt.dirs
@@ -5,6 +5,7 @@ etc/apt
etc/apt/apt.conf.d
etc/apt/preferences.d
etc/apt/sources.list.d
+etc/apt/trusted.gpg.d
etc/logrotate.d
var/cache/apt/archives/partial
var/lib/apt/lists/partial
diff --git a/debian/changelog b/debian/changelog
index f70c5735f..fca8d3ccb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,10 @@ apt (0.7.26) UNRELEASED; urgency=low
the keyring so we don't need to ship our own version
* cmdline/apt-key:
- errors out if wget is not installed (Closes: #545754)
+ - add --keyring option as we have now possibly many
+ * methods/gpgv.cc:
+ - pass all keyrings (TrustedParts) to gpgv instead of
+ using only one trusted.gpg keyring (Closes: #304846)
-- Michael Vogt <mvo@debian.org> Thu, 10 Dec 2009 22:02:38 +0100
diff --git a/doc/apt-key.8.xml b/doc/apt-key.8.xml
index 7b0691b5e..8f445b7f9 100644
--- a/doc/apt-key.8.xml
+++ b/doc/apt-key.8.xml
@@ -26,7 +26,8 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>apt-key</command>
- <arg><replaceable>command</replaceable>/</arg>
+ <arg><option>--keyring <replaceable>filename</replaceable></option></arg>
+ <arg><replaceable>command</replaceable></arg>
<arg rep="repeat"><option><replaceable>arguments</replaceable></option></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -135,11 +136,24 @@
</variablelist>
</refsect1>
+ <refsect1><title>Options</title>
+<para>Note that options need to be defined before the commands described in the previous section.</para>
+ <variablelist>
+ <varlistentry><term>--keyring <replaceable>filename</replaceable></term>
+ <listitem><para>With this option it is possible to specify a specific keyring
+ file the command should operate on. The default is that a command is executed
+ on the <filename>trusted.gpg</filename> file as well as on all parts in the
+ <filename>trusted.gpg.d</filename> directory, through <filename>trusted.gpg</filename>
+ is the primary keyring which means that e.g. new keys are added to this one.
+ </para></listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
<refsect1><title>Files</title>
<variablelist>
- <varlistentry><term><filename>/etc/apt/trusted.gpg</filename></term>
- <listitem><para>Keyring of local trusted keys, new keys will be added here.</para></listitem>
- </varlistentry>
+
+ &file-trustedgpg;
<varlistentry><term><filename>/etc/apt/trustdb.gpg</filename></term>
<listitem><para>Local trust database of archive keys.</para></listitem>
@@ -153,8 +167,6 @@
<listitem><para>Keyring of Debian archive removed trusted keys.</para></listitem>
</varlistentry>
-
-
</variablelist>
</refsect1>
diff --git a/doc/apt.ent b/doc/apt.ent
index 0b341ec14..da43d8f3d 100644
--- a/doc/apt.ent
+++ b/doc/apt.ent
@@ -353,3 +353,16 @@
Configuration Item: <literal>Dir::State::Lists</literal> (implicit partial).</para></listitem>
</varlistentry>
">
+
+<!ENTITY file-trustedgpg "
+ <varlistentry><term><filename>/etc/apt/trusted.gpg</filename></term>
+ <listitem><para>Keyring of local trusted keys, new keys will be added here.
+ Configuration Item: <literal>Dir::Etc::Trusted</literal>.</para></listitem>
+ </varlistentry>
+
+ <varlistentry><term><filename>/etc/apt/trusted.gpg.d/</filename></term>
+ <listitem><para>File fragments for the trusted keys, additional keyrings can
+ be stored here (by other packages or the administrator).
+ Configuration Item <literal>Dir::Etc::TrustedParts</literal>.</para></listitem>
+ </varlistentry>
+">
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index be461aaad..87cf97ffe 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -90,11 +90,6 @@ APT
TrustCDROM "false"; // consider the CDROM always trusted
};
- GPGV
- {
- TrustedKeyring "/etc/apt/trusted.gpg";
- };
-
// Some general options
Ignore-Hold "false";
Clean-Installed "true";
@@ -320,6 +315,8 @@ Dir "/"
SourceParts "sources.list.d";
VendorList "vendors.list";
VendorParts "vendors.list.d";
+ Trusted "trusted.gpg";
+ TrustedParts "trusted.gpg.d";
};
// Locations of binaries
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index 150c1d315..e3e849827 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -1,10 +1,9 @@
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
#include <apti18n.h>
-#include <sys/stat.h>
-#include <unistd.h>
#include <utime.h>
#include <stdio.h>
#include <fcntl.h>
@@ -45,42 +44,47 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
vector<string> &WorthlessSigners,
vector<string> &NoPubKeySigners)
{
+ bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
// setup a (empty) stringstream for formating the return value
std::stringstream ret;
ret.str("");
- if (_config->FindB("Debug::Acquire::gpgv", false))
- {
- std::cerr << "inside VerifyGetSigners" << std::endl;
- }
+ if (Debug == true)
+ std::clog << "inside VerifyGetSigners" << std::endl;
+
pid_t pid;
int fd[2];
FILE *pipein;
int status;
- struct stat buff;
- string gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
- string pubringpath = _config->Find("APT::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg");
- if (_config->FindB("Debug::Acquire::gpgv", false))
+ string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
+ // FIXME: remove support for deprecated APT::GPGV setting
+ string const trustedFile = _config->FindFile("Dir::Etc::Trusted",
+ _config->Find("APT::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg").c_str());
+ string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts", "/etc/apt/trusted.gpg.d");
+ if (Debug == true)
{
- std::cerr << "gpgv path: " << gpgvpath << std::endl;
- std::cerr << "Keyring path: " << pubringpath << std::endl;
+ std::clog << "gpgv path: " << gpgvpath << std::endl;
+ std::clog << "Keyring file: " << trustedFile << std::endl;
+ std::clog << "Keyring path: " << trustedPath << std::endl;
}
- if (stat(pubringpath.c_str(), &buff) != 0)
+ vector<string> keyrings = GetListOfFilesInDir(trustedPath, "gpg", false);
+ if (FileExists(trustedFile) == true)
+ keyrings.push_back(trustedFile);
+
+ if (keyrings.empty() == true)
{
- ioprintf(ret, _("Couldn't access keyring: '%s'"), strerror(errno));
+ // TRANSLATOR: %s is the trusted keyring parts directory
+ ioprintf(ret, _("No keyring installed in %s."), trustedPath.c_str());
return ret.str();
}
+
if (pipe(fd) < 0)
- {
return "Couldn't create pipe";
- }
pid = fork();
if (pid < 0)
- {
return string("Couldn't spawn new process") + strerror(errno);
- }
else if (pid == 0)
{
const char *Args[400];
@@ -90,8 +94,16 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
Args[i++] = "--status-fd";
Args[i++] = "3";
Args[i++] = "--ignore-time-conflict";
- Args[i++] = "--keyring";
- Args[i++] = pubringpath.c_str();
+ for (vector<string>::const_iterator K = keyrings.begin();
+ K != keyrings.end(); ++K)
+ {
+ Args[i++] = "--keyring";
+ Args[i++] = K->c_str();
+ if(i >= 395) {
+ std::clog << _("E: Too many keyrings should be passed to gpgv. Exiting.") << std::endl;
+ exit(111);
+ }
+ }
Configuration::Item const *Opts;
Opts = _config->Tree("Acquire::gpgv::Options");
@@ -104,7 +116,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
continue;
Args[i++] = Opts->Value.c_str();
if(i >= 395) {
- std::cerr << _("E: Argument list from Acquire::gpgv::Options too long. Exiting.") << std::endl;
+ std::clog << _("E: Argument list from Acquire::gpgv::Options too long. Exiting.") << std::endl;
exit(111);
}
}
@@ -113,14 +125,14 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
Args[i++] = outfile;
Args[i++] = NULL;
- if (_config->FindB("Debug::Acquire::gpgv", false))
+ if (Debug == true)
{
- std::cerr << "Preparing to exec: " << gpgvpath;
+ std::clog << "Preparing to exec: " << gpgvpath;
for(unsigned int j=0;Args[j] != NULL; j++)
- std::cerr << " " << Args[j];
- std::cerr << std::endl;
+ std::clog << " " << Args[j];
+ std::clog << std::endl;
}
- int nullfd = open("/dev/null", O_RDONLY);
+ int const nullfd = open("/dev/null", O_RDONLY);
close(fd[0]);
// Redirect output to /dev/null; we read from the status fd
dup2(nullfd, STDOUT_FILENO);
@@ -159,8 +171,8 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
break;
*(buffer+bufferoff) = '\0';
bufferoff = 0;
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Read: " << buffer << std::endl;
+ if (Debug == true)
+ std::clog << "Read: " << buffer << std::endl;
// Push the data into three separate vectors, which
// we later concatenate. They're kept separate so
@@ -168,33 +180,33 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
// it will be better.
if (strncmp(buffer, GNUPGBADSIG, sizeof(GNUPGBADSIG)-1) == 0)
{
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got BADSIG! " << std::endl;
+ if (Debug == true)
+ std::clog << "Got BADSIG! " << std::endl;
BadSigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
if (strncmp(buffer, GNUPGNOPUBKEY, sizeof(GNUPGNOPUBKEY)-1) == 0)
{
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got NO_PUBKEY " << std::endl;
+ if (Debug == true)
+ std::clog << "Got NO_PUBKEY " << std::endl;
NoPubKeySigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
if (strncmp(buffer, GNUPGNODATA, sizeof(GNUPGBADSIG)-1) == 0)
{
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got NODATA! " << std::endl;
+ if (Debug == true)
+ std::clog << "Got NODATA! " << std::endl;
BadSigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
if (strncmp(buffer, GNUPGKEYEXPIRED, sizeof(GNUPGKEYEXPIRED)-1) == 0)
{
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got KEYEXPIRED! " << std::endl;
+ if (Debug == true)
+ std::clog << "Got KEYEXPIRED! " << std::endl;
WorthlessSigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
if (strncmp(buffer, GNUPGREVKEYSIG, sizeof(GNUPGREVKEYSIG)-1) == 0)
{
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got REVKEYSIG! " << std::endl;
+ if (Debug == true)
+ std::clog << "Got REVKEYSIG! " << std::endl;
WorthlessSigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
if (strncmp(buffer, GNUPGGOODSIG, sizeof(GNUPGGOODSIG)-1) == 0)
@@ -204,17 +216,17 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
while (*p && isxdigit(*p))
p++;
*p = 0;
- if (_config->FindB("Debug::Acquire::gpgv", false))
- std::cerr << "Got GOODSIG, key ID:" << sig << std::endl;
+ if (Debug == true)
+ std::clog << "Got GOODSIG, key ID:" << sig << std::endl;
GoodSigners.push_back(string(sig));
}
}
fclose(pipein);
waitpid(pid, &status, 0);
- if (_config->FindB("Debug::Acquire::gpgv", false))
+ if (Debug == true)
{
- std::cerr << "gpgv exited\n";
+ std::clog << "gpgv exited\n";
}
if (WEXITSTATUS(status) == 0)
@@ -305,7 +317,7 @@ bool GPGVMethod::Fetch(FetchItem *Itm)
if (_config->FindB("Debug::Acquire::gpgv", false))
{
- std::cerr << "gpgv succeeded\n";
+ std::clog << "gpgv succeeded\n";
}
return true;