all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Teemu Likonen <tlikonen@iki.fi>
To: Glenn Morris <rgm@gnu.org>
Cc: oub@mat.ucm.es, 37025@debbugs.gnu.org
Subject: bug#37025: [found the culprit]
Date: Sun, 18 Aug 2019 18:13:49 +0300	[thread overview]
Message-ID: <87mug6a4lu.fsf@iki.fi> (raw)
In-Reply-To: <875zmyh0ny.fsf@iki.fi>

[-- Attachment #1: Type: text/plain, Size: 4232 bytes --]

Teemu Likonen [2019-08-15T19:08:01+03] wrote:

> Here's a patch with version checking. This patch includes everything
> in the previous patch (that is, use "--sender" only with OpenPGP
> protocol) and additionally this checks if gpg is at least version
> 2.1.15 which introduced the "--sender" option.

The code is probably clearer if we define a separate predicate function
for checking GnuPG version. I made another version of the patch which
defines function epg-required-version-p (epg-config.el) and uses the
function in epg.el. The function is used twice in my patch but it can be
useful in the future.


diff --git a/lisp/epg-config.el b/lisp/epg-config.el
index 5549068169..54328290c8 100644
--- a/lisp/epg-config.el
+++ b/lisp/epg-config.el
@@ -262,6 +262,15 @@ epg-check-configuration
           (throw 'version-ok t)))
       (error "Unsupported version: %s" version))))
 
+(defun epg-required-version-p (protocol required-version)
+  "Verify a sufficient version of GnuPG for specific protocol.
+PROTOCOL is symbol, either `OpenPGP' or `CMS'.  REQUIRED-VERSION
+is a string containing the required version number.  Return
+non-nil if that version or higher is installed."
+  (let ((version (cdr (assq 'version (epg-find-configuration protocol)))))
+    (and (stringp version)
+         (version<= required-version version))))
+
 ;;;###autoload
 (defun epg-expand-group (config group)
   "Look at CONFIG and try to expand GROUP."
diff --git a/lisp/epg.el b/lisp/epg.el
index ce58c520f1..6d377d07e2 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1618,7 +1618,9 @@ 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))
+                                  (epg-required-version-p 'OpenPGP "2.1.15")
+                                  (stringp sender))
                          (list "--sender" sender)))
 		     (epg--args-from-sig-notations
 		      (epg-context-sig-notations context))
@@ -1714,9 +1716,11 @@ 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)
+                           (when (and (epg-required-version-p 'OpenPGP "2.1.15")
+                                      (stringp sender))
                              (list "--sender" sender))))
                      (if sign
 			 (epg--args-from-sig-notations
diff --git a/lisp/gnus/mml-sec.el b/lisp/gnus/mml-sec.el
index 07d2028534..e0ec829617 100644
--- a/lisp/gnus/mml-sec.el
+++ b/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

-- 
///  OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450
//  https://keys.openpgp.org/search?q=tlikonen@iki.fi
/  https://keybase.io/tlikonen  https://github.com/tlikonen

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 694 bytes --]

  parent reply	other threads:[~2019-08-18 15:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 10:24 bug#37025: 27.0.50; smime signing and encryption does not work any longer Uwe Brauer
2019-08-14 18:54 ` bug#37025: [found the culprit] (was: bug#37025: 27.0.50; smime signing and encryption does not work any longer) Uwe Brauer
2019-08-14 19:14   ` Teemu Likonen
2019-08-15  1:39     ` bug#37025: [found the culprit] Glenn Morris
2019-08-15  4:48       ` Teemu Likonen
2019-08-15  7:38         ` Uwe Brauer
2019-08-15 16:08         ` Teemu Likonen
2019-08-15 16:12           ` Uwe Brauer
2019-08-18 15:13           ` Teemu Likonen [this message]
2019-08-26  5:53             ` Lars Ingebrigtsen
2019-08-26  6:57               ` Uwe Brauer
2019-08-26  7:31                 ` bug#37025: [confirmed] (was: bug#37025: [found the culprit]) Uwe Brauer
2019-08-26 14:44                   ` Teemu Likonen
2019-08-27  6:43                   ` bug#37025: [confirmed] Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mug6a4lu.fsf@iki.fi \
    --to=tlikonen@iki.fi \
    --cc=37025@debbugs.gnu.org \
    --cc=oub@mat.ucm.es \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.