From 21f5bd6154f254a53942a9823c9c708ffa4b22a4 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 19 Oct 2019 14:23:21 +0200 Subject: Support PuTTY's antispoof message in Tramp * lisp/net/tramp-sh.el (tramp-actions-before-shell): Add respective entry for PuTTY's antispoof message. * lisp/net/tramp.el (tramp-antispoof-regexp): New defcustom. (tramp-action-confirm-message): New defun. --- lisp/net/tramp-sh.el | 1 + lisp/net/tramp.el | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'lisp/net') diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index e92b9d7729b..26254f87fe1 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -556,6 +556,7 @@ shell from reading its init file." (tramp-yesno-prompt-regexp tramp-action-yesno) (tramp-yn-prompt-regexp tramp-action-yn) (tramp-terminal-prompt-regexp tramp-action-terminal) + (tramp-antispoof-regexp tramp-action-confirm-message) (tramp-process-alive-regexp tramp-action-process-alive)) "List of pattern/action pairs. Whenever a pattern matches, the corresponding action is performed. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 6ff313e8fb3..6c17ef0b344 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -636,6 +636,16 @@ The regexp should match at end of buffer. The answer will be provided by `tramp-action-terminal', which see." :type 'regexp) +;; Plink 0.71 has added an additional anti-spoofing prompt after +;; authentication. This could be discarded with the argument +;; \"-no-antispoof\". However, since we don't know which PuTTY +;; version is installed, we must react interactively. +(defcustom tramp-antispoof-regexp + (regexp-quote "Access granted. Press Return to begin session. ") + "Regular expression matching plink's anti-spoofing message." + :version 27.1 + :type 'regexp) + (defcustom tramp-operation-not-permitted-regexp (concat "\\(" "preserving times.*" "\\|" "set mode" "\\)" ":\\s-*" (regexp-opt '("Operation not permitted") t)) @@ -3935,6 +3945,13 @@ The terminal type can be configured with `tramp-terminal-type'." (tramp-send-string vec (concat tramp-terminal-type tramp-local-end-of-line)) t) +(defun tramp-action-confirm-message (_proc vec) + "Return RET in order to confirm the message." + (with-current-buffer (tramp-get-connection-buffer vec) + (tramp-message vec 6 "\n%s" (buffer-string))) + (tramp-send-string vec tramp-local-end-of-line) + t) + (defun tramp-action-process-alive (proc _vec) "Check, whether a process has finished." (unless (process-live-p proc) -- cgit v1.2.1