summaryrefslogtreecommitdiff
path: root/cmdline/apt-key.in
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-02-06 18:43:55 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-09-27 00:12:14 +0200
commit0b94a7bc2ebb42453d9e22dc58dde76b9261de50 (patch)
tree662d9d82f789db7f19aca211aacf548bce89a13b /cmdline/apt-key.in
parent33a2267214eed2a11281c9f93b8cf10b4c436d94 (diff)
miscellaneous small cleanups in apt-key
Git-Dch: Ignore
Diffstat (limited to 'cmdline/apt-key.in')
-rw-r--r--cmdline/apt-key.in24
1 files changed, 7 insertions, 17 deletions
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in
index 21d692631..a9a729cce 100644
--- a/cmdline/apt-key.in
+++ b/cmdline/apt-key.in
@@ -166,9 +166,7 @@ remove_key_from_keyring() {
fi
local GPG="$GPG_CMD --keyring $KEYRINGFILE"
- while [ -n "$1" ]; do
- local KEY="$1"
- shift
+ for KEY in "$@"; do
# check if the key is in this keyring: the key id is in the 5 column at the end
if ! get_fingerprints_of_keyring "$KEYRINGFILE" | grep -q "^[0-9A-F]*${KEY}$"; then
continue
@@ -226,18 +224,11 @@ foreach_keyring_do() {
fi
}
-list_keys_from_keyring() {
+run_cmd_on_keyring() {
local KEYRINGFILE="$1"
shift
- # don't show the error message if this keyring doesn't include the key
- $GPG_CMD --keyring "$KEYRINGFILE" --batch --list-keys "$@" 2>/dev/null || true
-}
-
-fingerprint_keys_from_keyring() {
- local KEYRINGFILE="$1"
- shift
- # don't show the error message if this keyring doesn't include the fingerprint
- $GPG_CMD --keyring "$KEYRINGFILE" --batch --fingerprint "$@" 2>/dev/null || true
+ # fingerprint and co will fail if key isn't in this keyring
+ $GPG_CMD --keyring "$KEYRINGFILE" --batch "$@" 2>/dev/null || true
}
import_keys_from_keyring() {
@@ -267,10 +258,9 @@ merge_back_changes() {
# merge all updated keys
foreach_keyring_do 'merge_keys_into_keyrings' "${GPGHOMEDIR}/pubring.gpg"
fi
- # no look for keys which were added or removed
+ # look for keys which were added or removed
get_fingerprints_of_keyring "${GPGHOMEDIR}/pubring.orig.gpg" > "${GPGHOMEDIR}/pubring.orig.keylst"
get_fingerprints_of_keyring "${GPGHOMEDIR}/pubring.gpg" > "${GPGHOMEDIR}/pubring.keylst"
- #echo >&2 "MERGE BACK"
sort "${GPGHOMEDIR}/pubring.keylst" "${GPGHOMEDIR}/pubring.orig.keylst" | uniq --unique | while read key; do
if grep -q "^${key}$" "${GPGHOMEDIR}/pubring.orig.keylst"; then
# key isn't part of new keyring, so remove
@@ -445,10 +435,10 @@ case "$command" in
merge_back_changes
;;
list)
- foreach_keyring_do 'list_keys_from_keyring' "$@"
+ foreach_keyring_do 'run_cmd_on_keyring' --list-keys "$@"
;;
finger*)
- foreach_keyring_do 'fingerprint_keys_from_keyring' "$@"
+ foreach_keyring_do 'run_cmd_on_keyring' --fingerprint "$@"
;;
export|exportall)
foreach_keyring_do 'import_keys_from_keyring' "${GPGHOMEDIR}/pubring.gpg"