Check the correct email address when generating a gpg key

This commit is contained in:
Bob Mottram 2017-09-18 22:51:22 +01:00
parent 9804c49a2c
commit 26a132b5c4
1 changed files with 4 additions and 4 deletions

View File

@ -102,15 +102,15 @@ function gpg_create_key {
echo $'Generating a new GPG key'
su -m root -c "gpg --homedir /home/$key_username/.gnupg --batch --full-gen-key /home/$key_username/gpg-genkey.conf" - $key_username
chown -R $key_username:$key_username /home/$key_username/.gnupg
KEY_EXISTS=$(gpg_key_exists "$key_username" "${key_username}@${HOSTNAME}")
KEY_EXISTS=$(gpg_key_exists "$key_username" "$MY_EMAIL_ADDRESS")
if [[ $KEY_EXISTS == "no" ]]; then
echo $"A GPG key for ${key_username}@${HOSTNAME} could not be created"
echo $"A GPG key for $MY_EMAIL_ADDRESS could not be created"
exit 63621
fi
shred -zu /home/$key_username/gpg-genkey.conf
CURR_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$key_username" "${key_username}@${HOSTNAME}")
CURR_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$key_username" "$MY_EMAIL_ADDRESS")
if [ ${#CURR_GPG_PUBLIC_KEY_ID} -lt 4 ]; then
echo $"GPG public key ID could not be obtained for ${key_username}@${HOSTNAME}"
echo $"GPG public key ID could not be obtained for $MY_EMAIL_ADDRESS"
exit 825292
fi
gpg_set_permissions $key_username