diff options
| author | Noam Postavsky | 2018-07-15 21:40:05 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-07-15 21:51:54 -0400 |
| commit | 4318d70677dedea12a3dcfb689bce71e409212f0 (patch) | |
| tree | fea8d8a95629bd145356329f47e55891071e0d07 | |
| parent | f521161c1bc5a9cd10ee25ff5f4b7b8d753db55d (diff) | |
| download | emacs-4318d70677dedea12a3dcfb689bce71e409212f0.tar.gz emacs-4318d70677dedea12a3dcfb689bce71e409212f0.zip | |
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.
| -rw-r--r-- | lisp/epg-config.el | 27 |
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." | |||
| 98 | :type 'boolean) | 98 | :type 'boolean) |
| 99 | 99 | ||
| 100 | (defconst epg-gpg-minimum-version "1.4.3") | 100 | (defconst epg-gpg-minimum-version "1.4.3") |
| 101 | (defconst epg-gpg2-minimum-version "2.1.6") | ||
| 101 | 102 | ||
| 102 | (defconst epg-config--program-alist | 103 | (defconst epg-config--program-alist |
| 103 | `((OpenPGP | 104 | `((OpenPGP |
| 104 | epg-gpg-program | 105 | epg-gpg-program |
| 105 | ("gpg2" . "2.1.6") ("gpg" . ,epg-gpg-minimum-version)) | 106 | ("gpg2" . ,epg-gpg2-minimum-version) |
| 107 | ("gpg" . ((,epg-gpg-minimum-version . "2.0") | ||
| 108 | ,epg-gpg2-minimum-version))) | ||
| 106 | (CMS | 109 | (CMS |
| 107 | epg-gpgsm-program | 110 | epg-gpgsm-program |
| 108 | ("gpgsm" . "2.0.4"))) | 111 | ("gpgsm" . "2.0.4"))) |
| @@ -231,14 +234,26 @@ version requirement is met." | |||
| 231 | (epg-config--make-gpg-configuration epg-gpg-program)) | 234 | (epg-config--make-gpg-configuration epg-gpg-program)) |
| 232 | 235 | ||
| 233 | ;;;###autoload | 236 | ;;;###autoload |
| 234 | (defun epg-check-configuration (config &optional minimum-version) | 237 | (defun epg-check-configuration (config &optional req-versions) |
| 235 | "Verify that a sufficient version of GnuPG is installed." | 238 | "Verify that a sufficient version of GnuPG is installed. |
| 239 | CONFIG should be a `epg-configuration' object (a plist). | ||
| 240 | REQ-VERSIONS should be a list with elements of the form (MIN | ||
| 241 | . MAX) where MIN and MAX are version strings indicating a | ||
| 242 | semi-open range of acceptable versions. REQ-VERSIONS may also be | ||
| 243 | a single minimum version string." | ||
| 236 | (let ((version (alist-get 'version config))) | 244 | (let ((version (alist-get 'version config))) |
| 237 | (unless (stringp version) | 245 | (unless (stringp version) |
| 238 | (error "Undetermined version: %S" version)) | 246 | (error "Undetermined version: %S" version)) |
| 239 | (unless (version<= (or minimum-version | 247 | (catch 'version-ok |
| 240 | epg-gpg-minimum-version) | 248 | (pcase-dolist ((or `(,min . ,max) |
| 241 | version) | 249 | (and min (let max nil))) |
| 250 | (if (listp req-versions) req-versions | ||
| 251 | (list req-versions))) | ||
| 252 | (when (and (version<= (or min epg-gpg-minimum-version) | ||
| 253 | version) | ||
| 254 | (or (null max) | ||
| 255 | (version< version max))) | ||
| 256 | (throw 'version-ok t))) | ||
| 242 | (error "Unsupported version: %s" version)))) | 257 | (error "Unsupported version: %s" version)))) |
| 243 | 258 | ||
| 244 | ;;;###autoload | 259 | ;;;###autoload |