unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Manuel Giraud <manuel@ledu-giraud.fr>
To: Eli Zaretskii <eliz@gnu.org>
Cc: akib@disroot.org,  monnier@iro.umontreal.ca,  emacs-devel@gnu.org
Subject: Re: [Patch] Avoid recording chars when reading passwords
Date: Mon, 20 Jun 2022 17:28:05 +0200	[thread overview]
Message-ID: <87ilovxsl6.fsf@elite.giraud> (raw)
In-Reply-To: <83czf3mv56.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Jun 2022 14:28:21 +0300")

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

Eli Zaretskii <eliz@gnu.org> writes:

[...]

> I think it would be better to have a more general name, in case we
> would want to exempt more stuff from being recorded.  Something like
> record-all-keys, perhaps (with an explanation in the doc string that
> currently it only affects password entry)?

Ok. Here is an updated version of the patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-recording-passwords-chars.patch --]
[-- Type: text/x-patch, Size: 3909 bytes --]

From 06ead0deb3faa0b2cb9124c2c68966d9d3e3d015 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 14 Jun 2022 11:14:02 +0200
Subject: [PATCH] Avoid recording passwords' chars

* lisp/cus-start.el (standard): New user custom `record-all-keys'.
* src/keyboard.c (syms_of_keyboard): Un-obsolete
`inhibit--record-char'.
* lisp/subr.el (read-passwd): Use `inhibit--record-char' to
inhibit passwords recording.
---
 etc/NEWS          |  6 ++++++
 lisp/cus-start.el |  1 +
 lisp/subr.el      |  7 +------
 src/keyboard.c    | 18 ++++++++++++++++++
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 1b8560a923..bee92b62f8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -365,6 +365,12 @@ This inhibits putting empty strings onto the kill ring.
 These options allow adjusting point and scrolling a window when
 dragging items from another program.
 
++++
+** New user option 'record-all-keys'.
+If non-nil, this option will force recording of all input keys
+including in passwords prompt (this was the previous behaviour).  It
+now defaults to NIL and inhibits recording of passwords.
+
 +++
 ** New function 'command-query'.
 This function makes its argument command prompt the user for
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index d8c4b48035..ca2fca4eb7 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -398,6 +398,7 @@ minibuffer-prompt-properties--setter
 	     ;;    			(const :tag " current dir" nil)
 	     ;;    			(directory :format "%v"))))
 	     (load-prefer-newer lisp boolean "24.4")
+             (record-all-keys keyboard boolean)
 	     ;; minibuf.c
 	     (minibuffer-follows-selected-frame
               minibuffer (choice (const :tag "Always" t)
diff --git a/lisp/subr.el b/lisp/subr.el
index 50ae357a13..29f9706c39 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1883,12 +1883,6 @@ 'inhibit-nul-byte-detection
 (make-obsolete-variable 'load-dangerous-libraries
                         "no longer used." "27.1")
 
-(defvar inhibit--record-char nil
-  "Obsolete variable.
-This was used internally by quail.el and keyboard.c in Emacs 27.
-It does nothing in Emacs 28.")
-(make-obsolete-variable 'inhibit--record-char nil "28.1")
-
 (define-obsolete-function-alias 'compare-window-configurations
   #'window-configuration-equal-p "29.1")
 
@@ -3048,6 +3042,7 @@ read-passwd
             (use-local-map read-passwd-map)
             (setq-local inhibit-modification-hooks nil) ;bug#15501.
 	    (setq-local show-paren-mode nil)		;bug#16091.
+            (setq-local inhibit--record-char t)
             (add-hook 'post-command-hook #'read-password--hide-password nil t))
         (unwind-protect
             (let ((enable-recursive-minibuffers t)
diff --git a/src/keyboard.c b/src/keyboard.c
index 55d710ed62..51a424e61f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3307,6 +3307,11 @@ help_char_p (Lisp_Object c)
 static void
 record_char (Lisp_Object c)
 {
+  /* subr.el/read-passwd binds inhibit_record_char to avoid recording
+     passwords.  */
+  if (!record_all_keys && inhibit_record_char)
+    return;
+
   int recorded = 0;
 
   if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement)))
@@ -12992,6 +12997,19 @@ syms_of_keyboard (void)
 changed.  */);
   Vdisplay_monitors_changed_functions = Qnil;
 
+  DEFVAR_BOOL ("inhibit--record-char",
+	       inhibit_record_char,
+	       doc: /* If non-nil, don't record input events.
+This inhibits recording input events for the purposes of keyboard
+macros, dribble file, and `recent-keys'.
+Internal use only.  */);
+  inhibit_record_char = false;
+
+  DEFVAR_BOOL ("record-all-keys", record_all_keys,
+	       doc: /* Non-nil means to record all typed keys.  When
+nil, only passwords' keys are not recorded.  */);
+  record_all_keys = false;
+
   pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
 }
 
-- 
2.36.1


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

  reply	other threads:[~2022-06-20 15:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 13:46 [Patch] Avoid recording chars when reading passwords Manuel Giraud
2022-06-08 15:48 ` Eli Zaretskii
2022-06-13 13:26   ` Manuel Giraud
2022-06-14  9:38   ` Manuel Giraud
2022-06-14 11:35     ` Eli Zaretskii
2022-06-14 12:34       ` Stefan Monnier
2022-06-14 17:46         ` Eli Zaretskii
2022-06-15  7:59           ` Manuel Giraud
2022-06-18 11:16             ` Eli Zaretskii
2022-06-18 11:29               ` Akib Azmain Turja
2022-06-18 11:33                 ` Akib Azmain Turja
2022-06-20  9:58                   ` Manuel Giraud
2022-06-20 11:28                     ` Eli Zaretskii
2022-06-20 15:28                       ` Manuel Giraud [this message]
2022-06-20 15:52                         ` Eli Zaretskii
2022-06-25  9:35                           ` Eli Zaretskii
2022-06-15 12:27           ` Stefan Monnier
2022-06-15 13:27             ` Eli Zaretskii

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=87ilovxsl6.fsf@elite.giraud \
    --to=manuel@ledu-giraud.fr \
    --cc=akib@disroot.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).