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 }