GNU bug report logs - #56336
28.1.90; [28.1] Emacs prompts for password when output from async command contains "password:"

Previous Next

Package: emacs;

Reported by: Jan Synáček <jan.synacek <at> gmail.com>

Date: Fri, 1 Jul 2022 12:14:01 UTC

Severity: normal

Tags: moreinfo

Found in version 28.1.90

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 56336 in the body.
You can then email your comments to 56336 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#56336; Package emacs. (Fri, 01 Jul 2022 12:14:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Synáček <jan.synacek <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 01 Jul 2022 12:14:01 GMT) Full text and rfc822 format available.

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

From: Jan Synáček <jan.synacek <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1.90; [28.1] Emacs prompts for password when output from async
 command contains "password:"
Date: Fri, 01 Jul 2022 14:03:40 +0200
When the output from a command spawned with 'M-&' (async-shell-command)
ends with "password:" Emacs prompts for a password.

Reproducer:
0) $ cat /tmp/test.txt
   enter your password:
1) emacs -Q
2) Press 'M-&', enter 'cat /tmp/test.txt' as input and hit enter.
3) Emacs prompts for a password.

I expect that 3) should not happen as the output is simply to stdout and
no stdin input is expected. Note that the reproducer is minimal and a
bit contrived but the real bug showed itself when I was running a big
test suite that contained several lines ending with "password:" in its
output.

I've also tested this with the latest master (commit
3a4c408a7b6f3df5ca0eb4a406efbdb4899e9742), where it sometimes happens as
well and sometimes you just get an error like this:

Error running timer: (error "Buffer *Async Shell Command* has no process")


In GNU Emacs 28.1.90 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-07-01 built on jsynacek-home
Repository revision: 7e33618bbc07b65c36744db8e7ef219d2d942456
Repository branch: emacs-28
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Arch Linux

Configured using:
 'configure --with-imagemagick --with-json --with-native-compilation
 --prefix=/home/jsynacek/emacs'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
IMAGEMAGICK JPEG JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  windmove-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  global-so-long-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/jsynacek/.emacs.d/elpa/transient-20220514.945/transient hides /home/jsynacek/emacs/share/emacs/28.1.90/lisp/transient

Features:
(shadow sort mail-extr emacsbug tabify man windmove vc-mtn vc-hg vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs counsel xdg swiper misearch
multi-isearch vc-git magit-extras face-remap dired-aux haskell-lite
github-actions-lite cabal-project-lite cabal-lite dockerfile-lite
the-org-mode-expansions org-element avl-tree org ob ob-tangle ob-ref
ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp
ob-core ob-eval org-table oc-basic bibtex iso8601 ol org-keys oc
org-compat org-macs org-loaddefs find-func cal-menu calendar
cal-loaddefs vc-dir ewoc slime etags fileloop generator xref project
arc-mode archive-mode noutline outline hyperspec rg files-x vc
vc-dispatcher rg-info-hack rg-menu rg-ibuffer rg-result wgrep-rg wgrep
rg-history rg-header ibuf-ext ibuffer ibuffer-loaddefs grep cus-edit pp
cus-load wid-edit pulse magit-submodule magit-obsolete magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
diff-mode git-commit log-edit easy-mmode message rmc puny rfc822 mml
mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert autorevert filenotify magit-margin magit-transient
magit-process with-editor magit-mode magit-git magit-base magit-section
crm dash compat-27 compat-26 jsynacek-text jsynacek-term term disp-table
shell pcomplete ehelp jsynacek-project ivy delsel ivy-faces ivy-overlay
colir color expand-region text-mode-expansions er-basic-expansions
thingatpt expand-region-core advice expand-region-custom dired
dired-loaddefs avy transient time-date format-spec compat edmacro kmacro
jsynacek-misc jsynacek-elisp smtpmail sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils so-long open-color server
compile text-property-search comint ansi-color ring slime-autoloads info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap url-handlers
url-parse auth-source eieio eieio-core eieio-loaddefs password-cache
json map url-vars comp comp-cstr warnings subr-x rx cl-seq cl-macs
cl-extra help-mode seq byte-opt gv cl-loaddefs cl-lib bytecomp
byte-compile cconv iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 625701 124605)
 (symbols 48 28318 7)
 (strings 32 137451 11163)
 (string-bytes 1 4439546)
 (vectors 16 65984)
 (vector-slots 8 1019313 83933)
 (floats 8 312 708)
 (intervals 56 17397 65)
 (buffers 992 42))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Sat, 02 Jul 2022 12:29:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jan Synáček <jan.synacek <at> gmail.com>
Cc: 56336 <at> debbugs.gnu.org
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when
 output from async command contains "password:"
Date: Sat, 02 Jul 2022 14:28:34 +0200
Jan Synáček <jan.synacek <at> gmail.com> writes:

> When the output from a command spawned with 'M-&' (async-shell-command)
> ends with "password:" Emacs prompts for a password.
>
> Reproducer:
> 0) $ cat /tmp/test.txt
>    enter your password:
> 1) emacs -Q
> 2) Press 'M-&', enter 'cat /tmp/test.txt' as input and hit enter.
> 3) Emacs prompts for a password.
>
> I expect that 3) should not happen as the output is simply to stdout and
> no stdin input is expected. Note that the reproducer is minimal and a
> bit contrived but the real bug showed itself when I was running a big
> test suite that contained several lines ending with "password:" in its
> output.
>
> I've also tested this with the latest master (commit
> 3a4c408a7b6f3df5ca0eb4a406efbdb4899e9742), where it sometimes happens as
> well and sometimes you just get an error like this:
>
> Error running timer: (error "Buffer *Async Shell Command* has no process")

I've now fixed the latter in Emacs 29.

The former problem is rather intractable.  That is, if you say

ssh foo <at> host

you'll get a password prompt as the final line in the buffer, and Emacs
will ask you to enter a password.

If you say

echo -n "password: "; sleep 10; echo foo

then there's no way for Emacs to distinguish that from the ssh
situation: It sees a prompt as the last thing in the buffer, and Emacs
can't possibly know that that's not a process asking for a password.

Note that

echo "password: "; echo foo; sleep 10

won't ask for a password.

So I don't know that there's any way to fix this -- Emacs uses a
heuristic, and it will be wrong in some cases.

Or does anybody have any ideas here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 02 Jul 2022 12:30:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Sun, 03 Jul 2022 07:43:01 GMT) Full text and rfc822 format available.

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

From: miha <at> kamnitnik.top
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Jan Synáček
 <jan.synacek <at> gmail.com>
Cc: 56336 <at> debbugs.gnu.org
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when
 output from async command contains "password:"
Date: Sun, 03 Jul 2022 09:53:20 +0200
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I've now fixed the latter in Emacs 29.

Thanks. I think an equivalent change could be made for
eshell-watch-for-password-prompt and term-watch-for-password-prompt as
well.

Best regards.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Sun, 03 Jul 2022 12:21:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: miha <at> kamnitnik.top
Cc: 56336 <at> debbugs.gnu.org, Jan Synáček <jan.synacek <at> gmail.com>
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when
 output from async command contains "password:"
Date: Sun, 03 Jul 2022 14:19:49 +0200
miha <at> kamnitnik.top writes:

> Thanks. I think an equivalent change could be made for
> eshell-watch-for-password-prompt and term-watch-for-password-prompt as
> well.

Are they used in contexts where this is meaningful?  I.e., used from
commands like `M-&' that kill off the shell?

But I guess for resilience it doesn't hurt...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Sun, 03 Jul 2022 16:55:02 GMT) Full text and rfc822 format available.

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

From: Jan Synáček <jan.synacek <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 56336 <at> debbugs.gnu.org
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when output
 from async command contains "password:"
Date: Sun, 3 Jul 2022 18:54:10 +0200
On Sat, Jul 2, 2022 at 2:28 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> The former problem is rather intractable.  That is, if you say
>
> ssh foo <at> host
>
> you'll get a password prompt as the final line in the buffer, and Emacs
> will ask you to enter a password.
>
> If you say
>
> echo -n "password: "; sleep 10; echo foo
>
> then there's no way for Emacs to distinguish that from the ssh
> situation: It sees a prompt as the last thing in the buffer, and Emacs
> can't possibly know that that's not a process asking for a password.
>
> Note that
>
> echo "password: "; echo foo; sleep 10
>
> won't ask for a password.
>
> So I don't know that there's any way to fix this -- Emacs uses a
> heuristic, and it will be wrong in some cases.
>
> Or does anybody have any ideas here?

Well, I know about one thing that might work well enough as an
additional heuristic just for this case.

It seems that if a command only outputs to stdout (and probably to
stderr as well) and doesn't really ask for input, lsof -p <that async
process> shows something like this:
$ lsof -p 145475
...
sleep   145475 jsynacek    0u   CHR  136,1      0t0        4 /dev/pts/1
sleep   145475 jsynacek    1u   CHR  136,1      0t0        4 /dev/pts/1
sleep   145475 jsynacek    2u   CHR  136,1      0t0        4 /dev/pts/1

Whereas if the command really wants input ('ssh jsynacek <at> localhost' in
this particular example), it looks like the following:
$ lsof -p 145512
...
ssh     145512 jsynacek    0u   CHR              136,1      0t0
4 /dev/pts/1
ssh     145512 jsynacek    1u   CHR              136,1      0t0
4 /dev/pts/1
ssh     145512 jsynacek    2u   CHR              136,1      0t0
4 /dev/pts/1
ssh     145512 jsynacek    3u  IPv6             203802      0t0
TCP localhost:32864->localhost:ssh (ESTABLISHED)
ssh     145512 jsynacek    4u  unix 0x000000006034f025      0t0
203803 type=STREAM (CONNECTED)
ssh     145512 jsynacek    5u   CHR                5,0      0t0
11 /dev/tty

Note the /dev/tty in the output. I'm not sure, but I think this might
be good enough.

-- 
Jan Synáček




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Mon, 04 Jul 2022 10:54:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jan Synáček <jan.synacek <at> gmail.com>
Cc: 56336 <at> debbugs.gnu.org
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when
 output from async command contains "password:"
Date: Mon, 04 Jul 2022 12:53:18 +0200
Jan Synáček <jan.synacek <at> gmail.com> writes:

> Well, I know about one thing that might work well enough as an
> additional heuristic just for this case.
>
> It seems that if a command only outputs to stdout (and probably to
> stderr as well) and doesn't really ask for input, lsof -p <that async
> process> shows something like this:
> $ lsof -p 145475

[...]

> Note the /dev/tty in the output. I'm not sure, but I think this might
> be good enough.

It's not portable across operating systems, though.  (And the processes
may play shenanigans with detaching and spawning other processes that
then ask for a password (think xdg-open and friends), so it's not
reliable on Linux either.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56336; Package emacs. (Tue, 02 Aug 2022 11:03:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: miha <at> kamnitnik.top
Cc: 56336 <at> debbugs.gnu.org, Jan Synáček <jan.synacek <at> gmail.com>
Subject: Re: bug#56336: 28.1.90; [28.1] Emacs prompts for password when
 output from async command contains "password:"
Date: Tue, 02 Aug 2022 13:02:03 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> Thanks. I think an equivalent change could be made for
>> eshell-watch-for-password-prompt and term-watch-for-password-prompt as
>> well.
>
> Are they used in contexts where this is meaningful?  I.e., used from
> commands like `M-&' that kill off the shell?

There wasn't any followup here in a month, so I don't think it's worth
tweaking this more unless anybody has an actual case where this bugs
out, and I'm therefore closing this bug report.





bug marked as fixed in version 29.1, send any further explanations to 56336 <at> debbugs.gnu.org and Jan Synáček <jan.synacek <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 02 Aug 2022 11:03: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. (Tue, 30 Aug 2022 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 351 days ago.

Previous Next


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