From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jan =?UTF-8?Q?Syn=C3=A1=C4=8Dek?= Newsgroups: gmane.emacs.bugs Subject: 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 Message-ID: References: <87r13511lv.fsf@gmail.com> <87tu7z1yx9.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14750"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56336@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 03 18:55:23 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o82sU-0003ch-Hd for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 18:55:22 +0200 Original-Received: from localhost ([::1]:40446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o82sT-0001vv-El for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 12:55:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o82sA-0001vl-OP for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 12:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o82sA-0001nr-GM for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 12:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o82sA-0007Kd-AQ for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 12:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jan =?UTF-8?Q?Syn=C3=A1=C4=8Dek?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jul 2022 16:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56336 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 56336-submit@debbugs.gnu.org id=B56336.165686727028128 (code B ref 56336); Sun, 03 Jul 2022 16:55:02 +0000 Original-Received: (at 56336) by debbugs.gnu.org; 3 Jul 2022 16:54:30 +0000 Original-Received: from localhost ([127.0.0.1]:45453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o82re-0007Jc-Bp for submit@debbugs.gnu.org; Sun, 03 Jul 2022 12:54:30 -0400 Original-Received: from mail-vs1-f49.google.com ([209.85.217.49]:40691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o82rb-0007JM-GK for 56336@debbugs.gnu.org; Sun, 03 Jul 2022 12:54:28 -0400 Original-Received: by mail-vs1-f49.google.com with SMTP id q28so6966841vsp.7 for <56336@debbugs.gnu.org>; Sun, 03 Jul 2022 09:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=V75P5r/w0+X8KNM0p2UEtvWI2/j13d09q3c5MSuFd0E=; b=V3iOuKChplUN3xEFj/HGpgpk3lsafuuP0QU6HBKeuu/9jwd//9v4vqaysw4TLX19we 0lImpLksSJ2WKfvJcVHoYFr0EeyWAhMYwKeOSERS79B3pmOvoawVyW0Xtr8GqGQ3WKnV PCtm3OYaQ+Hz7ONN4b99kWMV0bxsDcMP4bMLiwC6Z9RqiAJaOF8JGtkW9445TJHC0Tlj ShFKxY6KYh/XHNO14hLNUuVefx4laHb7l5gg0uCDTWw+z3/FdSabaNH3KlmvQBtqL4gf KREPYvApYpTBTPSVnR0XaIRP+gfZgKizasl5dEJjGYjWO4AurHa9cV65KOeEW1STGDjr 9pmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=V75P5r/w0+X8KNM0p2UEtvWI2/j13d09q3c5MSuFd0E=; b=j0xO59PsiuOa+8nVWGToWf9LNqcZtkep7hl9LacYBtVE06HX46hP4DVTBL4mwDRwuU BEh+xUJyefaYnnteUhun9l2DDnzENhCf7fMKY2VNVPyRC3kLAJUMAG4usF+llry/DNNS Ae5KFVzV38GeV2eKp2sw5kwZNbFI8TwZztcrBfE8q2zj7BAxDUVwksgN7ZpFNd1jMUVV WcQZ/OC2jyP+MZVW7egWv7CqE5KjxRQi19cT36EOpvTSPLqOGPDJdcB9qJZFGGKXG/bz xejsxRHUTg7S34Vh/zds0RVNT+I4du0KtfH1RpJ60YWtYnrmTe0YYq7qWuW6nLS23rqg Ly5Q== X-Gm-Message-State: AJIora/S+RLA9ZBgOrcPAQ3d5z5gduJ1T0EnlhmepkApp2i0bpXzPm9D ZK+mrjrzp2cSE35RMjHEGxqC8tnxKa6Dvso4QY8= X-Google-Smtp-Source: AGRyM1tyzjSQsUgCNQSRz9ugWTFSzW3pHHb2AqlczGkQcLqBvKCdUb2BIqMJuiaMaVMMvLfNSPWLclVI6f0jhw3pIXQ= X-Received: by 2002:a67:ce02:0:b0:354:2ad9:963a with SMTP id s2-20020a67ce02000000b003542ad9963amr14288782vsl.44.1656867261714; Sun, 03 Jul 2022 09:54:21 -0700 (PDT) In-Reply-To: <87tu7z1yx9.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:236013 Archived-At: On Sat, Jul 2, 2022 at 2:28 PM Lars Ingebrigtsen wrote: > The former problem is rather intractable. That is, if you say > > ssh foo@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 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@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=3DSTREAM (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. --=20 Jan Syn=C3=A1=C4=8Dek