diff --git a/src/freedombone-controlpanel-user b/src/freedombone-controlpanel-user index 1b16349d..0a3e4ad4 100755 --- a/src/freedombone-controlpanel-user +++ b/src/freedombone-controlpanel-user @@ -33,6 +33,8 @@ PROJECT_NAME='freedombone' export TEXTDOMAIN=${PROJECT_NAME}-controlpanel-user export TEXTDOMAINDIR="/usr/share/locale" +MY_EMAIL_ADDRESS=$USER@$HOSTNAME + function any_key { echo ' ' read -n1 -r -p $"Press any key to continue..." key @@ -345,7 +347,6 @@ function block_unblock_subject { } function show_gpg_key { - MY_EMAIL_ADDRESS=$USER@$HOSTNAME GPG_ID=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}') GPG_FINGERPRINT=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "key fingerprint" | head -n 1 | awk -F '= ' '{print $2}') GPG_DATE=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $2}') @@ -364,7 +365,7 @@ function add_gpg_key { case $sel in 0) ADD_EMAIL_ADDRESS=$(<$data) - if [ ${#ADD_EMAIL_ADDRESS} -gt 1 ]; then + if [ ${#ADD_EMAIL_ADDRESS} -gt 2 ]; then if [[ $ADD_EMAIL_ADDRESS == *"@"* && $ADD_EMAIL_ADDRESS == *"."* ]]; then clear gpg --search-keys $ADD_EMAIL_ADDRESS @@ -376,10 +377,36 @@ function add_gpg_key { fi ;; esac - } function remove_gpg_key { + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --title $"Remove someone's PGP/GPG key" \ + --backtitle $"Freedombone User Control Panel" \ + --inputbox $"Enter their email address below" 8 60 2>$data + sel=$? + case $sel in + 0) + REMOVE_EMAIL_ADDRESS=$(<$data) + if [ ${#REMOVE_EMAIL_ADDRESS} -gt 2 ]; then + if [[ $REMOVE_EMAIL_ADDRESS == *"@"* && $REMOVE_EMAIL_ADDRESS == *"."* ]]; then + if [[ $REMOVE_EMAIL_ADDRESS != $MY_EMAIL_ADDRESS ]]; then + clear + gpg --delete-key $REMOVE_EMAIL_ADDRESS + else + dialog --title $"Remove someone's PGP/GPG key" \ + --backtitle $"Freedombone User Control Panel" \ + --msgbox $"It's not a good idea to remove your own encryption key" 6 65 + fi + else + dialog --title $"Unrecognised email address" \ + --backtitle $"Freedombone User Control Panel" \ + --msgbox $"This doesn't look like an email address" 6 50 + fi + fi + ;; + esac } function add_ssh_key {