Getting the gpg key from an email address also checks gpg config for default-key
This commit is contained in:
parent
9927969e39
commit
2a7e6c323d
|
@ -262,8 +262,34 @@ function gpg_pubkey_from_email {
|
||||||
key_id=
|
key_id=
|
||||||
if [[ $key_owner_username != "root" ]]; then
|
if [[ $key_owner_username != "root" ]]; then
|
||||||
key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
|
key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
|
||||||
|
|
||||||
|
# If the default key is specified within gpg.conf
|
||||||
|
if [ -f /home/$key_owner_username/gpg.conf ]; then
|
||||||
|
if grep -q "default-key" /home/$key_owner_username/gpg.conf; then
|
||||||
|
default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key")
|
||||||
|
if [[ "$default_gpg_key" != *'#'* ]]; then
|
||||||
|
default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
|
||||||
|
if [ ${#default_gpg_key} -gt 3 ]; then
|
||||||
|
key_id=$(su -c "gpg --list-keys $default_gpg_key" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
|
key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
|
||||||
|
|
||||||
|
# If the default key is specified within gpg.conf
|
||||||
|
if [ -f /root/gpg.conf ]; then
|
||||||
|
if grep -q "default-key" /root/gpg.conf; then
|
||||||
|
default_gpg_key=$(cat /root/gpg.conf | grep "default-key")
|
||||||
|
if [[ "$default_gpg_key" != *'#'* ]]; then
|
||||||
|
default_gpg_key=$(cat /root/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
|
||||||
|
if [ ${#default_gpg_key} -gt 3 ]; then
|
||||||
|
key_id=$(gpg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo $key_id
|
echo $key_id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue