From bdf4dd3285e76cebcd4fd905d63bd6b184d02269 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 26 Oct 2015 19:16:26 +0000 Subject: [PATCH] Encrypt sent items --- src/freedombone-adduser | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/freedombone-adduser b/src/freedombone-adduser index c3109468..490d3067 100755 --- a/src/freedombone-adduser +++ b/src/freedombone-adduser @@ -28,6 +28,12 @@ if [ ! -d /home/$MY_USERNAME/Maildir ]; then exit 4 fi +if grep -q "set from=" /home/$MY_USERNAME/.muttrc; then + sed -i "s|set from=.*|set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'|g" /home/$MY_USERNAME/.muttrc +else + echo "set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'" >> /home/$MY_USERNAME/.muttrc +fi + # generate a gpg key echo "Making a GPG key for $MY_USERNAME@$HOSTNAME" mkdir /home/$MY_USERNAME/.gnupg @@ -64,6 +70,21 @@ if [ ! -f $MY_GPG_PUBLIC_KEY ]; then exit 5 fi +# encrypt outgoing mail to the "sent" folder +if ! grep -q "pgp_encrypt_only_command" /home/$MY_USERNAME/.muttrc; then + echo '' >> /home/$MY_USERNAME/.muttrc + echo '# Encrypt items in the Sent folder' >> /home/$MY_USERNAME/.muttrc + echo "set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc +else + 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 0x$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 + echo "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 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc +else + 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 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc +fi + if ! grep -q "Change your GPG password" /home/$MY_USERNAME/README; then echo '' >> /home/$MY_USERNAME/README echo '' >> /home/$MY_USERNAME/README @@ -100,7 +121,7 @@ freedombone-addxmpp -e "$MY_USERNAME@$HOSTNAME" -p "$NEW_USER_PASSWORD" if [ ! "$?" = "0" ]; then echo "XMPP account not created" userdel -r $MY_USERNAME - exit 6 + exit 6 fi clear