summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2011-07-09 03:28:57 +0200
committerAllan McRae <allan@archlinux.org>2011-07-19 02:27:53 +0200
commitfec10d4a65ebfdcac1f0e3dec9e24c1fe67bb52a (patch)
tree1e2258653d9680695c7a33a398821f68a51eb6c8 /scripts
parent74f6d717a3e25957ca5f3cf80897b218b990eea8 (diff)
downloadpacman-fec10d4a65ebfdcac1f0e3dec9e24c1fe67bb52a.tar.gz
pacman-fec10d4a65ebfdcac1f0e3dec9e24c1fe67bb52a.tar.xz
pacman-key: check only a single operation has been specified
Follow the example of gpg and only allow a single operation to be specified each time. Prevents having to deal with conflicting variable names and potential issues due to the order in which the operations are run. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/pacman-key.sh.in16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 4366ca45..776fc0e9 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -308,6 +308,22 @@ PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:-@sysconfdir@/pacman.d/gnupg}
GPG_PACMAN="gpg --homedir ${PACMAN_KEYRING_DIR} --no-permission-warning"
+# check only a single operation has been given
+numopt=$(( ADD + DELETE + EDITKEY + EXPORT + FINGER + LIST + RECEIVE + RELOAD + UPDATEBD ))
+
+if (( ! numopt )); then
+ error "$(gettext "No operations specified")"
+ echo
+ usage
+ exit 1
+fi
+
+if (( numopt != 1 )); then
+ error "$(gettext "Multiple operations specified")"
+ printf "$(gettext "Please run %s with each operation separately\n")" "pacman-key"
+ exit 1
+fi
+
(( ADD )) && ${GPG_PACMAN} --quiet --batch --import "${KEYFILES[@]}"
(( DELETE )) && ${GPG_PACMAN} --quiet --batch --delete-key --yes "${KEYIDS[@]}"