emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master f5fa0c9: Only use --sender for gpg when gpg support


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master f5fa0c9: Only use --sender for gpg when gpg supports it
Date: Mon, 26 Aug 2019 01:53:21 -0400 (EDT)

branch: master
commit f5fa0c9062d065dc61fdff92b56b9f5da439a83d
Author: Teemu Likonen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Only use --sender for gpg when gpg supports it
    
    * lisp/epg-config.el (epg-required-version-p): New function (bug#37025).
    
    * lisp/gnus/mml-sec.el (mml-secure-epg-sign):
    * lisp/epg.el (epg-start-sign):
    (epg-start-encrypt): Use it to only use --sender when the gpg
    binary supports it.
---
 lisp/epg-config.el   |  9 +++++++++
 lisp/epg.el          | 10 +++++++---
 lisp/gnus/mml-sec.el |  8 ++++----
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lisp/epg-config.el b/lisp/epg-config.el
index 5549068..5432829 100644
--- a/lisp/epg-config.el
+++ b/lisp/epg-config.el
@@ -262,6 +262,15 @@ a single minimum version string."
           (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 ce58c52..6d377d0 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1618,7 +1618,9 @@ If you are unsure, use synchronous version of this 
function
                                      (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 @@ If you are unsure, use synchronous version of this 
function
                                          (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 07d2028..e0ec829 100644
--- a/lisp/gnus/mml-sec.el
+++ b/lisp/gnus/mml-sec.el
@@ -915,7 +915,7 @@ If no one is selected, symmetric encryption will be 
performed.  "
     (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 @@ If no one is selected, symmetric encryption will be 
performed.  "
         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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]