From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: better than read-hide-char Date: Sat, 02 Mar 2019 23:58:11 +0200 Organization: LINKOV.NET Message-ID: <87va11vszw.fsf@mail.linkov.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="19209"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 02 23:05:08 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h0Ckl-0004nQ-9M for ged-emacs-devel@m.gmane.org; Sat, 02 Mar 2019 23:05:07 +0100 Original-Received: from localhost ([127.0.0.1]:59445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0Ckk-0006z6-AK for ged-emacs-devel@m.gmane.org; Sat, 02 Mar 2019 17:05:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0Ckd-0006yg-Kn for emacs-devel@gnu.org; Sat, 02 Mar 2019 17:05:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0CkY-0000sE-6L for emacs-devel@gnu.org; Sat, 02 Mar 2019 17:04:56 -0500 Original-Received: from quail.birch.relay.mailchannels.net ([23.83.209.151]:33443) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0CkR-0000f6-6p for emacs-devel@gnu.org; Sat, 02 Mar 2019 17:04:50 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 84DBF683BF5 for ; Sat, 2 Mar 2019 22:04:39 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (unknown [100.96.20.153]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 41A5A683842 for ; Sat, 2 Mar 2019 22:04:39 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.3); Sat, 02 Mar 2019 22:04:39 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Bubble-Versed: 734077012a3711f6_1551564279404_4134072605 X-MC-Loop-Signature: 1551564279403:2099025426 X-MC-Ingress-Time: 1551564279403 Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTP id EED1580463 for ; Sat, 2 Mar 2019 14:04:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=91hSiIJuf6w4KvlkmGN0dxPZtpU=; b= lTshIqjUSY1MwbfzSdphWUL/pAxtW/MUey0540/YWM3WgvpXKxybRfi0a1PAjnOn V7Jyp7nVRxNYMZufC0Lc4gdku+6i7c2/NB5CHoSwRabS00hDw49w8y/GKCNNXFVs 8LWCjmZJq8H6GDgMc5ja6C9Ck7uWpNDPFTy8A3FxQ1M= Original-Received: from mail.jurta.org (m91-129-98-103.cust.tele2.ee [91.129.98.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTPSA id A11B480460 for ; Sat, 2 Mar 2019 14:04:37 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a27 In-Reply-To: (Stefan Monnier's message of "Tue, 31 Jul 2018 09:47:56 -0400") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrvdejgdduiedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledrleekrddutdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledrleekrddutdefpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtohepvghmrggtshdquggvvhgvlhesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.209.151 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233782 Archived-At: > PS: Adding a command to temporarily reveal the password is also a small > matter of programming. > > diff --git a/lisp/subr.el b/lisp/subr.el > index 5b38c4d42e..d93b97a7c4 100644 > --- a/lisp/subr.el > +++ b/lisp/subr.el > @@ -2452,11 +2452,19 @@ > (message "Password not repeated accurately; please start over") > (sit-for 1)))) > success) > - (let ((hide-chars-fun > + (let* (ol > + (hide-chars-fun Maybe hide-chars-fun should be customizable? This would allow adding an option to temporarily reveal the password instead of patching the implementation like: diff --git a/lisp/subr.el b/lisp/subr.el index 5b0330745f..14bd601e71 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2320,6 +2320,11 @@ read-passwd-map map) "Keymap used while reading passwords.") +(defcustom read-passwd-hide-delay 0.3 + "Time delay before hiding typed password chars." + :type 'number + :group 'display) + (defun read-passwd (prompt &optional confirm default) "Read a password, prompting with PROMPT, and return it. If optional CONFIRM is non-nil, read the password twice to make sure. @@ -2346,12 +2351,20 @@ read-passwd success) (let ((hide-chars-fun (lambda (beg end _len) - (clear-this-command-keys) - (setq beg (min end (max (minibuffer-prompt-end) - beg))) - (dotimes (i (- end beg)) - (put-text-property (+ i beg) (+ 1 i beg) - 'display (string (or read-hide-char ?*)))))) + (let ((minibuf (current-buffer))) + (run-with-timer + read-passwd-hide-delay + nil + (lambda () + (clear-this-command-keys) + (when (buffer-live-p minibuf) + (with-current-buffer minibuf + (setq beg (min end (max (minibuffer-prompt-end) beg))) + (setq end (min end (point-max))) + (dotimes (i (- end beg)) + (put-text-property (+ i beg) (+ 1 i beg) + 'display (string (or read-hide-char ?*)) + minibuf))))))))) minibuf) (minibuffer-with-setup-hook (lambda () OTOH, another useful option would be the opposite: to increase security when necessary and obscure the number of typed characters: diff --git a/lisp/subr.el b/lisp/subr.el index 5c8b84b8e9..194f019ba7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2357,7 +2357,8 @@ read-passwd beg))) (dotimes (i (- end beg)) (put-text-property (+ i beg) (+ 1 i beg) - 'display (string (or read-hide-char ?*)))))) + 'display (make-string (1+ (random 3)) + (or read-hide-char ?*)))))) minibuf) (minibuffer-with-setup-hook (lambda ()