Package: mutt-patched
Severity: wishlist
Tags: patch

Hi,

please add a patch to be able to automatically encrypt postponed messages if it
is marked for encryption. There is also a upstream bug report about this. The
attached patch is based on top of the existing patches. The patch is from Kevin
McCarthy.

http://dev.mutt.org/trac/ticket/3665

Form Kevins patch description:
> 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.


Best,
Philip



-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (700, 'testing'), (550, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.14-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
# HG changeset patch
# User Kevin McCarthy <ke...@8t8.us>
# Date 1383772024 28800
#      Wed Nov 06 13:07:04 2013 -0800
# Node ID 69a5326cbccd3c745e864fa068ea0ff086224bf1
# Parent  3306cb186f49e83edf15aac91c51f4c6131ef8fe
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.

--- a/globals.h
+++ b/globals.h
@@ -119,6 +119,7 @@
 #endif
 WHERE char *PostIndentString;
 WHERE char *Postponed;
+WHERE char *PostponeEncryptAs;
 WHERE char *Prefix;
 WHERE char *PrintCmd;
 WHERE char *QueryCmd;
--- a/init.h
+++ b/init.h
@@ -2356,6 +2356,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},
   /*
--- a/mutt.h
+++ b/mutt.h
@@ -432,6 +432,7 @@
   OPTPOPAUTHTRYALL,
   OPTPOPLAST,
 #endif
+  OPTPOSTPONEENCRYPT,
   OPTPRINTDECODE,
   OPTPRINTSPLIT,
   OPTPROMPTAFTER,
--- a/send.c
+++ b/send.c
@@ -1677,6 +1677,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.

Reply via email to