diff options
| author | Robert Pluim | 2019-11-17 21:21:48 +0100 |
|---|---|---|
| committer | Robert Pluim | 2019-11-25 16:00:09 +0100 |
| commit | 2d12d4d2d467f5df81e232707ad9191264b7c2b0 (patch) | |
| tree | cebd1af000cff9ef162f2d976f0bfd632471d2f0 | |
| parent | 5a3e96b17c2a948ac952295962dc6e281ec5cad5 (diff) | |
| download | emacs-2d12d4d2d467f5df81e232707ad9191264b7c2b0.tar.gz emacs-2d12d4d2d467f5df81e232707ad9191264b7c2b0.zip | |
Handle auth-source-search failures in open-network-stream
If the user cancels the gpg decryption pop-up, auth-source-search
fails *and* epa pops up an error buffer. Fix epa to allow suppressing
that, and ignore errors returned from auth-source-search.
* lisp/epa.el (epa-suppress-error-buffer): New defvar. Bind non-nil
to stop epa popping up an error buffer.
* lisp/net/network-stream.el: require epa when byte-compiling.
(network-stream-certificate): ignore errors when calling
auth-source-search, and suppress the epa error buffer.
| -rw-r--r-- | lisp/epa.el | 4 | ||||
| -rw-r--r-- | lisp/net/network-stream.el | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/lisp/epa.el b/lisp/epa.el index a2be9a3dbd2..13708d046d6 100644 --- a/lisp/epa.el +++ b/lisp/epa.el | |||
| @@ -179,6 +179,7 @@ You should bind this variable with `let', but do not set it globally.") | |||
| 179 | (defvar epa-list-keys-arguments nil) | 179 | (defvar epa-list-keys-arguments nil) |
| 180 | (defvar epa-info-buffer nil) | 180 | (defvar epa-info-buffer nil) |
| 181 | (defvar epa-error-buffer nil) | 181 | (defvar epa-error-buffer nil) |
| 182 | (defvar epa-suppress-error-buffer nil) | ||
| 182 | (defvar epa-last-coding-system-specified nil) | 183 | (defvar epa-last-coding-system-specified nil) |
| 183 | 184 | ||
| 184 | (defvar epa-key-list-mode-map | 185 | (defvar epa-key-list-mode-map |
| @@ -578,7 +579,8 @@ If SECRET is non-nil, list secret keys instead of public keys." | |||
| 578 | (message "%s" info))) | 579 | (message "%s" info))) |
| 579 | 580 | ||
| 580 | (defun epa-display-error (context) | 581 | (defun epa-display-error (context) |
| 581 | (unless (equal (epg-context-error-output context) "") | 582 | (unless (or (equal (epg-context-error-output context) "") |
| 583 | epa-suppress-error-buffer) | ||
| 582 | (let ((buffer (get-buffer-create "*Error*"))) | 584 | (let ((buffer (get-buffer-create "*Error*"))) |
| 583 | (save-selected-window | 585 | (save-selected-window |
| 584 | (unless (and epa-error-buffer (buffer-live-p epa-error-buffer)) | 586 | (unless (and epa-error-buffer (buffer-live-p epa-error-buffer)) |
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el index 9a796d93ab8..1e9317bc18c 100644 --- a/lisp/net/network-stream.el +++ b/lisp/net/network-stream.el | |||
| @@ -46,6 +46,9 @@ | |||
| 46 | (require 'nsm) | 46 | (require 'nsm) |
| 47 | (require 'puny) | 47 | (require 'puny) |
| 48 | 48 | ||
| 49 | (eval-when-compile | ||
| 50 | (require 'epa)) ; for epa-suppress-error-buffer | ||
| 51 | |||
| 49 | (declare-function starttls-available-p "starttls" ()) | 52 | (declare-function starttls-available-p "starttls" ()) |
| 50 | (declare-function starttls-negotiate "starttls" (process)) | 53 | (declare-function starttls-negotiate "starttls" (process)) |
| 51 | (declare-function starttls-open-stream "starttls" (name buffer host port)) | 54 | (declare-function starttls-open-stream "starttls" (name buffer host port)) |
| @@ -225,10 +228,12 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." | |||
| 225 | ;; Either nil or a list with a key/certificate pair. | 228 | ;; Either nil or a list with a key/certificate pair. |
| 226 | spec) | 229 | spec) |
| 227 | ((eq spec t) | 230 | ((eq spec t) |
| 228 | (let* ((auth-info | 231 | (let* ((epa-suppress-error-buffer t) |
| 229 | (car (auth-source-search :max 1 | 232 | (auth-info |
| 230 | :host host | 233 | (ignore-errors |
| 231 | :port service))) | 234 | (car (auth-source-search :max 1 |
| 235 | :host host | ||
| 236 | :port service)))) | ||
| 232 | (key (plist-get auth-info :key)) | 237 | (key (plist-get auth-info :key)) |
| 233 | (cert (plist-get auth-info :cert))) | 238 | (cert (plist-get auth-info :cert))) |
| 234 | (and key cert (file-readable-p key) (file-readable-p cert) | 239 | (and key cert (file-readable-p key) (file-readable-p cert) |