Subject: Re: bug#37025: [found the culprit]

From: Teemu Likonen <[email-masked]>
Date: Thu, 15 Aug 2019 07:48:24 +0300

Glenn Morris [2019-08-14T21:39:37-04] wrote:

> Teemu Likonen wrote:
>> Thanks for the report and bisecting. I think we can fix the bug by
>> including "--sender" option only with openpgp protocol (i.e. gpg).

Because --sender is an OpenPGP thing (gpg) it is logical to narrow its
use to that protocol only. Here's the first fix:

diff --git i/lisp/epg.el w/lisp/epg.el
index ce58c520f1..905440d183 100644
--- i/lisp/epg.el
+++ w/lisp/epg.el
@@ -1618,7 +1618,8 @@ epg-start-sign
 				      (car (epg-key-sub-key-list signer)))))
 			     (epg-context-signers context)))
                      (let ((sender (epg-context-sender context)))
-                       (when (stringp sender)
+                       (when (and (eql 'OpenPGP (epg-context-protocol context))
+                                  (stringp sender))
                          (list "--sender" sender)))
 		     (epg--args-from-sig-notations
 		      (epg-context-sig-notations context))
@@ -1714,7 +1715,8 @@ epg-start-encrypt
 					  (car (epg-key-sub-key-list
 						signer)))))
 				 (epg-context-signers context))))
-		     (if sign
+		     (if (and sign
+                              (eql 'OpenPGP (epg-context-protocol context)))
                          (let ((sender (epg-context-sender context)))
                            (when (stringp sender)
                              (list "--sender" sender))))
diff --git i/lisp/gnus/mml-sec.el w/lisp/gnus/mml-sec.el
index 07d2028534..e0ec829617 100644
--- i/lisp/gnus/mml-sec.el
+++ w/lisp/gnus/mml-sec.el
@@ -915,7 +915,7 @@ mml-secure-epg-encrypt
     (when sign
       (setq signers (mml-secure-signers context signer-names))
       (setf (epg-context-signers context) signers)
-      (when mml-secure-openpgp-sign-with-sender
+      (when (and (eq 'OpenPGP protocol) mml-secure-openpgp-sign-with-sender)
         (setf (epg-context-sender context) sender)))
     (when (eq 'OpenPGP protocol)
       (setf (epg-context-armor context) t)
@@ -945,10 +945,10 @@ mml-secure-epg-sign
 	 signature micalg)
     (when (eq 'OpenPGP protocol)
       (setf (epg-context-armor context) t)
-      (setf (epg-context-textmode context) t))
+      (setf (epg-context-textmode context) t)
+      (when mml-secure-openpgp-sign-with-sender
+        (setf (epg-context-sender context) sender)))
     (setf (epg-context-signers context) signers)
-    (when mml-secure-openpgp-sign-with-sender
-      (setf (epg-context-sender context) sender))
     (when (mml-secure-cache-passphrase-p protocol)
       (epg-context-set-passphrase-callback
        context

> gpg --sender
>    -> gpg: invalid option "--sender"  # RHEL 7.6 with gpg 2.0.22
>
> The option seems to only by present since gpg 2.1.15.
> https://gnupg.org/download/release_notes.html
>
> Ideally you should test if it is supported or not.

So there should also be version checking in epg.el's epg-start-sign and
epg-start-encrypt functions (or somewhere). Currently I don't know if
there are useful infrastructure in epg for dealing with different
versions of gpg.

-- 
///  OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450
//  https://keys.openpgp.org/search?q=[email-masked]
/  https://keybase.io/tlikonen  https://github.com/tlikonen