From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#17127: `call-process' circumvents password concealment w/ `read-passwd' Date: Sun, 29 Sep 2019 16:35:22 +0200 Message-ID: <87y2y7gogl.fsf@gnus.org> References: <871txntb60.fsf@nbtrap.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="229765"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 17127@debbugs.gnu.org To: Nathan Trapuzzano Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 29 16:36:21 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iEaJ9-000xbI-98 for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2019 16:36:19 +0200 Original-Received: from localhost ([::1]:39720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEaJ6-0005rx-K0 for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2019 10:36:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEaIt-0005pc-HU for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2019 10:36:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEaIs-0001Wn-6X for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2019 10:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iEaIs-0001WI-2s for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2019 10:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iEaIr-0000X9-UC for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2019 10:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Sep 2019 14:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17127 X-GNU-PR-Package: emacs Original-Received: via spool by 17127-submit@debbugs.gnu.org id=B17127.15697677322014 (code B ref 17127); Sun, 29 Sep 2019 14:36:01 +0000 Original-Received: (at 17127) by debbugs.gnu.org; 29 Sep 2019 14:35:32 +0000 Original-Received: from localhost ([127.0.0.1]:55405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iEaIL-0000WM-6A for submit@debbugs.gnu.org; Sun, 29 Sep 2019 10:35:32 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:56004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iEaII-0000WD-M6 for 17127@debbugs.gnu.org; Sun, 29 Sep 2019 10:35:27 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iEaIE-0001uZ-7r; Sun, 29 Sep 2019 16:35:24 +0200 In-Reply-To: <871txntb60.fsf@nbtrap.com> (Nathan Trapuzzano's message of "Thu, 27 Mar 2014 20:32:55 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:167684 Archived-At: Nathan Trapuzzano writes: > To reproduce with emacs -nw -q on 24.3 and trunk: > > M-: (global-set-key > (kbd "C-c C-c") > (lambda () > (interactive) > (call-process "echo" nil t nil "-n" "foobar"))) > > M-: (read-passwd "Password: ") > > C-c C-c > > "foobar" is printed in the minibuffer rather than "......", whereas, > e.g., yanking from the kill ring print dots. The following patch fixes this, I think, by using post-command-hook instead of after-change-functions. It seems to work for me -- does anybody see a problem with doing it this way? diff --git a/lisp/subr.el b/lisp/subr.el index 45b99a82d2..9e4553dcbb 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2426,6 +2426,12 @@ read-passwd-map map) "Keymap used while reading passwords.") +(defun read-password--hide-password () + (let ((beg (minibuffer-prompt-end))) + (dotimes (i (1+ (- (buffer-size) beg))) + (put-text-property (+ i beg) (+ 1 i beg) + 'display (string (or read-hide-char ?*)))))) + (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. @@ -2450,15 +2456,7 @@ read-passwd (message "Password not repeated accurately; please start over") (sit-for 1)))) 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 ?*)))))) - minibuf) + (let (minibuf) (minibuffer-with-setup-hook (lambda () (setq minibuf (current-buffer)) @@ -2469,7 +2467,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. - (add-hook 'after-change-functions hide-chars-fun nil 'local)) + (add-hook 'post-command-hook 'read-password--hide-password nil t)) (unwind-protect (let ((enable-recursive-minibuffers t) (read-hide-char (or read-hide-char ?*))) @@ -2479,7 +2477,8 @@ read-passwd ;; Not sure why but it seems that there might be cases where the ;; minibuffer is not always properly reset later on, so undo ;; whatever we've done here (bug#11392). - (remove-hook 'after-change-functions hide-chars-fun 'local) + (remove-hook 'after-change-functions 'read-password--hide-password + 'local) (kill-local-variable 'post-self-insert-hook) ;; And of course, don't keep the sensitive data around. (erase-buffer)))))))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no