From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Avoid recording chars when reading passwords Date: Tue, 14 Jun 2022 11:38:00 +0200 Message-ID: <8735g7vb47.fsf@elite.giraud> References: <87edzz8dzo.fsf@elite.giraud> <834k0v5f7z.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17493"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jun 14 11:47:39 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o1398-0004HG-L9 for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Jun 2022 11:47:38 +0200 Original-Received: from localhost ([::1]:42304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1396-0005mx-LV for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Jun 2022 05:47:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o12zv-00040d-0B for emacs-devel@gnu.org; Tue, 14 Jun 2022 05:38:07 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:46395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o12zs-00088g-S2; Tue, 14 Jun 2022 05:38:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=b8W3CXLM+ML2bEhK NkmOHjIoQd0AzGdBltxB5Hw2Ib8=; h=in-reply-to:date:references:subject: cc:to:from; d=ledu-giraud.fr; b=p7oFdGwFoZsD5NaqmFW3um8EDl82MPhEyvYPiB xTAsX3uB1ko9OQ4xOgPsuXkq4phHaBBPARv26qwn5j/luPmegZWdfAbAF/l2zGsfBHLBlZ EKizoxNXDESxuFa+hED+SQmwSz3fxldarqEJYEqxODw/tIuEcpZGbMCYA2F2Yb9voTsV8A mIl4zIbRqQ0zX0pjPid93TJhfZ7bD0SCaF7pRuo+80kLeJ7dAiM1JjM29sQEu90o+T+/2R NFb+gzGpZYWUV9VbREX38u2GBiVnA9bmgYlY6xWt09T4ol2ttcvv485R5qZVCfV/xOhcwT mdKQsj3TAHY/pCtPRWNGhaaA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id e5e7e019 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 14 Jun 2022 11:38:01 +0200 (CEST) In-Reply-To: <834k0v5f7z.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 08 Jun 2022 18:48:00 +0300") Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291165 Archived-At: --=-=-= Content-Type: text/plain Hi, So I digged into the log and found that `inhibit--record-char' was obsoleted in bd5c740419. The reason seems to be that "quail.el" was the last user of this variable and use it to inhibit a second recording after the first one. AFAIU, quail.el now have function (quail-add-unread-command-events) that put a copy of those events with 'no-record into unread-command-events to have this behaviour. I was not able to do the same when reading password (there is just one read_char involved), so as Eli suggested, I choose to un-obsolete `inhibit--record-char' and use it in `read-passwd' only. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Avoid-recording-passwords-chars.patch >From 8bfbc312ef7cb1f8f2cfd4ea8feda99af86e48a3 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 14 Jun 2022 11:14:02 +0200 Subject: [PATCH] Avoid recording passwords' chars * src/keyboard.c (syms_of_keyboard): un-obsolete `inhibit--record-char'. * lisp/subr.el (read-passwd): use `inhibit--record-char' to inhibit passwords recording. --- lisp/subr.el | 7 +------ src/keyboard.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) 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..fbdc0e9107 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3307,6 +3307,10 @@ help_char_p (Lisp_Object c) static void record_char (Lisp_Object c) { + /* subr.el/read-passwd binds this to avoid recording passwords. */ + if (inhibit_record_char) + return; + int recorded = 0; if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement))) @@ -12992,6 +12996,14 @@ 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; + pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); } -- 2.36.1 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--