unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Allen Li <darkfeline@felesatra.moe>
To: 31877@debbugs.gnu.org
Subject: bug#31877: [PATCH] nsm.el: Add choice to reshow certificate information
Date: Wed, 1 Aug 2018 03:09:43 -0700	[thread overview]
Message-ID: <CADbSrJyueGfkeq9LtgXvBJX8zy=fQCfur5JtUJiODA2jj+VKyA@mail.gmail.com> (raw)
In-Reply-To: <CADbSrJyhEFXasajqWGR2=u=sc6c5i8bgu1kT72bqQzMzenS1TQ@mail.gmail.com>

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

I have attached a patch to add a choice to reshow the cert, since the
fundamental problem is that the user could get stuck in a situation
where they have to choose to accept a cert they can't see.

[-- Attachment #2: 0001-Add-choice-to-reshow-certificate-information.patch --]
[-- Type: text/x-patch, Size: 3484 bytes --]

From 9b474c7f93fa277ce9b136012c05f43c56a6b498 Mon Sep 17 00:00:00 2001
From: Allen Li <darkfeline@felesatra.moe>
Date: Wed, 1 Aug 2018 03:04:26 -0700
Subject: [PATCH] Add choice to reshow certificate information

In various situations, the window displaying the certificate
information can be hidden (such as if the user accidentally presses ?,
which causes the read-multiple-choice help window to replace it).
Instead of leaving the user to make a choice blindly, add a choice to
reshow the certification information.

* lisp/net/nsm.el (nsm-query-user): Add reshow choice.
---
 lisp/net/nsm.el | 51 +++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index dab9003e02..b4721ca7cf 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -365,29 +365,34 @@ nsm-query
 	t))))
 
 (defun nsm-query-user (message args cert)
-  (let ((buffer (get-buffer-create "*Network Security Manager*")))
-    (save-window-excursion
-      ;; First format the certificate and warnings.
-      (with-help-window buffer
-        (with-current-buffer buffer
-          (erase-buffer)
-          (when (> (length cert) 0)
-            (insert cert "\n"))
-          (let ((start (point)))
-            (insert (apply #'format-message message args))
-            (goto-char start)
-            ;; Fill the first line of the message, which usually
-            ;; contains lots of explanatory text.
-            (fill-region (point) (line-end-position)))))
-      ;; Then ask the user what to do about it.
-      (unwind-protect
-          (cadr
-           (read-multiple-choice
-            "Continue connecting?"
-            '((?a "always" "Accept this certificate this session and for all future sessions.")
-              (?s "session only" "Accept this certificate this session only.")
-              (?n "no" "Refuse to use this certificate, and close the connection."))))
-        (kill-buffer buffer)))))
+  (catch 'return
+    (while t
+      (let ((buffer (get-buffer-create "*Network Security Manager*")))
+        (save-window-excursion
+          ;; First format the certificate and warnings.
+          (with-help-window buffer
+            (with-current-buffer buffer
+              (erase-buffer)
+              (when (> (length cert) 0)
+                (insert cert "\n"))
+              (let ((start (point)))
+                (insert (apply #'format-message message args))
+                (goto-char start)
+                ;; Fill the first line of the message, which usually
+                ;; contains lots of explanatory text.
+                (fill-region (point) (line-end-position)))))
+          ;; Then ask the user what to do about it.
+          (pcase (unwind-protect
+                     (cadr
+                      (read-multiple-choice
+                       "Continue connecting?"
+                       '((?a "always" "Accept this certificate this session and for all future sessions.")
+                         (?s "session only" "Accept this certificate this session only.")
+                         (?n "no" "Refuse to use this certificate, and close the connection.")
+                         (?r "reshow" "Reshow certificate information."))))
+                   (kill-buffer buffer))
+            ("reshow")
+            (val (throw 'return val))))))))
 
 (defun nsm-save-host (host port status what permanency)
   (let* ((id (nsm-id host port))
-- 
2.18.0


  reply	other threads:[~2018-08-01 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18  8:09 bug#31877: 26.1; Cannot view second certificate information when updating packages Allen Li
2018-08-01 10:09 ` Allen Li [this message]
2018-09-17  1:19   ` bug#31877: [PATCH] nsm.el: Add choice to reshow certificate information Noam Postavsky
2018-09-09  0:33 ` bug#31877: 26.1; Cannot view second certificate information when updating packages Allen Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADbSrJyueGfkeq9LtgXvBJX8zy=fQCfur5JtUJiODA2jj+VKyA@mail.gmail.com' \
    --to=darkfeline@felesatra.moe \
    --cc=31877@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).