unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [Patch] Avoid recording chars when reading passwords
@ 2022-06-08 13:46 Manuel Giraud
  2022-06-08 15:48 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Manuel Giraud @ 2022-06-08 13:46 UTC (permalink / raw)
  To: emacs-devel

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

Hi,

With this patch, passwords won't appear in the lossage or the dribble
file.

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

From a15d43e2cd80307e2597f7888a4920d73fa58362 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Wed, 8 Jun 2022 15:39:39 +0200
Subject: [PATCH] Avoid recording chars when reading passwords

* lisp/subr.el (read-passwd): inhibit char recording when reading
a password.
* src/keyboard.c (syms_of_keyboard, read_char): introduce
`do-not-record-char' to inhibit char recording.
---
 lisp/subr.el   |  1 +
 src/keyboard.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 50ae357a13..1007237fb6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3048,6 +3048,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 do-not-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..a628c2d2df 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3046,10 +3046,13 @@ read_char (int commandflag, Lisp_Object map,
 
   /* Store these characters into recent_keys, the dribble file if any,
      and the keyboard macro being defined, if any.  */
-  record_char (c);
-  recorded = true;
-  if (! NILP (also_record))
-    record_char (also_record);
+  if (!do_not_record_char)
+    {
+      record_char (c);
+      recorded = true;
+      if (! NILP (also_record))
+	record_char (also_record);
+    }
 
   /* Wipe the echo area.
      But first, if we are about to use an input method,
@@ -3172,7 +3175,7 @@ read_char (int commandflag, Lisp_Object map,
   /* When we consume events from the various unread-*-events lists, we
      bypass the code that records input, so record these events now if
      they were not recorded already.  */
-  if (!recorded)
+  if (!recorded && !do_not_record_char)
     {
       record_char (c);
       recorded = true;
@@ -12561,6 +12564,11 @@ syms_of_keyboard (void)
 \(Even if the operating system has support for stopping a process.)  */);
   cannot_suspend = false;
 
+  DEFVAR_BOOL ("do-not-record-char", do_not_record_char,
+	       doc: /* Non-nil means to not record chars.
+Those chars would not appear in the dribble file or in `view-lossage'.  */);
+  do_not_record_char = false;
+
   DEFVAR_BOOL ("menu-prompting", menu_prompting,
 	       doc: /* Non-nil means prompt with menus when appropriate.
 This is done when reading from a keymap that has a prompt string,
-- 
2.36.0


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

-- 
Manuel Giraud

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

end of thread, other threads:[~2022-06-25  9:35 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).