Package: mutt
Version: 1.5.11-2
Priority: wishlist

(This bug has been reported upstream as bug #2122, I'm sending this to the
Debian maintainer in case he thinks it would be reasonable to include this
into sid to get wider testing)

Currently, GPG only encrypts messages to the To:, CC: or Bcc: but *not* to the
From: of an email message. This means that any user that sends an encrypted
mail to any other user will not be able to read the e-mail in the future if
he is under default configuration in Debian.

I don't see any reason for outgoing mail to not be encrypted to the sender's
key so he is able to read it in the future and other software (i.e. PGP
Desktop) does this by default.

I suggest the attached (tested) patch be introduced to mutt to introduce this
new behavior. The patch has been produced against the latest mutt version.
The only minor inconvenience is that if the user is holding more that one key
in his public keyring with his own e-mail address he will always be asked
which one to use.

In order to reproduce this issue:

1.- confirm your ~/.gnupg/options does not have an 'encrypt-to YourKeyID'
statement and that your muttrc has not redefined the gpg commands used by
default in Debian's muttrc
2.- Send a PGP/GPG encrypted mail to someone else and store it in a folder
3.- Try to read the stored message

The current workarounds to this issue is either adding an 
'encrypt-to YourKeyID' in gnupg.options or e-mailing to yourself (in
Bcc: or To:) so that either a) gnupg encrypts to you by default or b)
mutt tells gnupg to encrypt to you (adds you to the keylist).

The first one affects not only mutt by the default behaviour of gnupg which
might not be convenient to some users (although it seems to be the most used
workaround for people that have suffered this issue). The second one seems 
klunky and is prone to error, if your forget to do it then you "lose" the
e-mail as you are unable to read it at all (well, you can ask the recipient
to send you a copy of your e-mail but that makes you look stupid).

I *think* other OSS MUAs (Kmail, Evolution, Mozilla-Thunderbird) do this by
default already, based on experience exchanging mails with users of those.
But it would be nice to check it out first.


Regards

Javier

diff -Nru mutt-1.5.11/debian/changelog mutt-1.5.11.encrypt.from/debian/changelog
--- mutt-1.5.11/debian/changelog        2005-10-28 19:14:32.000000000 +0200
+++ mutt-1.5.11.encrypt.from/debian/changelog   2005-10-28 18:46:17.000000000 
+0200
@@ -1,3 +1,15 @@
+mutt (1.5.11-2.1) unstable; urgency=low
+
+  * Patch:
+    + 101_encrypt_to_sender:  Encrypt messages to the From: user too as not
+      doing it prevents users from reading encrypted e-mail they've sent. This
+      can be circumvented currently by using the 'encrypt-to' GnuPG option or
+      Bcc mailing yourself, but there is really no reason why outgoing mail
+      should not be encrypted by default to the sender as well as the
+      recipients.
+
+ -- Javier Fernandez-Sanguino Pen~a <[EMAIL PROTECTED]>  Fri, 28 Oct 2005 
18:40:29 +0200
+
 mutt (1.5.11-2) unstable; urgency=low (but fixes critical bug not in testing)
 
   * The fix for coping with mboxes bigger than 2 GB introduced a bug affecting
diff -Nru mutt-1.5.11/debian/patches/101_encrypt_to_sender 
mutt-1.5.11.encrypt.from/debian/patches/101_encrypt_to_sender
--- mutt-1.5.11/debian/patches/101_encrypt_to_sender    1970-01-01 
01:00:00.000000000 +0100
+++ mutt-1.5.11.encrypt.from/debian/patches/101_encrypt_to_sender       
2005-10-28 19:10:39.000000000 +0200
@@ -0,0 +1,268 @@
+--- mutt-1.5.11.orig/crypt.c   2005-10-28 18:40:04.000000000 +0200
++++ mutt-1.5.11/crypt.c        2005-10-28 18:40:13.000000000 +0200
+@@ -715,7 +715,7 @@
+      if ((WithCrypto & APPLICATION_PGP)
+          && (msg->security & APPLICATION_PGP))
+      {
+-       if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
++       if ((*keylist = crypt_pgp_findkeys (msg->env->from, msg->env->to, 
msg->env->cc,
+                                      msg->env->bcc)) == NULL)
+            return (-1);
+        unset_option (OPTPGPCHECKTRUST);
+@@ -723,7 +723,7 @@
+      if ((WithCrypto & APPLICATION_SMIME)
+          && (msg->security & APPLICATION_SMIME))
+      {
+-       if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
++       if ((*keylist = crypt_smime_findkeys (msg->env->from, msg->env->to, 
msg->env->cc,
+                                                    msg->env->bcc)) == NULL)
+            return (-1);
+      }
+diff -u mutt-1.5.11.orig/cryptglue.c mutt-1.5.11/cryptglue.c
+--- mutt-1.5.11.orig/cryptglue.c       2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/cryptglue.c    2005-10-28 18:55:51.000000000 +0200
+@@ -200,10 +200,10 @@
+ 
+ /* This routine attempts to find the keyids of the recipients of a
+    message.  It returns NULL if any of the keys can not be found.  */
+-char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *crypt_pgp_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc)
+ {
+   if (CRYPT_MOD_CALL_CHECK (PGP, findkeys))
+-    return (CRYPT_MOD_CALL (PGP, findkeys)) (to, cc, bcc);
++    return (CRYPT_MOD_CALL (PGP, findkeys)) (from, to, cc, bcc);
+ 
+   return NULL;
+ }
+@@ -327,10 +327,10 @@
+ 
+ /* This routine attempts to find the keyids of the recipients of a
+    message.  It returns NULL if any of the keys can not be found.  */
+-char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *crypt_smime_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc)
+ {
+   if (CRYPT_MOD_CALL_CHECK (SMIME, findkeys))
+-    return (CRYPT_MOD_CALL (SMIME, findkeys)) (to, cc, bcc);
++    return (CRYPT_MOD_CALL (SMIME, findkeys)) (from, to, cc, bcc);
+ 
+   return NULL;
+ }
+diff -u mutt-1.5.11.orig/crypt-gpgme.c mutt-1.5.11/crypt-gpgme.c
+--- mutt-1.5.11.orig/crypt-gpgme.c     2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/crypt-gpgme.c  2005-10-28 18:56:28.000000000 +0200
+@@ -4080,14 +4080,14 @@
+   return (keylist);
+ }
+ 
+-char *pgp_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *pgp_gpgme_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc)
+ {
+-  return find_keys (to, cc, bcc, APPLICATION_PGP);
++  return find_keys (from, to, cc, bcc, APPLICATION_PGP);
+ }
+ 
+-char *smime_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *smime_gpgme_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc)
+ {
+-  return find_keys (to, cc, bcc, APPLICATION_SMIME);
++  return find_keys (from, to, cc, bcc, APPLICATION_SMIME);
+ }
+ 
+ /*
+diff -u mutt-1.5.11.orig/crypt-gpgme.h mutt-1.5.11/crypt-gpgme.h
+--- mutt-1.5.11.orig/crypt-gpgme.h     2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/crypt-gpgme.h  2005-10-28 18:56:40.000000000 +0200
+@@ -24,8 +24,8 @@
+ void pgp_gpgme_init (void);
+ void smime_gpgme_init (void);
+ 
+-char *pgp_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+-char *smime_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
++char *pgp_gpgme_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc);
++char *smime_gpgme_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc);
+ 
+ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign);
+ BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist);
+diff -u mutt-1.5.11.orig/crypt-mod.h mutt-1.5.11/crypt-mod.h
+--- mutt-1.5.11.orig/crypt-mod.h       2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/crypt-mod.h    2005-10-28 18:56:51.000000000 +0200
+@@ -43,7 +43,7 @@
+ typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags,
+                                                            char *keylist);
+ typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
+-typedef char *(*crypt_func_findkeys_t) (ADDRESS *to,
++typedef char *(*crypt_func_findkeys_t) (ADDRESS *from, ADDRESS *to,
+                                         ADDRESS *cc, ADDRESS *bcc);
+ typedef BODY *(*crypt_func_sign_message_t) (BODY *a);
+ typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist,
+diff -u mutt-1.5.11.orig/crypt-mod-pgp-classic.c 
mutt-1.5.11/crypt-mod-pgp-classic.c
+--- mutt-1.5.11.orig/crypt-mod-pgp-classic.c   2005-10-28 18:46:22.000000000 
+0200
++++ mutt-1.5.11/crypt-mod-pgp-classic.c        2005-10-28 18:56:57.000000000 
+0200
+@@ -46,9 +46,9 @@
+   return pgp_application_pgp_handler (m, s);
+ }
+ 
+-static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++static char *crypt_mod_pgp_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, 
ADDRESS *bcc)
+ {
+-  return pgp_findKeys (to, cc, bcc);
++  return pgp_findKeys (from, to, cc, bcc);
+ }
+ 
+ static BODY *crypt_mod_pgp_sign_message (BODY *a)
+diff -u mutt-1.5.11.orig/crypt-mod-pgp-gpgme.c 
mutt-1.5.11/crypt-mod-pgp-gpgme.c
+--- mutt-1.5.11.orig/crypt-mod-pgp-gpgme.c     2005-10-28 18:46:22.000000000 
+0200
++++ mutt-1.5.11/crypt-mod-pgp-gpgme.c  2005-10-28 18:57:09.000000000 +0200
+@@ -65,9 +65,9 @@
+   return pgp_gpgme_check_traditional (fp, b, tagged_only);
+ }
+ 
+-static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++static char *crypt_mod_pgp_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, 
ADDRESS *bcc)
+ {
+-  return pgp_gpgme_findkeys (to, cc, bcc);
++  return pgp_gpgme_findkeys (from, to, cc, bcc);
+ }
+ 
+ static BODY *crypt_mod_pgp_sign_message (BODY *a)
+diff -u mutt-1.5.11.orig/crypt-mod-smime-classic.c 
mutt-1.5.11/crypt-mod-smime-classic.c
+--- mutt-1.5.11.orig/crypt-mod-smime-classic.c 2005-10-28 18:46:22.000000000 
+0200
++++ mutt-1.5.11/crypt-mod-smime-classic.c      2005-10-28 18:57:13.000000000 
+0200
+@@ -46,9 +46,9 @@
+   return smime_application_smime_handler (m, s);
+ }
+ 
+-static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++static char *crypt_mod_smime_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS 
*cc, ADDRESS *bcc)
+ {
+-  return smime_findKeys (to, cc, bcc);
++  return smime_findKeys (from, to, cc, bcc);
+ }
+ 
+ static BODY *crypt_mod_smime_sign_message (BODY *a)
+diff -u mutt-1.5.11.orig/crypt-mod-smime-gpgme.c 
mutt-1.5.11/crypt-mod-smime-gpgme.c
+--- mutt-1.5.11.orig/crypt-mod-smime-gpgme.c   2005-10-28 18:46:22.000000000 
+0200
++++ mutt-1.5.11/crypt-mod-smime-gpgme.c        2005-10-28 18:57:18.000000000 
+0200
+@@ -55,9 +55,9 @@
+   return smime_gpgme_application_handler (m, s);
+ }
+ 
+-static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++static char *crypt_mod_smime_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS 
*cc, ADDRESS *bcc)
+ {
+-  return smime_gpgme_findkeys (to, cc, bcc);
++  return smime_gpgme_findkeys (from, to, cc, bcc);
+ }
+ 
+ static BODY *crypt_mod_smime_sign_message (BODY *a)
+diff -u mutt-1.5.11.orig/mutt_crypt.h mutt-1.5.11/mutt_crypt.h
+--- mutt-1.5.11.orig/mutt_crypt.h      2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/mutt_crypt.h   2005-10-28 18:52:40.000000000 +0200
+@@ -196,8 +196,8 @@
+ BODY *crypt_pgp_make_key_attachment (char *tempf);
+ 
+ /* This routine attempts to find the keyids of the recipients of a
+-   message.  It returns NULL if any of the keys can not be found.  */
+-char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
++   message as well as its sender.  It returns NULL if any of the keys can not 
be found.  */
++char *crypt_pgp_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc);
+ 
+ /* Create a new body with a PGP signed message from A. */
+ BODY *crypt_pgp_sign_message (BODY *a);
+@@ -245,8 +245,8 @@
+ char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public);
+ 
+ /* This routine attempts to find the keyids of the recipients of a
+-   message.  It returns NULL if any of the keys can not be found.  */
+-char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
++   message as well as its sender.  It returns NULL if any of the keys can not 
be found.  */
++char *crypt_smime_findkeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS 
*bcc);
+ 
+ /* fixme: Needs documentation. */
+ BODY *crypt_smime_sign_message (BODY *a);
+diff -u mutt-1.5.11.orig/pgp.c mutt-1.5.11/pgp.c
+--- mutt-1.5.11.orig/pgp.c     2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/pgp.c  2005-10-28 19:05:22.000000000 +0200
+@@ -1118,7 +1118,7 @@
+ /* This routine attempts to find the keyids of the recipients of a message.
+  * It returns NULL if any of the keys can not be found.
+  */
+-char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *pgp_findKeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+ {
+   char *keyID, *keylist = NULL, *t;
+   size_t keylist_size = 0;
+@@ -1131,13 +1131,14 @@
+ 
+   const char *fqdn = mutt_fqdn (1);
+ 
+-  for (i = 0; i < 3; i++) 
++  for (i = 0; i < 4; i++) 
+   {
+     switch (i)
+     {
+-      case 0: p = to; break;
+-      case 1: p = cc; break;
+-      case 2: p = bcc; break;
++      case 0: p = from; break;
++      case 1: p = to; break;
++      case 2: p = cc; break;
++      case 3: p = bcc; break;
+       default: abort ();
+     }
+     
+diff -u mutt-1.5.11.orig/pgp.h mutt-1.5.11/pgp.h
+--- mutt-1.5.11.orig/pgp.h     2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/pgp.h  2005-10-28 19:05:30.000000000 +0200
+@@ -49,7 +49,7 @@
+ pgp_key_t pgp_getkeybyaddr (ADDRESS *, short, pgp_ring_t);
+ pgp_key_t pgp_getkeybystr (char *, short, pgp_ring_t);
+ 
+-char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
++char *pgp_findKeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+ 
+ void pgp_forget_passphrase (void);
+ int pgp_application_pgp_handler (BODY *, STATE *);
+diff -u mutt-1.5.11.orig/smime.c mutt-1.5.11/smime.c
+--- mutt-1.5.11.orig/smime.c   2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/smime.c        2005-10-28 19:05:51.000000000 +0200
+@@ -746,7 +746,7 @@
+  * It returns NULL if any of the keys can not be found.
+  */
+ 
+-char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
++char *smime_findKeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+ {
+   char *keyID, *keylist = NULL;
+   size_t keylist_size = 0;
+@@ -758,13 +758,14 @@
+ 
+   const char *fqdn = mutt_fqdn (1);
+   
+-  for (i = 0; i < 3; i++)
++  for (i = 0; i < 4; i++)
+   {
+     switch (i)
+     {
+-      case 0: p = to; break;
+-      case 1: p = cc; break;
+-      case 2: p = bcc; break;
++      case 0: p = from; break;
++      case 1: p = to; break;
++      case 2: p = cc; break;
++      case 3: p = bcc; break;
+       default: abort ();
+     }
+     
+diff -u mutt-1.5.11.orig/smime.h mutt-1.5.11/smime.h
+--- mutt-1.5.11.orig/smime.h   2005-10-28 18:46:22.000000000 +0200
++++ mutt-1.5.11/smime.h        2005-10-28 19:05:58.000000000 +0200
+@@ -50,7 +50,7 @@
+ 
+ char* smime_ask_for_key (char *, char *, short);
+ 
+-char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
++char *smime_findKeys (ADDRESS *from, ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+ 
+ void  smime_invoke_import (char *, char *);
+ 

Attachment: signature.asc
Description: Digital signature

Reply via email to