all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Manuel Giraud <manuel@ledu-giraud.fr>
To: emacs-devel@gnu.org
Subject: [Patch] Avoid recording chars when reading passwords
Date: Wed, 08 Jun 2022 15:46:19 +0200	[thread overview]
Message-ID: <87edzz8dzo.fsf@elite.giraud> (raw)

[-- 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

             reply	other threads:[~2022-06-08 13:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 13:46 Manuel Giraud [this message]
2022-06-08 15:48 ` [Patch] Avoid recording chars when reading passwords 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

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

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

  git send-email \
    --in-reply-to=87edzz8dzo.fsf@elite.giraud \
    --to=manuel@ledu-giraud.fr \
    --cc=emacs-devel@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.