From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 18 07:51:35 2021 Received: (at submit) by debbugs.gnu.org; 18 Oct 2021 11:51:35 +0000 Received: from localhost ([127.0.0.1]:46103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcRB1-0004QW-4g for submit@debbugs.gnu.org; Mon, 18 Oct 2021 07:51:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:40046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcRAx-0004QM-Ma for submit@debbugs.gnu.org; Mon, 18 Oct 2021 07:51:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcRAw-0002rF-Gt for bug-gnu-emacs@gnu.org; Mon, 18 Oct 2021 07:51:31 -0400 Received: from kamnitnik.top ([2001:19f0:5001:bf2:5400:2ff:fee0:2626]:49010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcRAt-0007L0-Rb for bug-gnu-emacs@gnu.org; Mon, 18 Oct 2021 07:51:29 -0400 Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id 5703E9C707 for ; Mon, 18 Oct 2021 11:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1634557883; bh=exna0SGpOm+cV4eMaBhoGbbNQAExaMbjcLNCGLzgLnY=; h=From:To:Subject:Date:From; b=wgLZpGmiMOu/uUuWw5wFCtEMp4cv1Wsi4sgaGiI0voNFzsooIJNOWqfNccxuXhwM1 zgQYkLF9j/J8GU9FPQdA5FIyaJN1th1YRcu1fChEucWrmBIoXkuu5O7PY1uXpvw9HA 9ksUGOe3xyIKrC/S0xX1d4wfFNs2LjkEqWa6sE9PZojmrPt+8PW9un/rT8gUhXhkQw sCWpDYHkfCzMWfpwCJnoVnh0PjlxZDTUZqYBOr+sJdqeM/XOlN/5y1cG98AQjhZoEV WirhFzDncVA7tNW6UqyYIV2PTRRFIdFM5qnmDkOj3t4lUIBqOYFx9Z8pQI5f/FTsj8 EqGsUbqCNOuGw== From: miha@kamnitnik.top To: bug-gnu-emacs@gnu.org Subject: 29.0.50; [PATCH] Use run-at-time to read a password in comint Date: Mon, 18 Oct 2021 13:54:59 +0200 Message-ID: <87k0ia4kfg.fsf@miha-pc> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=2001:19f0:5001:bf2:5400:2ff:fee0:2626; envelope-from=miha@kamnitnik.top; helo=kamnitnik.top X-Spam_score_int: 24 X-Spam_score: 2.4 X-Spam_bar: ++ X-Spam_report: (2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently, comint-watch-for-password-prompt has some problems. It is called from the comint process filter and doesn't return until the user exits the password minibuffer. If the process produces more output while the minibuffer is still open (this happens if the "sudo" command times out, for example), the process filter will be called recursively before the current exe [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: kamnitnik.top (top)] 0.9 SPF_FAIL SPF: sender does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=mfrom; id=miha%40kamnitnik.top; ip=209.51.188.17; r=debbugs.gnu.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.51.188.17 listed in wl.mailspike.net] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] 0.5 FROM_SUSPICIOUS_NTLD_FP From abused NTLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Currently, comint-watch-for-password-prompt has some problems. It is called from the comint process filter and doesn't return until the user exits the password minibuffer. If the process produces more output while the minibuffer is still open (this happens if the "sudo" command times out, for example), the process filter will be called recursively before the current execution of the process filter has a chance to finish. This filter function uses some global/buffer-local, state (the variable comint-last-output-start, for example), so it isn't made to be called simultaneously like that. The user may also quit the password minibuffer with C-g, canceling execution of the filter function. The result of these two events is usually that the buffer text containing the password prompt isn't correctly marked as output with the 'field text property. Further problems may arise if comint-output-filter-functions contain functions after the password prompt watcher. I've come up with a solution: using (run-at-time 0 ...), we can prompt for a password after the filter function finishes execution. The attached patch implements this for comint, eshell and term.el. Best regards. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-watch-for-password-prompt-Use-run-at-time-to-read-pa.patch Content-Transfer-Encoding: quoted-printable From=20d4e8af0f4d90c7d989f21781fc7ca7fd284652bf Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Mon, 18 Oct 2021 13:13:45 +0200 Subject: [PATCH] *-watch-for-password-prompt: Use run-at-time to read passw= ord * lisp/comint.el (comint-watch-for-password-prompt): * lisp/eshell/esh-mode.el (eshell-watch-for-password-prompt): * lisp/term.el (term-watch-for-password-prompt): Use run-at-time to read a password. =2D-- lisp/comint.el | 18 +++++++++++++----- lisp/eshell/esh-mode.el | 9 ++++++++- lisp/term.el | 9 ++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index a0873c0b6a..e925b3a4b6 100644 =2D-- a/lisp/comint.el +++ b/lisp/comint.el @@ -2455,11 +2455,19 @@ comint-watch-for-password-prompt (when (let ((case-fold-search t)) (string-match comint-password-prompt-regexp (string-replace "\r" "" string))) =2D (let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-d= epth))) =2D (if (> comint--prompt-recursion-depth 10) =2D (message "Password prompt recursion too deep") =2D (comint-send-invisible =2D (string-trim string "[ \n\r\t\v\f\b\a]+" "\n+")))))) + ;; Use `run-at-time' in order not to pause execution of the + ;; process filter with a minibuffer + (run-at-time + 0 nil + (lambda (current-buf) + (with-current-buffer current-buf + (let ((comint--prompt-recursion-depth + (1+ comint--prompt-recursion-depth))) + (if (> comint--prompt-recursion-depth 10) + (message "Password prompt recursion too deep") + (comint-send-invisible + (string-trim string "[ \n\r\t\v\f\b\a]+" "\n+")))))) + (current-buffer)))) ;; Low-level process communication =20 diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 98e89037f3..579b01f4d1 100644 =2D-- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -940,7 +940,14 @@ eshell-watch-for-password-prompt (beginning-of-line) (if (re-search-forward eshell-password-prompt-regexp eshell-last-output-end t) =2D (eshell-send-invisible)))))) + ;; Use `run-at-time' in order not to pause execution of + ;; the process filter with a minibuffer + (run-at-time + 0 nil + (lambda (current-buf) + (with-current-buffer current-buf + (eshell-send-invisible))) + (current-buffer))))))) =20 (custom-add-option 'eshell-output-filter-functions 'eshell-watch-for-password-prompt) diff --git a/lisp/term.el b/lisp/term.el index dd5457745b..530b93484e 100644 =2D-- a/lisp/term.el +++ b/lisp/term.el @@ -2409,7 +2409,14 @@ term-watch-for-password-prompt (when (term-in-line-mode) (when (let ((case-fold-search t)) (string-match comint-password-prompt-regexp string)) =2D (term-send-invisible (read-passwd string))))) + ;; Use `run-at-time' in order not to pause execution of the + ;; process filter with a minibuffer + (run-at-time + 0 nil + (lambda (current-buf) + (with-current-buffer current-buf + (term-send-invisible (read-passwd string)))) + (current-buffer))))) =20 ;;; Low-level process communication =2D-=20 2.33.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmFtYJMTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP0wWD/0S+j4XkLLP3QoeAW89Zpb14lYOfvqR 3VW9T84wUVfGuoxeuAbrxmQqMJoGJDaQUXableKWBEa2aI1LTxb4tM906Qsxq+r5 MprCg/BAYxVWZDpDU2hjLPv4pj8GOW45u538MLktgXqOAnYZaqBYT8kZRHGbGOui pvr+FneDP48vMBaRsLDVZVwKwZLUBAfeEW0MsL5omIrZ5/CrzqEivlzos2kAimUX zs0cK3hiEIxFOTWwt7Paf6xGzRinJWbswe1Rn1Sb3heVsz6rFFT/aQHqXp0++foX X5z6qvAqg8Q0EEdLNAcBCwqFf6UrNJ5nHm/zSZu0x565XCYx7OCFZ9vrpsTVgHmG YrowQ3ygCL7s/20P5kzXe2/vDZnwbx9sLdBJWKmWt/GpRmt1oVHr9Lb3LqKS8Ujq 3zKduP96ZNE817Y8Z6u86JEX3Cb4Myw62Bjkt33WGzZqM2niQM7EnRj05bVN6pO7 AuneMmKjnI5PcbmJE6zohcTn3v+MMzpijzM5Kzy5V39qrIxQaSaOdsGpagp7ms/s xLSCME0cvz/ZNGD0S0HP5R2rNsGe9qnF71j3OQ6uhmMKui2Ud4fO7zVn81n5wpIE UvSMnJCOdOvscJEl9Kzt2NUIdsL8pWpBYt4HaWBH/fRMYpmFonv1lzwG1CKGFsxX FUHsCeHK2kIryg== =2+CK -----END PGP SIGNATURE----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 18 09:26:06 2021 Received: (at 51263) by debbugs.gnu.org; 18 Oct 2021 13:26:06 +0000 Received: from localhost ([127.0.0.1]:46269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcSeU-0006p2-FA for submit@debbugs.gnu.org; Mon, 18 Oct 2021 09:26:06 -0400 Received: from quimby.gnus.org ([95.216.78.240]:51894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcSeS-0006of-HI for 51263@debbugs.gnu.org; Mon, 18 Oct 2021 09:26:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i30bBZFYbjRm95WXOizhQBq1ATVDjsCbfuzSv4G+CMI=; b=S3ETC9eeLzhp43cHl+G/tsaHrx aIUT8RcAKrGYO7xKYTOunCHo9FCTmWrTTaPphQEzo3kxhzwA4wQ7eh5iT3MUzk1tOujVG5txHgclH KqEBgKh6I0GVZME8o/4VSTDaJje2CZUpXUT7qk0D1xusF6LIw0s/IDVAl65Kp0IDoS90=; Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcSeJ-0002zB-9V; Mon, 18 Oct 2021 15:25:57 +0200 From: Lars Ingebrigtsen To: miha@kamnitnik.top Subject: Re: bug#51263: 29.0.50; [PATCH] Use run-at-time to read a password in comint References: <87k0ia4kfg.fsf@miha-pc> X-Now-Playing: Deru's _Pushing Air_: "Flux of Humor" Date: Mon, 18 Oct 2021 15:25:54 +0200 In-Reply-To: <87k0ia4kfg.fsf@miha-pc> (miha@kamnitnik.top's message of "Mon, 18 Oct 2021 13:54:59 +0200") Message-ID: <87k0iaihwd.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: miha@kamnitnik.top writes: > I've come up with a solution: using (run-at-time 0 ...), we can prompt > for a password after the filter function finishes execution. The > attached patch implements this for comint, eshell and term [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 51263 Cc: 51263@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) miha@kamnitnik.top writes: > I've come up with a solution: using (run-at-time 0 ...), we can prompt > for a password after the filter function finishes execution. The > attached patch implements this for comint, eshell and term.el. Seems to work very nicely -- I tried mixing some async output while prompting for a "su" password, and I couldn't see any glitches, so I've pushed your patch to Emacs 29. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 18 09:26:11 2021 Received: (at control) by debbugs.gnu.org; 18 Oct 2021 13:26:11 +0000 Received: from localhost ([127.0.0.1]:46272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcSeY-0006pI-OI for submit@debbugs.gnu.org; Mon, 18 Oct 2021 09:26:11 -0400 Received: from quimby.gnus.org ([95.216.78.240]:51910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcSeW-0006os-U3 for control@debbugs.gnu.org; Mon, 18 Oct 2021 09:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gVYQDwPwlTTljn3fSXPEPvWcLnHeYGwjV6bgDhXuGx8=; b=OTHpvSzQYU6L7nBnO+Q8Y5KhxT krRyC1820Lt6fZXUf7G8sLcxZMMFpsin1T8D0NW6Wa8UOUBeGhLxzuOldHgHNDgQYN441EQ9R8jKX Clr9wdoPli0MH2lQxkJTQQ0KxY5Hpvzns9MCKdZJj2nE5AKWa2NtkPJZFwTJmUPyqlLU=; Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcSeP-0002zK-Gn for control@debbugs.gnu.org; Mon, 18 Oct 2021 15:26:03 +0200 Date: Mon, 18 Oct 2021 15:26:01 +0200 Message-Id: <87ilxuihw6.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #51263 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 51263 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 51263 29.1 quit From unknown Sun Jun 15 08:39:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 16 Nov 2021 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator