Encrypt sent items with the users public key

This commit is contained in:
Bob Mottram 2015-03-29 14:31:36 +01:00
parent 89a8e6e164
commit 2e47f648ae
1 changed files with 12 additions and 1 deletions

View File

@ -5616,6 +5616,11 @@ function encrypt_outgoing_email {
return return
fi fi
if [ ! -f /home/$MY_USERNAME/.muttrc ]; then
return
fi
# obtain your public key ID
if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then 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}') 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 if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then
@ -5623,7 +5628,13 @@ function encrypt_outgoing_email {
fi fi
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 echo 'encrypt_outgoing_email' >> $COMPLETION_FILE
} }