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: Mon, 20 Jun 2022 17:28:05 +0200 Message-ID: <87ilovxsl6.fsf@elite.giraud> References: <87edzz8dzo.fsf@elite.giraud> <834k0v5f7z.fsf@gnu.org> <8735g7vb47.fsf@elite.giraud> <83bkuvtr3q.fsf@gnu.org> <83tu8nrvdb.fsf@gnu.org> <87ilp2z7a4.fsf@elite.giraud> <83bkuqnrwa.fsf@gnu.org> <877d5ep5u3.fsf@disroot.org> <874k0ip5nj.fsf@disroot.org> <87wndbmzax.fsf@elite.giraud> <83czf3mv56.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="23416"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: akib@disroot.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jun 20 17:29:41 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 1o3JLQ-0005xc-PH for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Jun 2022 17:29:40 +0200 Original-Received: from localhost ([::1]:38450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3JLP-000765-QG for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Jun 2022 11:29:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3JK1-0004ky-8N for emacs-devel@gnu.org; Mon, 20 Jun 2022 11:28:13 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:44725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3JJy-0002X8-QY; Mon, 20 Jun 2022 11:28:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=hUoXgHz4rIo2u2Yv n0cqCre3408EiStr4BFkXlHVXuA=; h=in-reply-to:date:references:subject: cc:to:from; d=ledu-giraud.fr; b=UBhb9qOD/atm9vVN7CaiMjG9prGpL2JqF9dnme k5OpaVzAVKBFJH/j13ImBKCgUrL+R6DF3L7Avh9aKUTGynZ6FbTyi9B9sxlH4JqklxevwP j+OXGMnrNbAjy5QEkYQZ74O2uE/51ti9gz8Go5luAiMhFZZ4my02HUIxjKBpjXnQTm6HuH CYDr6HNjo9+gdFfmxSO7gjCQpx4rAmnJTAZLu9hcwZvsf31FvybpBI0COgUOz1yekYf4Ed FnYC86QAE2wgfVfgv4H/ug39/4U1+SCAxeuqpG5o0Lo0XsIGbRmCwz31zjzfXN0Ui/dK89 oczVxPBtjCrnfCX6LEZGW+dA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id eeb83287 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 20 Jun 2022 17:28:06 +0200 (CEST) In-Reply-To: <83czf3mv56.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Jun 2022 14:28:21 +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:291470 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Avoid-recording-passwords-chars.patch >From 06ead0deb3faa0b2cb9124c2c68966d9d3e3d015 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 * 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 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--