GNU bug report logs -
#56336
28.1.90; [28.1] Emacs prompts for password when output from async command contains "password:"
Previous Next
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.
Full log
Message #19 received at 56336 <at> debbugs.gnu.org (full text, mbox):
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
This bug report was last modified 2 years and 352 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.