From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#30190: 27.0.50; term run in line mode shows user passwords Date: Sun, 4 Feb 2018 12:40:07 +0900 (JST) Message-ID: References: <87r2qjh0fs.fsf@gmail.com> <87mv17nwe4.fsf@users.sourceforge.net> <87efm259s5.fsf@gmail.com> <83vafe9f16.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1969643053-1517715610=:4034" X-Trace: blaine.gmane.org 1517715559 19172 195.159.176.226 (4 Feb 2018 03:39:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Feb 2018 03:39:19 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 30190@debbugs.gnu.org, Tino Calancha , npostavs@users.sourceforge.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 04 04:39:15 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiB94-0004QR-Tx for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Feb 2018 04:39:11 +0100 Original-Received: from localhost ([::1]:55546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBB4-0002AD-8M for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Feb 2018 22:41:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBAw-00028i-KX for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 22:41:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiBAs-00058W-MI for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 22:41:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48251) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiBAs-00058Q-IK for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 22:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eiBAr-0005D5-TR for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 22:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Feb 2018 03:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30190 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 30190-submit@debbugs.gnu.org id=B30190.151771561919973 (code B ref 30190); Sun, 04 Feb 2018 03:41:01 +0000 Original-Received: (at 30190) by debbugs.gnu.org; 4 Feb 2018 03:40:19 +0000 Original-Received: from localhost ([127.0.0.1]:56148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiBAB-0005C5-9q for submit@debbugs.gnu.org; Sat, 03 Feb 2018 22:40:19 -0500 Original-Received: from mail-pg0-f53.google.com ([74.125.83.53]:39480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiBA8-0005Bp-RE for 30190@debbugs.gnu.org; Sat, 03 Feb 2018 22:40:17 -0500 Original-Received: by mail-pg0-f53.google.com with SMTP id w17so15969171pgv.6 for <30190@debbugs.gnu.org>; Sat, 03 Feb 2018 19:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=LKWc1ywGZhVTJq5XJRPhdcP9MvSTHooGWYCRXF87yOs=; b=ttUwuJLhUt/Nq1aWtlBeY6r03wCAcfZ07kPYckHoLH1zZWwDIXkM3K8+oWCKlPSk2Z cVKHC3MTE7kmHA6PbkKG/pQycGAcq4nfWCtrsKy8TsDHB8+pnpbqjPMCFmw4L6m+UqfY TiZft4NaMmlRcLOwMz93Rxv8gB2yZ88/HTU/xrGkfgvox9vug0yvGt9yGsXELqqFcW8D EitC74VWMZ2tauiUfNFk0W50hpi+lB8d76xUJ1x9k2A2pJG2SDkqbrRprJfhJ45JGlsh +FZNRWbKvqpGjczSkzKfpcbxDqgNXcwGzr+l4CSROklHjsQR1qlfjTM25n3N6KOBJNf4 eL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=LKWc1ywGZhVTJq5XJRPhdcP9MvSTHooGWYCRXF87yOs=; b=OMiNVPyu53oyDOyxVpxcV7WezgAmreG7zokY4PuiSXD7gagvILywGp+MEaDjoK/FJz PwTYFopK11Rgc1/ZUG1cFZ2Tx3HVdY82kAEQiyLXpXkqRNOuoK0mEunvMkluYE5w87f+ ZlHnpvMftCeTfQjN34D2veMJA5FtNc2dx4S5IMb7SChjL5PcqqCLd/piA7/Ne/FYl0QJ zOG1qlDKy0axchlg7mBSak6IzOkAQi6eXTtXa0eLIu7CKyrqGHddka1GkByPl2quE3JP HUKjhNUn4mgUWeliuJ98wpokO+4dtBAnNe3e4V0hrENqz0Z4B1nPXi3YKhDwXI7C7Bkn RWwQ== X-Gm-Message-State: AKwxytcMYeqPrN0lTrL/SW55E+AMwbG5AnKFI4uAdfE8jbayo9npEoqA /kJ2vNKjJEC6UhY2SA/crQ0= X-Google-Smtp-Source: AH8x226c3kKVnVsiJZjsurM4RL0SOpUA2oWEPg7IDIx8cyxo3IrbMkn/GunwZoGHXmmuDRt2InRYuQ== X-Received: by 10.99.164.25 with SMTP id c25mr35003075pgf.430.1517715611089; Sat, 03 Feb 2018 19:40:11 -0800 (PST) Original-Received: from calancha-pc (146.219.128.101.dy.bbexcite.jp. [101.128.219.146]) by smtp.gmail.com with ESMTPSA id w10sm8719704pgr.57.2018.02.03.19.40.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Feb 2018 19:40:10 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83vafe9f16.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142876 Archived-At: --8323329-1969643053-1517715610=:4034 Content-Type: text/plain; format=flowed; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 3 Feb 2018, Eli Zaretskii wrote: > My feedback is that such a radical solution with so many lines of code > is a no-no for the release branch. Please look for a simpler > solution, perhaps don't create a new file? A suitable patch for the next release for discussion below: --8<-----------------------------cut here---------------start------------->8--- commit 2a0f243ff63772bb16ce4e3666b5fd5e696ea68f Author: tino calancha Date: Sun Feb 4 12:32:04 2018 +0900 Prevent term run in line mode from showing user passwords For buffers whose mode derive from comint-mode, the user password is read from the minibuffer and it's hidden. A buffer in term-mode and line submode, instead shows the passwords. This commit forces buffers in line term-mode to hide passwords (Bug#30190). * lisp/term.el (term-password-prompt-regexp): New user option. (term-watch-for-password-prompt): New function. (term-send-input, term-emulate-terminal): Call it. (term-output-filter-hook): New hook. Add term-watch-for-password-prompt to it. (term-send-input, term-emulate-terminal): Call the new hook each time we receive output. diff --git a/lisp/term.el b/lisp/term.el index 3970e93cf1..49fbc58cf3 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -558,6 +558,27 @@ term-suppress-hard-newline ;; indications of the current pc. (defvar term-pending-frame nil) +;; Stolen from comint.el +(defcustom term-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" "PEM" "SUDO" + "[sudo]" "Repeat" "Bad" "Retype") + t) + " +\\)" + "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)" + "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?" + ;; "[[:alpha:]]" used to be "for", which fails to match non-English. + "\\(?: [[:alpha:]]+ .+\\)?[\\s  ]*[::៖][\\s  ]*\\'") + "Regexp matching prompts for passwords in the inferior process. +This is used by `term-watch-for-password-prompt'." + :version "27.1" + :type 'regexp + :group 'comint) + ;;; Here are the per-interpreter hooks. (defvar term-get-old-input (function term-get-old-input-default) "Function that submits old text in term mode. @@ -586,6 +607,17 @@ term-input-filter-functions This variable is buffer-local.") +;;; Stolen from comint.el +;;;###autoload +(defvar term-output-filter-hook '(term-watch-for-password-prompt) + "Functions to call after output is inserted into the buffer. +One possible function is `term-watch-for-password-prompt'. +These functions get one argument, a string containing the text as originally +inserted. + +You can use `add-hook' to add functions to this list +either globally or locally.") + (defvar term-input-sender (function term-simple-send) "Function to actually send to PROCESS the STRING submitted by user. Usually this is just `term-simple-send', but if your mode needs to @@ -2134,7 +2166,8 @@ term-send-input (set-marker term-pending-delete-marker pmark-val) (set-marker (process-mark proc) (point))) (goto-char pmark) - (funcall term-input-sender proc input))))) + (funcall term-input-sender proc input) + (run-hook-with-args 'term-output-filter-hook ""))))) (defun term-get-old-input-default () "Default for `term-get-old-input'. @@ -2264,6 +2297,21 @@ term-send-invisible (term-send-string proc str) (term-send-string proc "\n"))) +;;; Stolen from comint.el +;; TODO: This file share plenty of code with comint.el; it might be worth +;; to extract the common functionality into a new file. +(defun term-watch-for-password-prompt (string) + "Prompt in the minibuffer for password and send without echoing. +This function uses `term-send-invisible' to read and send a password to the buffer's +process if STRING contains a password prompt defined by +`term-password-prompt-regexp'. + +This function could be in the list `term-emulate-terminal'." + (when (term-in-line-mode) + (when (let ((case-fold-search t)) + (string-match term-password-prompt-regexp string)) + (term-send-invisible nil)))) + ;;; Low-level process communication @@ -3121,6 +3169,8 @@ term-emulate-terminal (term-handle-deferred-scroll)) (set-marker (process-mark proc) (point)) + ;; Run these hooks with point where the user had it. + (run-hook-with-args 'term-output-filter-hook str) (when save-point (goto-char save-point) (set-marker save-point nil)) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.91 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2018-02-04 built on calancha-pc Repository revision: aafcd12eebff1549b3d4b4f8f8d0f24498c1aedf --8323329-1969643053-1517715610=:4034--