unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Keep network security info buffers after use
@ 2023-12-17 19:02 Karl Fogel
  2023-12-17 19:27 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 48+ messages in thread
From: Karl Fogel @ 2023-12-17 19:02 UTC (permalink / raw)
  To: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]

What do people think of the attached behavior change?

Summary: after the user is prompted about whether to accept a 
remote cert, the buffer(s) with information about the cert should 
stay around, instead of being killed like they currently are.

Request: I'd like to know if people agree with the overall goal 
here.  I'm still testing the change (I need to learn something new 
in order to test it -- namely, how to artifically "forget" a cert 
so that I get re-prompted again, and if anyone has tips on that, 
I'm all ears).

Motivation:

Recently I was sending an email from Emacs on a new machine, and I 
got prompted about whether to accept the remote SMTP server's 
cert.  The prompt function is `nsm-query-user', and its manner of 
prompting didn't allow me to easily leave the minibuffer to go 
into the "*Network Security Manager*" buffer and grab the cert 
info so that I could save it to inspect further later on (maybe 
there was something I could have done with a recursive edit, but I 
didn't want to break my flow that much).

So after accepting the cert, I tried to go back to the "*Network 
Security Manager*" buffer to get the remote server fingerprint -- 
but alas, the buffer was gone.

Hence this change: make it so that that buffer (and another 
related cert-specific buffer) stay around after the user has been 
prompted, in case the user wants to go back and get the 
information in them.

I'm not sure whether just eliminating the calls to `kill-buffer' 
is enough.  Maybe they should be replaced with `bury-buffer' 
calls, to make sure that those buffers aren't in the user's face? 
As I said above, I'm still testing.  I'd just like to know if we 
agree with the goal of this change.  I won't push it to master 
until a) I know we agree on the goal, and b) it's fully tested.

Best regards,
-Karl


[-- Attachment #2: Keep network security info buffers after use --]
[-- Type: text/plain, Size: 7339 bytes --]

From 3b9a564d2aaae83f612d55f4d9592fa5d96986eb Mon Sep 17 00:00:00 2001
From: Karl Fogel <kfogel@red-bean.com>
Date: Sun, 17 Dec 2023 12:17:11 -0600
Subject: [PATCH] Keep network security info buffers after use

* lisp/net/nsm.el (nsm-query-user): Don't kill the two informational
  buffers "*Network Security Manager*" and "*Certificate Details*".
  Even after making a decision about a certificate, the user might
  want to go back to those buffers to get information from them.

Note that while the diff is large, the actual change is tiny.  The
removal of the `unwind-protect' wrapper caused much reindentation
(there's nothing to unwind now, as both unwindforms went away).  The
"real" diff is just the removal of the two `kill-buffer' calls at the
end of the function and would look something like this:

  --- lisp/net/nsm.el
  +++ lisp/net/nsm.el
  @@ -918,9 +918,7 @@ nsm-query-user
                      (goto-char (point-min))
                      (read-only-mode)))))
               ;; Return the answer.
  -            (cadr answer))
  -        (kill-buffer cert-buffer)
  -        (kill-buffer buffer)))))
  +            (cadr answer))))))
---
 lisp/net/nsm.el | 139 ++++++++++++++++++++++++------------------------
 1 file changed, 69 insertions(+), 70 deletions(-)

diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index 09f7ac52537..9df08b33ca9 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -846,81 +846,80 @@ nsm-query-user
                         '((?b "backward page" "See previous page")
                           (?f "forward page" "See next page"))))))
       ;; Then ask the user what to do about it.
-      (unwind-protect
-          (let* ((pems (cl-loop for cert in certs
-                                collect (gnutls-format-certificate
-                                         (plist-get cert :pem))))
-                 (cert-index 0)
-                 show-details answer buf)
-            (while (not done)
-              (setq answer (if show-details
-                               (read-multiple-choice "Viewing certificate:"
-                                                     details-choices)
-                             (read-multiple-choice "Continue connecting?"
-                                                   accept-choices)))
-              (setq buf (if show-details cert-buffer buffer))
-
-              (cl-case (car answer)
-                (?q
-                 ;; Exit the details window.
-                 (set-window-buffer (get-buffer-window cert-buffer) buffer)
-                 (setq show-details nil))
-
-                (?d
-                 ;; Enter the details window.
-                 (set-window-buffer (get-buffer-window buffer) cert-buffer)
-                 (with-current-buffer cert-buffer
-                   (read-only-mode -1)
-                   (insert (nth cert-index pems))
-                   (goto-char (point-min))
-                   (read-only-mode))
-                 (setq show-details t))
-
-                (?b
-                 ;; Scroll down.
-                 (with-selected-window (get-buffer-window buf)
-                   (with-current-buffer buf
-                     (ignore-errors (scroll-down)))))
-
-                (?f
-                 ;; Scroll up.
-                 (with-selected-window (get-buffer-window buf)
-                   (with-current-buffer buf
-                     (ignore-errors (scroll-up)))))
-
-                (?n
-                 ;; "No" or "next certificate".
-                 (if show-details
-                     (with-current-buffer cert-buffer
-                       (read-only-mode -1)
-                       (erase-buffer)
-                       (setq cert-index (mod (1+ cert-index) (length pems)))
-                       (insert (nth cert-index pems))
-                       (goto-char (point-min))
-                       (read-only-mode))
-                   (setq done t)))
-
-                (?a
-                 ;; "Always"
-                 (setq done t))
-
-                (?s
-                 ;; "Session only"
-                 (setq done t))
-
-                (?p
-                 ;; Previous certificate.
+      (let* ((pems (cl-loop for cert in certs
+                            collect (gnutls-format-certificate
+                                     (plist-get cert :pem))))
+             (cert-index 0)
+             show-details answer buf)
+        (while (not done)
+          (setq answer (if show-details
+                           (read-multiple-choice "Viewing certificate:"
+                                                 details-choices)
+                         (read-multiple-choice "Continue connecting?"
+                                               accept-choices)))
+          (setq buf (if show-details cert-buffer buffer))
+
+          (cl-case (car answer)
+            (?q
+             ;; Exit the details window.
+             (set-window-buffer (get-buffer-window cert-buffer) buffer)
+             (setq show-details nil))
+
+            (?d
+             ;; Enter the details window.
+             (set-window-buffer (get-buffer-window buffer) cert-buffer)
+             (with-current-buffer cert-buffer
+               (read-only-mode -1)
+               (insert (nth cert-index pems))
+               (goto-char (point-min))
+               (read-only-mode))
+             (setq show-details t))
+
+            (?b
+             ;; Scroll down.
+             (with-selected-window (get-buffer-window buf)
+               (with-current-buffer buf
+                 (ignore-errors (scroll-down)))))
+
+            (?f
+             ;; Scroll up.
+             (with-selected-window (get-buffer-window buf)
+               (with-current-buffer buf
+                 (ignore-errors (scroll-up)))))
+
+            (?n
+             ;; "No" or "next certificate".
+             (if show-details
                  (with-current-buffer cert-buffer
                    (read-only-mode -1)
                    (erase-buffer)
-                   (setq cert-index (mod (1- cert-index) (length pems)))
+                   (setq cert-index (mod (1+ cert-index) (length pems)))
                    (insert (nth cert-index pems))
                    (goto-char (point-min))
-                   (read-only-mode)))))
-            ;; Return the answer.
-            (cadr answer))
-        (kill-buffer cert-buffer)
-        (kill-buffer buffer)))))
+                   (read-only-mode))
+               (setq done t)))
+
+            (?a
+             ;; "Always"
+             (setq done t))
+
+            (?s
+             ;; "Session only"
+             (setq done t))
+
+            (?p
+             ;; Previous certificate.
+             (with-current-buffer cert-buffer
+               (read-only-mode -1)
+               (erase-buffer)
+               (setq cert-index (mod (1- cert-index) (length pems)))
+               (insert (nth cert-index pems))
+               (goto-char (point-min))
+               (read-only-mode)))))
+        ;; Return the answer.  (We leave `buffer' and `cert-buffer'
+        ;; around, in case the user wants to go back and get any
+        ;; information from them.)
+        (cadr answer)))))
 
 (defun nsm-save-host (host port status what problems permanency)
   (let* ((id (nsm-id host port))
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2023-12-27 12:54 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-17 19:02 [PATCH] Keep network security info buffers after use Karl Fogel
2023-12-17 19:27 ` Eli Zaretskii
2023-12-17 23:27   ` Karl Fogel
2023-12-18 17:36     ` Eli Zaretskii
2023-12-19  0:00       ` Karl Fogel
2023-12-19  5:31         ` tomas
2023-12-19 12:34         ` Eli Zaretskii
2023-12-19 12:50           ` tomas
2023-12-19 13:05             ` Eli Zaretskii
2023-12-20 22:43           ` Andreas Schwab
2023-12-21  6:45             ` Eli Zaretskii
2023-12-17 21:03 ` Andreas Schwab
2023-12-19  3:49 ` Richard Stallman
2023-12-19  5:56   ` Karl Fogel
2023-12-19 12:51     ` Eli Zaretskii
2023-12-19 13:10       ` tomas
2023-12-19 18:57       ` Karl Fogel
2023-12-19 19:08         ` Eli Zaretskii
2023-12-19 20:18           ` Karl Fogel
2023-12-20 21:34             ` Jens Schmidt
2023-12-20 22:26               ` Andreas Schwab
2023-12-21  6:29               ` Eli Zaretskii
2023-12-21 17:38                 ` Karl Fogel
2023-12-21 18:43                   ` Andreas Schwab
2023-12-21 23:10                     ` Karl Fogel
2023-12-22  7:29                       ` Eli Zaretskii
2023-12-22 10:00 ` Stefan Kangas
2023-12-22 11:51   ` Eli Zaretskii
2023-12-22 21:58     ` Jens Schmidt
2023-12-22 22:10       ` Jens Schmidt
2023-12-23  7:15       ` Eli Zaretskii
2023-12-23 10:46         ` Jens Schmidt
2023-12-23 22:57       ` Karl Fogel
2023-12-24  6:14         ` Eli Zaretskii
2023-12-24 13:52     ` Stefan Kangas
2023-12-24 14:51       ` Eli Zaretskii
2023-12-24 15:34         ` Karl Fogel
2023-12-24 16:28           ` Eli Zaretskii
2023-12-25 17:35             ` Kévin Le Gouguec
2023-12-25 18:51               ` Eli Zaretskii
2023-12-25 20:23                 ` Tomas Hlavaty
2023-12-26 14:43                 ` Kévin Le Gouguec
2023-12-26 17:01                   ` Eli Zaretskii
2023-12-26 22:09                     ` Stefan Kangas
2023-12-27 12:54                       ` Eli Zaretskii
2023-12-25 20:18               ` Tomas Hlavaty
2023-12-27 12:35                 ` Eli Zaretskii
2023-12-24 18:42       ` [External] : " Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).