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 21:47:56 +0900 (JST) Message-ID: References: <87r2qjh0fs.fsf@gmail.com> <87mv17nwe4.fsf@users.sourceforge.net> <87efm259s5.fsf@gmail.com> <83vafe9f16.fsf@gnu.org> <87a7wpexm5.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-816559170-1517748479=:24516" X-Trace: blaine.gmane.org 1517748449 7739 195.159.176.226 (4 Feb 2018 12:47:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Feb 2018 12:47:29 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 30190@debbugs.gnu.org, Tino Calancha To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 04 13:47:24 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 1eiJhN-0000rW-3N for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Feb 2018 13:47:09 +0100 Original-Received: from localhost ([::1]:45311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiJjO-00059b-33 for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Feb 2018 07:49:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiJjH-000592-8V for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 07:49:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiJjC-00084H-CC for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 07:49:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiJjC-00083r-8j for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 07:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eiJjB-0003Im-P0 for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 07:49:01 -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 12:49: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.151774848812631 (code B ref 30190); Sun, 04 Feb 2018 12:49:01 +0000 Original-Received: (at 30190) by debbugs.gnu.org; 4 Feb 2018 12:48:08 +0000 Original-Received: from localhost ([127.0.0.1]:56244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiJiK-0003He-GR for submit@debbugs.gnu.org; Sun, 04 Feb 2018 07:48:08 -0500 Original-Received: from mail-pg0-f49.google.com ([74.125.83.49]:45044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiJiI-0003HG-TW for 30190@debbugs.gnu.org; Sun, 04 Feb 2018 07:48:07 -0500 Original-Received: by mail-pg0-f49.google.com with SMTP id r1so716754pgn.11 for <30190@debbugs.gnu.org>; Sun, 04 Feb 2018 04:48:06 -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=h5ISj8KbQgFuXvGAPeG1dKIPtfG5AqaMQpVsq2NLE9Y=; b=WPQtxIRjO/eKECi7GWiCmjIMCSO49CUpR+yYpgt/MNjdSnPnjrsRaN6j43DvVFLVgz W9wqcHm+E4Ab1ixgBkwFV36jy6FCiVywSCJ/60obXauyXyOBjfyrfHn/9mMdAKXutrlL ZE8/SGgpRzl7laj/J2YtsAVHlTssChvBbf4LKZWQbUb0UBLdULqt2JIyJIT2jXrOGiqc qR4veCuaYZF2Bi87lkQPmTxCZABnm2PNDH7nJx5WO4CnbCIGM3TQm6dP1YmkQJbfYDmT iF+fW4xcnJcdciH5MXI9xgK2RQ4nwhiezly8kNMdB8tyykTDcuRfEZXdLLH9S8QbB9W+ E6eg== 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=h5ISj8KbQgFuXvGAPeG1dKIPtfG5AqaMQpVsq2NLE9Y=; b=i1bzDVVdf0BqN1vE2x/NYoQ8+KGSBDtcLswptnib4JDiyced7Rksl8TF6187+bVlYx rG6YefeR4G0dUmpJcWt0jbEJvRk7tq36H0uK7U9zCQiB1y7nDOp4ndz3TT1AaSYmfrDM EatZVHLpset+biEYkH/oX9bZPjZP4h1w4mqlFdV4CflWilu1KBZ4M6s/CFmHtQA9cW0c 4E2I2AEt2uJHAfP4jTeqAc+lEwHpYGWF9LbaTs+5n8vA6e5cUYcwXF5XaIa5QPe643nq 7ErZIVt2e5gCt80oHStvscaeoWb0FH+T7kPL4c/jupNHYFTS6LzCGqEoxK6SQRhZGyYf W7ow== X-Gm-Message-State: AKwxytfluP+I+WLuWEVx0e6axlNwDWIey5MrLNbUbrHtKnQqeX4CUWHj BnF5SQ/lTE6DUREixfyT+qE= X-Google-Smtp-Source: AH8x2259lOAOlV+zjEpLIu8wadfO796Am3z4WARSsQ/GbCovQKn00eM2f6pmoJy0+udH2/aVxKHTsQ== X-Received: by 10.101.69.66 with SMTP id x2mr36173436pgr.69.1517748480979; Sun, 04 Feb 2018 04:48:00 -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 j83sm7091973pfe.47.2018.02.04.04.47.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Feb 2018 04:47:59 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87a7wpexm5.fsf@users.sourceforge.net> 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:142883 Archived-At: --8323329-816559170-1517748479=:24516 Content-Type: text/plain; format=flowed; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sun, 4 Feb 2018, Noam Postavsky wrote: > Tino Calancha writes: > >> 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: >> > >> +;; Stolen from comint.el >> +(defcustom term-password-prompt-regexp > >> + :version "27.1" That's right. Well catched, thank you! Updated patch. > > I guess this should say "26.1". Although maybe we should just use > comint-password-prompt-regexp in term.el instead? Part of the fun is to prevent term.el from requiring comint.el as always has be done; just for using one variable I would not require comint.el. --8<-----------------------------cut here---------------start------------->8--- commit 6187b493ded4bdcfd3c6b6fa91333c381fba8913 Author: tino calancha Date: Sun Feb 4 21:43:43 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..6fddef6f82 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 "26.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--- --8323329-816559170-1517748479=:24516--