changeset: 6394:8a2d9d352e2c
user: Kevin McCarthy <[email protected]>
date: Wed Nov 06 13:07:04 2013 -0800
link: http://dev.mutt.org/hg/mutt/rev/8a2d9d352e2c
Add option to encrypt postponed messages. (closes #3665)
This patch is based on Christian Brabandt's patch sent
to mutt-users.
Add two new configuration variables: $postpone_encrypt and
$postpone_encrypt_as. When $postpone_encrypt is set and a message is
marked for encryption, the message will be encrypted using the key
specified in $postpone_encrypt_as before saving the message.
In this patch, $postpone_encrypt_as must be specified. I experimented
with passing safe_strdup( NONULL (PostponeEncryptAs)) when unspecified,
but although gpg.conf has a default-key setting, I could not get it to
work properly. (pgpclassic gave an error message and gpgme sefaulted.)
Although not necessary, this patch turns off signing during encryption
of the postponed message (and turns it back on before saving), since
there is no need to sign the message yet.
diffs (79 lines):
diff -r 25430a489665 -r 8a2d9d352e2c globals.h
--- a/globals.h Fri Jan 09 14:22:01 2015 -0800
+++ b/globals.h Wed Nov 06 13:07:04 2013 -0800
@@ -108,6 +108,7 @@
#endif
WHERE char *PostIndentString;
WHERE char *Postponed;
+WHERE char *PostponeEncryptAs;
WHERE char *Prefix;
WHERE char *PrintCmd;
WHERE char *QueryCmd;
diff -r 25430a489665 -r 8a2d9d352e2c init.h
--- a/init.h Fri Jan 09 14:22:01 2015 -0800
+++ b/init.h Wed Nov 06 13:07:04 2013 -0800
@@ -2121,6 +2121,21 @@
** .pp
** Also see the $$postpone variable.
*/
+ { "postpone_encrypt", DT_BOOL, R_NONE, OPTPOSTPONEENCRYPT, 0 },
+ /*
+ ** .pp
+ ** When \fIset\fP, postponed messages that are marked for encryption will be
+ ** encrypted using the key in $$postpone_encrypt_as before saving.
+ ** (Crypto only)
+ */
+ { "postpone_encrypt_as", DT_STR, R_NONE, UL &PostponeEncryptAs, 0 },
+ /*
+ ** .pp
+ ** This is the key used to encrypt postponed messages. It should be in
+ ** keyid form (e.g. 0x00112233 for PGP or the hash-value that OpenSSL
+ ** generates for S/MIME).
+ ** (Crypto only)
+ */
#ifdef USE_SOCKET
{ "preconnect", DT_STR, R_NONE, UL &Preconnect, UL 0},
/*
diff -r 25430a489665 -r 8a2d9d352e2c mutt.h
--- a/mutt.h Fri Jan 09 14:22:01 2015 -0800
+++ b/mutt.h Wed Nov 06 13:07:04 2013 -0800
@@ -406,6 +406,7 @@
OPTPOPAUTHTRYALL,
OPTPOPLAST,
#endif
+ OPTPOSTPONEENCRYPT,
OPTPRINTDECODE,
OPTPRINTSPLIT,
OPTPROMPTAFTER,
diff -r 25430a489665 -r 8a2d9d352e2c send.c
--- a/send.c Fri Jan 09 14:22:01 2015 -0800
+++ b/send.c Wed Nov 06 13:07:04 2013 -0800
@@ -1555,6 +1555,28 @@
if (msg->content->next)
msg->content = mutt_make_multipart (msg->content);
+ if (WithCrypto && option (OPTPOSTPONEENCRYPT) && PostponeEncryptAs
+ && (msg->security & ENCRYPT))
+ {
+ int is_signed = msg->security & SIGN;
+ if (is_signed)
+ msg->security &= ~SIGN;
+
+ pgpkeylist = safe_strdup (PostponeEncryptAs);
+ if (mutt_protect (msg, pgpkeylist) == -1)
+ {
+ if (is_signed)
+ msg->security |= SIGN;
+ FREE (&pgpkeylist);
+ msg->content = mutt_remove_multipart (msg->content);
+ goto main_loop;
+ }
+
+ if (is_signed)
+ msg->security |= SIGN;
+ FREE (&pgpkeylist);
+ }
+
/*
* make sure the message is written to the right part of a maildir
* postponed folder.