Commit 41050122 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Change $postpone_encrypt to use self-encrypt variables first.

The concept of postpone encryption is similar to self-encrypting on
send.  The problem is the $postpone_encrypt_as option doesn't take
into account whether PGP or S/MIME is being used.

Since we need to add the new options for self-encryption, modify
$postpone_encrypt to use them by default instead, falling back to
$postpone_encrypt_as if they are unset.  Note $postpone_encrypt_as is
deprecated in the documentation.
parent 54544e6a
......@@ -2070,7 +2070,8 @@ struct option_t MuttVars[] = {
/*
** .pp
** This is an additional key used to encrypt messages when $$pgp_self_encrypt
** is \fIset\fP. It should be in keyid or fingerprint form (e.g. 0x00112233).
** is \fIset\fP. It is also used to specify the key for $$postpone_encrypt.
** It should be in keyid or fingerprint form (e.g. 0x00112233).
** (PGP only)
*/
{ "pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1 },
......@@ -2292,15 +2293,16 @@ struct option_t MuttVars[] = {
/*
** .pp
** When \fIset\fP, postponed messages that are marked for encryption will be
** encrypted using the key in $$postpone_encrypt_as before saving.
** self-encrypted. Mutt will first try to encrypt using the value specified
** in $$pgp_self_encrypt_as or $$smime_self_encrypt_as. If those are not
** set, it will try the deprecated $$postpone_encrypt_as.
** (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 or fingerprint form (e.g. 0x00112233 for PGP or the
** hash-value that OpenSSL generates for S/MIME).
** This is a deprecated fall-back variable for $$postpone_encrypt.
** Please use $$pgp_self_encrypt_as or $$smime_self_encrypt_as.
** (Crypto only)
*/
#ifdef USE_SOCKET
......@@ -3121,8 +3123,9 @@ struct option_t MuttVars[] = {
/*
** .pp
** This is an additional certificate used to encrypt messages when
** $$smime_self_encrypt is \fIset\fP. It should be the
** hash-value that OpenSSL generates.
** $$smime_self_encrypt is \fIset\fP. It is also used to specify the
** certficate for $$postpone_encrypt. It should be the hash-value that
** OpenSSL generates.
** (S/MIME only)
*/
{ "smime_sign_command", DT_STR, R_NONE, UL &SmimeSignCommand, 0},
......
......@@ -1599,26 +1599,37 @@ main_loop:
if (msg->content->next)
msg->content = mutt_make_multipart (msg->content);
if (WithCrypto && option (OPTPOSTPONEENCRYPT) && PostponeEncryptAs
&& (msg->security & ENCRYPT))
if (WithCrypto && option (OPTPOSTPONEENCRYPT) && (msg->security & ENCRYPT))
{
int is_signed = msg->security & SIGN;
if (is_signed)
msg->security &= ~SIGN;
char *encrypt_as = NULL;
pgpkeylist = safe_strdup (PostponeEncryptAs);
if (mutt_protect (msg, pgpkeylist) == -1)
if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
encrypt_as = PgpSelfEncryptAs;
else if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
encrypt_as = SmimeSelfEncryptAs;
if (!(encrypt_as && *encrypt_as))
encrypt_as = PostponeEncryptAs;
if (encrypt_as && *encrypt_as)
{
int is_signed = msg->security & SIGN;
if (is_signed)
msg->security &= ~SIGN;
pgpkeylist = safe_strdup (encrypt_as);
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);
msg->content = mutt_remove_multipart (msg->content);
goto main_loop;
}
if (is_signed)
msg->security |= SIGN;
FREE (&pgpkeylist);
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment