summaryrefslogtreecommitdiff
path: root/cmdline/apt-key.in
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-07-31 09:27:19 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-07-31 09:56:26 +0200
commit4039798d971752325d097bfbdc9011b5e9efd29c (patch)
treebee4ac88bc565ab6a61f01bbfe379ce19098c215 /cmdline/apt-key.in
parent7303e11ff28f920a6277c159aa46f80c007350bb (diff)
downloadapt-4039798d971752325d097bfbdc9011b5e9efd29c.tar.gz
apt-key: kill gpg-agent explicitly in cleanup
apt-key has (usually) no secret key material so it doesn't really need the agent at all, but newer gpgs insist on starting it anyhow. The agents die off rather quickly after the underlying home-directory is cleaned up, but that is still not fast enough for tools like sbuild which want to unmount but can't as the agent is still hanging onto a non-existent homedir. Reported-By: Johannes 'josch' Schauer on IRC
Diffstat (limited to 'cmdline/apt-key.in')
-rw-r--r--cmdline/apt-key.in14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in
index 511c91c16..80aacfa5e 100644
--- a/cmdline/apt-key.in
+++ b/cmdline/apt-key.in
@@ -480,6 +480,14 @@ if [ -z "$command" ]; then
fi
shift
+cleanup_gpg_home() {
+ if [ -z "$GPGHOMEDIR" ]; then return; fi
+ if command_available 'gpgconf'; then
+ GNUPGHOME="${GPGHOMEDIR}" gpgconf --kill gpg-agent
+ fi
+ rm -rf "$GPGHOMEDIR"
+}
+
create_gpg_home() {
# gpg needs (in different versions more or less) files to function correctly,
# so we give it its own homedir and generate some valid content for it later on
@@ -491,8 +499,12 @@ create_gpg_home() {
fi
fi
GPGHOMEDIR="$(mktemp -d)"
- CURRENTTRAP="${CURRENTTRAP} rm -rf '$(escape_shell "${GPGHOMEDIR}")';"
+ CURRENTTRAP="${CURRENTTRAP} cleanup_gpg_home;"
trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+ if [ -z "$GPGHOMEDIR" ]; then
+ echo "ERROR: Could not create temporary gpg home directory in apt-key ($TMPDIR)"
+ exit 28
+ fi
chmod 700 "$GPGHOMEDIR"
}