From c57a0aff3e3e3ddf17af59ea197c0d6c9b959453 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 23 Feb 2013 13:40:14 +0100 Subject: [PATCH] * net/tramp.el (tramp-methods): Fix docstring. (tramp-ssh-controlmaster-options): Rename it from `tramp-ssh-controlmaster-template'. Return a string. (tramp-default-method): Adapt check for `tramp-ssh-controlmaster-options'. * net/tramp-sh.el (tramp-methods): Replace `tramp-ssh-controlmaster-template' by "%c". (tramp-do-copy-or-rename-file-out-of-band) (tramp-maybe-open-connection): Use it in format spec. Ensure, that it is applied for the first hop only. --- lisp/ChangeLog | 14 +++++++ lisp/net/tramp-sh.el | 92 ++++++++++++++++++++------------------------ lisp/net/tramp.el | 17 ++++---- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1555dfc43b6..deeef8d2914 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2013-02-23 Michael Albinus + + * net/tramp.el (tramp-methods): Fix docstring. + (tramp-ssh-controlmaster-options): Rename it from + `tramp-ssh-controlmaster-template'. Return a string. + (tramp-default-method): Adapt check for + `tramp-ssh-controlmaster-options'. + + * net/tramp-sh.el (tramp-methods): Replace + `tramp-ssh-controlmaster-template' by "%c". + (tramp-do-copy-or-rename-file-out-of-band) + (tramp-maybe-open-connection): Use it in format spec. Ensure, + that it is applied for the first hop only. + 2013-02-22 Juri Linkov * isearch.el (isearch-lazy-highlight-new-loop): diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index f2dc514116a..e63acb6b40e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -109,17 +109,15 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-copy-keep-date t))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("scp" + '("scp" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "scp") - (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") ("-r") - ,tramp-ssh-controlmaster-template)) + (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") ("-r") ("%c"))) (tramp-copy-keep-date t) (tramp-copy-recursive t) (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") @@ -128,17 +126,16 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("scp1" + '("scp1" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-1") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "scp") - (tramp-copy-args (("-1") ("-P" "%p") ("-p" "%k") ("-q") ("-r") - ,tramp-ssh-controlmaster-template)) + (tramp-copy-args (("-1") ("-P" "%p") ("-p" "%k") + ("-q") ("-r") ("%c"))) (tramp-copy-keep-date t) (tramp-copy-recursive t) (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") @@ -147,17 +144,16 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("scp2" + '("scp2" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-2") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "scp") - (tramp-copy-args (("-2") ("-P" "%p") ("-p" "%k") ("-q") ("-r") - ,tramp-ssh-controlmaster-template)) + (tramp-copy-args (("-2") ("-P" "%p") ("-p" "%k") + ("-q") ("-r") ("%c"))) (tramp-copy-keep-date t) (tramp-copy-recursive t) (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") @@ -166,17 +162,16 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("scpx" + '("scpx" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("-t" "-t") ("%h") ("/bin/sh"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "scp") - (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") ("-r") - ,tramp-ssh-controlmaster-template)) + (tramp-copy-args (("-P" "%p") ("-p" "%k") + ("-q") ("-r") ("%c"))) (tramp-copy-keep-date t) (tramp-copy-recursive t) (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") @@ -185,34 +180,27 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("sftp" + '("sftp" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "sftp") - (tramp-copy-args ,tramp-ssh-controlmaster-template))) + (tramp-copy-args ("%c")))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("rsync" + '("rsync" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-copy-program "rsync") (tramp-copy-args (("-t" "%k") ("-r"))) - (tramp-copy-env (("RSYNC_RSH") - (,(mapconcat - 'identity - (append - '("ssh") tramp-ssh-controlmaster-template) - " ")))) + (tramp-copy-env (("RSYNC_RSH") ("ssh" "%c"))) (tramp-copy-keep-date t) (tramp-copy-keep-tmpfile t) (tramp-copy-recursive t))) @@ -232,10 +220,9 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-remote-shell-args ("-c")))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("ssh" + '("ssh" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") @@ -246,10 +233,9 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("ssh1" + '("ssh1" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-1") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") @@ -260,10 +246,9 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("ssh2" + '("ssh2" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-2") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") @@ -274,10 +259,9 @@ detected as prompt when being sent on echoing hosts, therefore.") (tramp-default-port 22))) ;;;###tramp-autoload (add-to-list 'tramp-methods - `("sshx" + '("sshx" (tramp-login-program "ssh") - (tramp-login-args (("-l" "%u") ("-p" "%p") - ,tramp-ssh-controlmaster-template + (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("-t" "-t") ("%h") ("/bin/sh"))) (tramp-async-args (("-q"))) (tramp-remote-shell "/bin/sh") @@ -2274,7 +2258,7 @@ The method used must be an out-of-band method." (t2 (tramp-tramp-file-p newname)) (orig-vec (tramp-dissect-file-name (if t1 filename newname))) copy-program copy-args copy-env copy-keep-date port spec - source target) + options source target) (with-parsed-tramp-file-name (if t1 filename newname) nil (if (and t1 t2) @@ -2342,9 +2326,11 @@ The method used must be an out-of-band method." user (or user "") port (or port "") spec (format-spec-make - ?h host ?u user ?p port ?t (tramp-get-connection-property - (tramp-get-connection-process v) "temp-file" "") + (tramp-get-connection-process v) "temp-file" "")) + options (format-spec tramp-ssh-controlmaster-options spec) + spec (format-spec-make + ?h host ?u user ?p port ?c options ?k (if keep-date " " "")) copy-program (tramp-get-method-parameter method 'tramp-copy-program) @@ -4404,6 +4390,9 @@ connection if a previous connection has died for some reason." (setenv "PROMPT_COMMAND") (setenv "PS1" tramp-initial-end-of-output) (let* ((target-alist (tramp-compute-multi-hops vec)) + ;; We will apply `tramp-ssh-controlmaster-options' + ;; only for the first hop. + (options tramp-ssh-controlmaster-options) (process-connection-type tramp-process-connection-type) (process-adaptive-read-buffering nil) (coding-system-for-read nil) @@ -4508,8 +4497,10 @@ connection if a previous connection has died for some reason." l-host (or l-host "") l-user (or l-user "") l-port (or l-port "") + spec (format-spec-make ?t tmpfile) + options (format-spec options spec) spec (format-spec-make - ?h l-host ?u l-user ?p l-port ?t tmpfile) + ?h l-host ?u l-user ?p l-port ?c options) command (concat ;; We do not want to see the trailing local @@ -4536,7 +4527,8 @@ connection if a previous connection has died for some reason." (tramp-message vec 3 "Found remote shell prompt on `%s'" l-host)) ;; Next hop. - (setq target-alist (cdr target-alist))) + (setq options "" + target-alist (cdr target-alist))) ;; Make initial shell settings. (tramp-open-connection-setup-interactive-shell p vec)))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index fe4959715d5..e5e69492130 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -220,7 +220,8 @@ pair of the form (KEY VALUE). The following KEYs are defined: argument. By this, arguments like (\"-l\" \"%u\") are optional. \"%t\" is replaced by the temporary file name produced with `tramp-make-tramp-temp-file'. \"%k\" indicates the keep-date - parameter of a program, if exists. + parameter of a program, if exists. \"%c\" adds additional + `tramp-ssh-controlmaster-options' options for the first hop. * `tramp-async-args' When an asynchronous process is started, we know already that the connection works. Therefore, we can pass additional @@ -281,25 +282,23 @@ started on the local host. You should specify a remote host useful only in combination with `tramp-default-proxies-alist'.") ;;;###tramp-autoload -(defconst tramp-ssh-controlmaster-template - (let (result) +(defconst tramp-ssh-controlmaster-options + (let ((result "")) (ignore-errors (with-temp-buffer (call-process "ssh" nil t nil "-o" "ControlMaster") (goto-char (point-min)) (when (search-forward-regexp "Missing ControlMaster argument" nil t) - (setq result - '("-o" "ControlPath=%t.%%r@%%h:%%p" - "-o" "ControlMaster=auto")))) + (setq result "-o ControlPath=%t.%%r@%%h:%%p -o ControlMaster=auto"))) (when result (with-temp-buffer (call-process "ssh" nil t nil "-o" "ControlPersist") (goto-char (point-min)) (when (search-forward-regexp "Missing ControlPersist argument" nil t) - (setq result (append result '("-o" "ControlPersist=no"))))))) + (setq result (concat result " -o ControlPersist=no")))))) result) "Call ssh to detect whether it supports the Control* arguments. -Return a template to be used in `tramp-methods'.") +Return a string to be used in `tramp-methods'.") (defcustom tramp-default-method ;; An external copy method seems to be preferred, because it performs @@ -333,7 +332,7 @@ Return a template to be used in `tramp-methods'.") (getenv "SSH_AUTH_SOCK") (getenv "SSH_AGENT_PID") ;; We could reuse the connection. - tramp-ssh-controlmaster-template) + (> (length tramp-ssh-controlmaster-options) 0)) "scp" "ssh")) ;; Fallback. -- 2.39.2