From 2e47f648ae812439038a0f7ec9184273e4cbd020 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Mar 2015 14:31:36 +0100 Subject: [PATCH] Encrypt sent items with the users public key --- src/freedombone | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/freedombone b/src/freedombone index 46691158..159ddb47 100755 --- a/src/freedombone +++ b/src/freedombone @@ -5616,6 +5616,11 @@ function encrypt_outgoing_email { return fi + if [ ! -f /home/$MY_USERNAME/.muttrc ]; then + return + fi + + # obtain your public key ID if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then MY_GPG_PUBLIC_KEY_ID=$(su -c "gpg --list-keys $MY_EMAIL_ADDRESS | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}') if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then @@ -5623,7 +5628,13 @@ function encrypt_outgoing_email { fi fi - sed -i "s|#encrypt-to .*|hidden-encrypt-to $MY_GPG_PUBLIC_KEY_ID|g" /home/$MY_USERNAME/.gnupg/gpg.conf + if ! grep -q "pgp_encrypt_only_command" /home/$MY_USERNAME/.muttrc; then + sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to $MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc + fi + + if ! grep -q "pgp_encrypt_sign_command" /home/$MY_USERNAME/.muttrc; then + sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to $MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc + fi echo 'encrypt_outgoing_email' >> $COMPLETION_FILE }