summaryrefslogtreecommitdiff
path: root/lisp/epg-config.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2018-07-15 21:40:05 -0400
committerNoam Postavsky <npostavs@gmail.com>2018-07-15 21:51:54 -0400
commit4318d70677dedea12a3dcfb689bce71e409212f0 (patch)
treefea8d8a95629bd145356329f47e55891071e0d07 /lisp/epg-config.el
parentf521161c1bc5a9cd10ee25ff5f4b7b8d753db55d (diff)
downloademacs-4318d70677dedea12a3dcfb689bce71e409212f0.tar.gz
Reject gpg 2.0 for epg configs by default (Bug#23561)
Previously, gpg2 2.0 would be rejected, but the same version installed as "gpg" would be accepted. * lisp/epg-config.el (epg-gpg2-minimum-version): New constant. (epg-config--program-alist) <OpenPGP>: Require a version in 1.4.3..2.0 or 2.1.6+., not just anything above 1.4.3. (epg-check-configuration): Accept a list of required version intervals, in addtion to just a single minimum.
Diffstat (limited to 'lisp/epg-config.el')
-rw-r--r--lisp/epg-config.el27
1 files changed, 21 insertions, 6 deletions
diff --git a/lisp/epg-config.el b/lisp/epg-config.el
index 85434985d39..39d264c05ad 100644
--- a/lisp/epg-config.el
+++ b/lisp/epg-config.el
@@ -98,11 +98,14 @@ Note that the buffer name starts with a space."
:type 'boolean)
(defconst epg-gpg-minimum-version "1.4.3")
+(defconst epg-gpg2-minimum-version "2.1.6")
(defconst epg-config--program-alist
`((OpenPGP
epg-gpg-program
- ("gpg2" . "2.1.6") ("gpg" . ,epg-gpg-minimum-version))
+ ("gpg2" . ,epg-gpg2-minimum-version)
+ ("gpg" . ((,epg-gpg-minimum-version . "2.0")
+ ,epg-gpg2-minimum-version)))
(CMS
epg-gpgsm-program
("gpgsm" . "2.0.4")))
@@ -231,14 +234,26 @@ version requirement is met."
(epg-config--make-gpg-configuration epg-gpg-program))
;;;###autoload
-(defun epg-check-configuration (config &optional minimum-version)
- "Verify that a sufficient version of GnuPG is installed."
+(defun epg-check-configuration (config &optional req-versions)
+ "Verify that a sufficient version of GnuPG is installed.
+CONFIG should be a `epg-configuration' object (a plist).
+REQ-VERSIONS should be a list with elements of the form (MIN
+. MAX) where MIN and MAX are version strings indicating a
+semi-open range of acceptable versions. REQ-VERSIONS may also be
+a single minimum version string."
(let ((version (alist-get 'version config)))
(unless (stringp version)
(error "Undetermined version: %S" version))
- (unless (version<= (or minimum-version
- epg-gpg-minimum-version)
- version)
+ (catch 'version-ok
+ (pcase-dolist ((or `(,min . ,max)
+ (and min (let max nil)))
+ (if (listp req-versions) req-versions
+ (list req-versions)))
+ (when (and (version<= (or min epg-gpg-minimum-version)
+ version)
+ (or (null max)
+ (version< version max)))
+ (throw 'version-ok t)))
(error "Unsupported version: %s" version))))
;;;###autoload