]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle auth-source-search failures in open-network-stream
authorRobert Pluim <rpluim@gmail.com>
Sun, 17 Nov 2019 20:21:48 +0000 (21:21 +0100)
committerRobert Pluim <rpluim@gmail.com>
Mon, 25 Nov 2019 15:00:09 +0000 (16:00 +0100)
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.

lisp/epa.el
lisp/net/network-stream.el

index a2be9a3dbd24c880f281022c01b2efe2bcc0bfe0..13708d046d68bb32f71cb5ffd75de373e7238a31 100644 (file)
@@ -179,6 +179,7 @@ You should bind this variable with `let', but do not set it globally.")
 (defvar epa-list-keys-arguments nil)
 (defvar epa-info-buffer nil)
 (defvar epa-error-buffer nil)
+(defvar epa-suppress-error-buffer nil)
 (defvar epa-last-coding-system-specified nil)
 
 (defvar epa-key-list-mode-map
@@ -578,7 +579,8 @@ If SECRET is non-nil, list secret keys instead of public keys."
     (message "%s" info)))
 
 (defun epa-display-error (context)
-  (unless (equal (epg-context-error-output context) "")
+  (unless (or (equal (epg-context-error-output context) "")
+              epa-suppress-error-buffer)
     (let ((buffer (get-buffer-create "*Error*")))
       (save-selected-window
        (unless (and epa-error-buffer (buffer-live-p epa-error-buffer))
index 9a796d93ab8054cd19436dd71af51efa859153fb..1e9317bc18c213ad89b92681b437147236dc2d68 100644 (file)
@@ -46,6 +46,9 @@
 (require 'nsm)
 (require 'puny)
 
+(eval-when-compile
+  (require 'epa)) ; for epa-suppress-error-buffer
+
 (declare-function starttls-available-p "starttls" ())
 (declare-function starttls-negotiate "starttls" (process))
 (declare-function starttls-open-stream "starttls" (name buffer host port))
@@ -225,10 +228,12 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
       ;; Either nil or a list with a key/certificate pair.
       spec)
      ((eq spec t)
-      (let* ((auth-info
-             (car (auth-source-search :max 1
-                                      :host host
-                                      :port service)))
+      (let* ((epa-suppress-error-buffer t)
+             (auth-info
+              (ignore-errors
+                (car (auth-source-search :max 1
+                                         :host host
+                                         :port service))))
             (key (plist-get auth-info :key))
             (cert (plist-get auth-info :cert)))
        (and key cert (file-readable-p key) (file-readable-p cert)