mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 13:07:58 -05:00
pacman-key: factor out validate_with_gpg() method
This was copy-pasted code for the most part once the filename was factored out. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
33685b960d
commit
067721cbff
@ -196,6 +196,18 @@ check_keyring() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate_with_gpg() {
|
||||||
|
msg2 "$(gettext "Verifying %s...")" "$1"
|
||||||
|
if [[ ! -f "$1.sig" ]]; then
|
||||||
|
error "$(gettext "File %s is unsigned, cannot continue.")" "$1"
|
||||||
|
return 1
|
||||||
|
elif ! "${GPG_PACMAN[@]}" --verify "$1.sig"; then
|
||||||
|
error "$(gettext "The signature of file %s is not valid.")" "$1"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
verify_keyring_input() {
|
verify_keyring_input() {
|
||||||
local ret=0;
|
local ret=0;
|
||||||
local KEYRING_IMPORT_DIR='@pkgdatadir@/keyrings'
|
local KEYRING_IMPORT_DIR='@pkgdatadir@/keyrings'
|
||||||
@ -205,25 +217,11 @@ verify_keyring_input() {
|
|||||||
local keyring keyfile
|
local keyring keyfile
|
||||||
for keyring in "${KEYRINGIDS[@]}"; do
|
for keyring in "${KEYRINGIDS[@]}"; do
|
||||||
keyfile="${KEYRING_IMPORT_DIR}/${keyring}.gpg"
|
keyfile="${KEYRING_IMPORT_DIR}/${keyring}.gpg"
|
||||||
msg2 "$(gettext "Verifying %s...")" "${keyfile}"
|
validate_with_gpg "${keyfile}" || ret=1
|
||||||
if [[ ! -f "${keyfile}.sig" ]]; then
|
|
||||||
error "$(gettext "File %s is unsigned, cannot continue.")" "${keyfile}"
|
|
||||||
ret=1
|
|
||||||
elif ! "${GPG_PACMAN[@]}" --verify "${keyfile}.sig"; then
|
|
||||||
error "$(gettext "The signature of file %s is not valid.")" "${keyfile}"
|
|
||||||
ret=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
keyfile="${KEYRING_IMPORT_DIR}/${keyring}-revoked"
|
keyfile="${KEYRING_IMPORT_DIR}/${keyring}-revoked"
|
||||||
if [[ -f "${keyfile}" ]]; then
|
if [[ -f "${keyfile}" ]]; then
|
||||||
msg2 "$(gettext "Verifying %s...")" "${keyfile}"
|
validate_with_gpg "${keyfile}" || ret=1
|
||||||
if [[ ! -f "${keyfile}.sig" ]]; then
|
|
||||||
error "$(gettext "File %s is unsigned, cannot continue.")" "${keyfile}"
|
|
||||||
ret=1
|
|
||||||
elif ! "${GPG_PACMAN[@]}" --verify "${keyfile}.sig"; then
|
|
||||||
error "$(gettext "The signature of file %s is not valid.")" "${keyfile}"
|
|
||||||
ret=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user