GNU bug report logs - #31075
25.2; shell/eshell password prompt have not hide password input

Previous Next

Package: emacs;

Reported by: Rugang Chen <urugang <at> gmail.com>

Date: Fri, 6 Apr 2018 09:31:02 UTC

Severity: normal

Tags: fixed

Found in version 25.2

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31075 in the body.
You can then email your comments to 31075 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31075; Package emacs. (Fri, 06 Apr 2018 09:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rugang Chen <urugang <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 06 Apr 2018 09:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rugang Chen <urugang <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.2; shell/eshell password prompt have not hide password input
Date: Fri, 6 Apr 2018 09:18:42 +0800
[Message part 1 (text/plain, inline)]
I found that command sudo has two pattern for english and chinese.
```
urugang <at> urugang-ubuntu:~$ LC_ALL=C sudo ls
[sudo] password for urugang:
urugang <at> urugang-ubuntu:~$ LC_ALL=zh_CN.utf8 sudo ls
[sudo] urugang 的密码:
```

So i think we should change comint-password-prompt-regexp from
```
(defcustom comint-password-prompt-regexp
  (concat
   "\\(^ *\\|"
   (regexp-opt
    '("Enter" "enter" "Enter same" "enter same" "Enter the" "enter the"
      "Old" "old" "New" "new" "'s" "login"
      "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad") t)
   " +\\)"
   "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)"
   "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?\
\\(?: for [^::៖]+\\)?[::៖]\\s *\\'")
  "Regexp matching prompts for passwords in the inferior process.
This is used by `comint-watch-for-password-prompt'."
  :version "24.4"
  :type 'regexp
  :group 'comint)
```
to
```
(defcustom comint-password-prompt-regexp
  (concat
   "\\(^ *\\|"
   (regexp-opt
    '("Enter" "enter" "Enter same" "enter same" "Enter the" "enter the"
      "Old" "old" "New" "new" "'s" "login"
      "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad") t)
   " +.*\\)"
   "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)"
   "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?\
\\(?: for [^::៖]+\\)?[::៖]\\s *\\'")
  "Regexp matching prompts for passwords in the inferior process.
This is used by `comint-watch-for-password-prompt'."
  :version "24.4"
  :type 'regexp
  :group 'comint)
```
In short, change `" +\\)"` to `" +.*\\)"`.

I have a question that why eshell dot not use same password prompt
patter in commit-mode.

```
(setq eshell-password-prompt-regexp comint-password-prompt-regexp)
```
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31075; Package emacs. (Tue, 26 Jun 2018 02:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 31075 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Rugang Chen <urugang <at> gmail.com>
Cc: 31075 <at> debbugs.gnu.org
Subject: Re: bug#31075: 25.2;
 shell/eshell password prompt have not hide password input
Date: Mon, 25 Jun 2018 22:22:47 -0400
[Message part 1 (text/plain, inline)]
Rugang Chen <urugang <at> gmail.com> writes:

> In short, change `" +\\)"` to `" +.*\\)"`.

Right.  I'm a bit worried that this regexp is getting too many optional
parts, but I can't see a better way to handle this case.

> I have a question that why eshell dot not use same password prompt
> patter in commit-mode.

Historical accident, probably. 

> (setq eshell-password-prompt-regexp comint-password-prompt-regexp)

Maybe we should go the other way around though, the eshell regexp looks
much simpler (the patch below does not unify them in either direction).

[v1-0001-Detect-Chinese-sudo-password-prompts-Bug-31075.patch (text/x-diff, inline)]
From 099168a7560265ca5ef940879bc4643ba396defd Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Mon, 25 Jun 2018 19:11:41 -0400
Subject: [PATCH v1] Detect Chinese sudo password prompts (Bug#31075)

* lisp/comint.el (comint-password-prompt-regexp): Allow text between
the prompt prefix and password equivalent.
* lisp/eshell/esh-mode.el (eshell-password-prompt-regexp): Accept some
unicode alternatives to ":".
* test/lisp/comint-tests.el (comint-testsuite-password-strings): Add
test case.
---
 lisp/comint.el            | 3 ++-
 lisp/eshell/esh-mode.el   | 2 +-
 test/lisp/comint-tests.el | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 71a2b5eca5..03c1193f13 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -360,7 +360,8 @@ comint-password-prompt-regexp
       "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "PEM" "SUDO"
       "[sudo]" "Repeat" "Bad" "Retype")
     t)
-   " +\\)"
+   ;; Allow for user name to precede password equivalent (Bug#31075).
+   " +.*\\)"
    "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)"
    "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?"
    ;; "[[:alpha:]]" used to be "for", which fails to match non-English.
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index bbb74c3d86..80e22e52a2 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -182,7 +182,7 @@ eshell-preoutput-filter-functions
   :group 'eshell-mode)
 
 (defcustom eshell-password-prompt-regexp
-  (format "\\(%s\\).*:\\s *\\'" (regexp-opt password-word-equivalents))
+  (format "\\(%s\\)[^::៖]*[::៖]\\s *\\'" (regexp-opt password-word-equivalents))
   "Regexp matching prompts for passwords in the inferior process.
 This is used by `eshell-watch-for-password-prompt'."
   :type 'regexp
diff --git a/test/lisp/comint-tests.el b/test/lisp/comint-tests.el
index 64898888ba..e8c79b9ed7 100644
--- a/test/lisp/comint-tests.el
+++ b/test/lisp/comint-tests.el
@@ -36,6 +36,7 @@ comint-testsuite-password-strings
     "Enter same passphrase again: "     ; ssh-keygen
     "Passphrase for key root <at> GNU.ORG: " ; plink
     "[sudo] password for user:" ; Ubuntu sudo
+    "[sudo] user 的密码:" ; localized
     "Password (again):"
     "Enter password:"
     "Mot de Passe:" ; localized
-- 
2.11.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31075; Package emacs. (Fri, 24 Aug 2018 11:51:02 GMT) Full text and rfc822 format available.

Message #11 received at 31075 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Rugang Chen <urugang <at> gmail.com>
Cc: 31075 <at> debbugs.gnu.org
Subject: Re: bug#31075: 25.2;
 shell/eshell password prompt have not hide password input
Date: Fri, 24 Aug 2018 07:50:22 -0400
tags 31075 fixed
close 31075 27.1
quit

Noam Postavsky <npostavs <at> gmail.com> writes:

> Subject: [PATCH v1] Detect Chinese sudo password prompts (Bug#31075)

Pushed to master.

[1: 161139a42c]: 2018-08-23 22:50:15 -0400
  Detect Chinese sudo password prompts (Bug#31075)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=161139a42c02cce051c51fb80c6ae00c9e6beaa6




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 24 Aug 2018 11:51:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 31075 <at> debbugs.gnu.org and Rugang Chen <urugang <at> gmail.com> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 24 Aug 2018 11:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 22 Sep 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 189 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.