pacman-key: fix permission checks for non-root operations

Removing lock-never from the default gpg.conf file exposed a couple of bugs
in the permission checks in pacman-key.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 49ebd856ec)
This commit is contained in:
Allan McRae 2024-04-03 10:52:21 +10:00
parent 2fdd017994
commit 78f17bae4d

View file

@ -266,12 +266,9 @@ check_keyring() {
exit 1 exit 1
fi fi
if (( (EXPORT || FINGER || LIST || VERIFY) && EUID != 0 )); then if (( !(EXPORT || FINGER || LISTKEYS || LISTSIGS || VERIFY) && EUID != 0 )); then
if ! grep -q "^[[:space:]]*lock-never[[:space:]]*$" ${PACMAN_KEYRING_DIR}/gpg.conf &>/dev/null; then error "$(gettext "You do not have sufficient permissions to run this command.")"
error "$(gettext "You do not have sufficient permissions to run this command.")" exit 1
msg "$(gettext "Use '%s' to correct the keyring permissions.")" "pacman-key --init"
exit 1
fi
fi fi
if (( LSIGNKEY || POPULATE )); then if (( LSIGNKEY || POPULATE )); then