Use ControlMaster where applicable. (Bug#13677)
* net/tramp.el (tramp-ssh-controlmaster-template): New defvar, replacing `tramp-detect-ssh-controlmaster'. (tramp-default-method): Use it. * net/tramp-sh.el (tramp-methods) [scp, scp1, scp2, scpx, sftp]: [rsync, ssh, ssh1, ssh2, sshx]: Add ControlPath and ControlMaster arguments. [scpc, rsyncc]: Remove methods. (top): Remove completion functions for "scpc", "rsyncc", "ssh1_old" and "ssh2_old". (tramp-do-copy-or-rename-file-out-of-band): Change trace level. (tramp-maybe-open-connection): Reuse tmpfile for ControlPath.
This commit is contained in:
parent
1ead7dbd66
commit
d729103280
3 changed files with 128 additions and 131 deletions
|
@ -1,3 +1,20 @@
|
|||
2013-02-13 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Use ControlMaster where applicable. (Bug#13677)
|
||||
|
||||
* net/tramp.el (tramp-ssh-controlmaster-template): New defvar,
|
||||
replacing `tramp-detect-ssh-controlmaster'.
|
||||
(tramp-default-method): Use it.
|
||||
|
||||
* net/tramp-sh.el (tramp-methods) [scp, scp1, scp2, scpx, sftp]:
|
||||
[rsync, ssh, ssh1, ssh2, sshx]: Add ControlPath and ControlMaster
|
||||
arguments.
|
||||
[scpc, rsyncc]: Remove methods.
|
||||
(top): Remove completion functions for "scpc", "rsyncc", "ssh1_old"
|
||||
and "ssh2_old".
|
||||
(tramp-do-copy-or-rename-file-out-of-band): Change trace level.
|
||||
(tramp-maybe-open-connection): Reuse tmpfile for ControlPath.
|
||||
|
||||
2013-02-13 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* emacs-lisp/package.el (package--initialized): Move before first use.
|
||||
|
|
|
@ -109,69 +109,17 @@ detected as prompt when being sent on echoing hosts, therefore.")
|
|||
(tramp-copy-keep-date t)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("scp"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p") ("-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-copy-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
("-o" "UserKnownHostsFile=/dev/null")
|
||||
("-o" "StrictHostKeyChecking=no")))
|
||||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("scp1"
|
||||
`("scp"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
("-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-copy-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
("-o" "UserKnownHostsFile=/dev/null")
|
||||
("-o" "StrictHostKeyChecking=no")))
|
||||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("scp2"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
("-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-copy-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
("-o" "UserKnownHostsFile=/dev/null")
|
||||
("-o" "StrictHostKeyChecking=no")))
|
||||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("scpc"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
("-o" "ControlPath=%t.%%r@%%h:%%p")
|
||||
("-o" "ControlMaster=yes")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-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")
|
||||
("-o" "ControlPath=%t.%%r@%%h:%%p")
|
||||
("-o" "ControlMaster=auto")))
|
||||
,tramp-ssh-controlmaster-template))
|
||||
(tramp-copy-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
|
@ -180,16 +128,17 @@ detected as prompt when being sent on echoing hosts, therefore.")
|
|||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("scpx"
|
||||
`("scp1"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
("-e" "none") ("-t" "-t")
|
||||
("%h") ("/bin/sh")))
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-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 (("-P" "%p") ("-p" "%k") ("-q") ("-r")))
|
||||
(tramp-copy-args (("-1") ("-P" "%p") ("-p" "%k") ("-q") ("-r")
|
||||
,tramp-ssh-controlmaster-template))
|
||||
(tramp-copy-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
|
@ -198,33 +147,60 @@ detected as prompt when being sent on echoing hosts, therefore.")
|
|||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("sftp"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p") ("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
(tramp-remote-shell-args ("-c"))
|
||||
(tramp-copy-program "sftp")))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
'("rsync"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p") ("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
(tramp-remote-shell-args ("-c"))
|
||||
(tramp-copy-program "rsync")
|
||||
(tramp-copy-args (("-e" "ssh") ("-t" "%k") ("-r")))
|
||||
(tramp-copy-keep-date t)
|
||||
(tramp-copy-keep-tmpfile t)
|
||||
(tramp-copy-recursive t)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
`("rsyncc"
|
||||
`("scp2"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
("-o" "ControlPath=%t.%%r@%%h:%%p")
|
||||
("-o" "ControlMaster=yes")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-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-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
("-o" "UserKnownHostsFile=/dev/null")
|
||||
("-o" "StrictHostKeyChecking=no")))
|
||||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
`("scpx"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-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-keep-date t)
|
||||
(tramp-copy-recursive t)
|
||||
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
|
||||
("-o" "UserKnownHostsFile=/dev/null")
|
||||
("-o" "StrictHostKeyChecking=no")))
|
||||
(tramp-default-port 22)))
|
||||
;;;###tramp-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
`("sftp"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-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-autoload
|
||||
(add-to-list 'tramp-methods
|
||||
`("rsync"
|
||||
(tramp-login-program "ssh")
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
|
@ -232,10 +208,11 @@ detected as prompt when being sent on echoing hosts, therefore.")
|
|||
(tramp-copy-program "rsync")
|
||||
(tramp-copy-args (("-t" "%k") ("-r")))
|
||||
(tramp-copy-env (("RSYNC_RSH")
|
||||
(,(concat
|
||||
"ssh"
|
||||
" -o ControlPath=%t.%%r@%%h:%%p"
|
||||
" -o ControlMaster=auto"))))
|
||||
(,(mapconcat
|
||||
'identity
|
||||
(append
|
||||
'("ssh") tramp-ssh-controlmaster-template)
|
||||
" "))))
|
||||
(tramp-copy-keep-date t)
|
||||
(tramp-copy-keep-tmpfile t)
|
||||
(tramp-copy-recursive t)))
|
||||
|
@ -255,9 +232,11 @@ 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") ("-e" "none") ("%h")))
|
||||
(tramp-login-args (("-l" "%u") ("-p" "%p")
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
(tramp-remote-shell-args ("-c"))
|
||||
|
@ -267,9 +246,10 @@ 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
|
||||
("-1") ("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
|
@ -280,9 +260,10 @@ 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
|
||||
("-2") ("-e" "none") ("%h")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
|
@ -293,11 +274,11 @@ 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")
|
||||
("-e" "none") ("-t" "-t")
|
||||
("%h") ("/bin/sh")))
|
||||
,tramp-ssh-controlmaster-template
|
||||
("-e" "none") ("-t" "-t") ("%h") ("/bin/sh")))
|
||||
(tramp-async-args (("-q")))
|
||||
(tramp-remote-shell "/bin/sh")
|
||||
(tramp-remote-shell-args ("-c"))
|
||||
|
@ -473,21 +454,14 @@ detected as prompt when being sent on echoing hosts, therefore.")
|
|||
(tramp-set-completion-function "scp" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "scp1" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "scp2" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "scpc" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "scpx" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "sftp" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "rsync" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function
|
||||
"rsyncc" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "rsh" tramp-completion-function-alist-rsh)
|
||||
(tramp-set-completion-function "remsh" tramp-completion-function-alist-rsh)
|
||||
(tramp-set-completion-function "ssh" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "ssh1" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "ssh2" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function
|
||||
"ssh1_old" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function
|
||||
"ssh2_old" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function "sshx" tramp-completion-function-alist-ssh)
|
||||
(tramp-set-completion-function
|
||||
"telnet" tramp-completion-function-alist-telnet)
|
||||
|
@ -2419,7 +2393,7 @@ The method used must be an out-of-band method."
|
|||
v "process-buffer" (current-buffer))
|
||||
(while copy-env
|
||||
(tramp-message
|
||||
orig-vec 5 "%s=\"%s\"" (car copy-env) (cadr copy-env))
|
||||
orig-vec 6 "%s=\"%s\"" (car copy-env) (cadr copy-env))
|
||||
(setenv (pop copy-env) (pop copy-env)))
|
||||
|
||||
;; Use an asynchronous process. By this, password can
|
||||
|
@ -4478,14 +4452,16 @@ connection if a previous connection has died for some reason."
|
|||
;; temporary file has another name, and it is
|
||||
;; created and protected by ssh. It is also
|
||||
;; removed by ssh when the connection is
|
||||
;; closed.
|
||||
;; closed. The temporary file name is cached
|
||||
;; in the main connection process, therefore
|
||||
;; we cannot use `tramp-get-connection-process'.
|
||||
(tmpfile
|
||||
(tramp-set-connection-property
|
||||
p "temp-file"
|
||||
(make-temp-name
|
||||
(expand-file-name
|
||||
tramp-temp-name-prefix
|
||||
(tramp-compat-temporary-file-directory)))))
|
||||
(with-tramp-connection-property
|
||||
(get-process (tramp-buffer-name vec)) "temp-file"
|
||||
(make-temp-name
|
||||
(expand-file-name
|
||||
tramp-temp-name-prefix
|
||||
(tramp-compat-temporary-file-directory)))))
|
||||
spec r-shell)
|
||||
|
||||
;; Add arguments for asynchronous processes.
|
||||
|
|
|
@ -280,15 +280,18 @@ started on the local host. You should specify a remote host
|
|||
`localhost' or the name of the local host. Another host name is
|
||||
useful only in combination with `tramp-default-proxies-alist'.")
|
||||
|
||||
(defun tramp-detect-ssh-controlmaster ()
|
||||
"Call ssh to detect whether it supports the ControlMaster argument.
|
||||
This function may return nil when the argument is supported, but
|
||||
shouldn't return t when it isn't."
|
||||
(ignore-errors
|
||||
(with-temp-buffer
|
||||
(call-process "ssh" nil t nil "-o" "ControlMaster")
|
||||
(goto-char (point-min))
|
||||
(search-forward-regexp "Missing ControlMaster argument" nil t))))
|
||||
;;;###tramp-autoload
|
||||
(defvar tramp-ssh-controlmaster-template
|
||||
(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)
|
||||
'("-o" "ControlPath=%t.%%r@%%h:%%p"
|
||||
"-o" "ControlMaster=auto"
|
||||
"-o" "ControlPersist=no"))))
|
||||
"Call ssh to detect whether it supports the ControlMaster argument.
|
||||
Return a template to be used in `tramp-methods'.")
|
||||
|
||||
(defcustom tramp-default-method
|
||||
;; An external copy method seems to be preferred, because it performs
|
||||
|
@ -297,8 +300,9 @@ shouldn't return t when it isn't."
|
|||
;; permanent password queries. Either a password agent like
|
||||
;; "ssh-agent" or "Pageant" shall run, or the optional
|
||||
;; password-cache.el or auth-sources.el packages shall be active for
|
||||
;; password caching. "scpc" is chosen if we detect that the user is
|
||||
;; running OpenSSH 4.0 or newer.
|
||||
;; password caching. If we detect that the user is running OpenSSH
|
||||
;; 4.0 or newer, we could reuse the connection, which calls also for
|
||||
;; an external method.
|
||||
(cond
|
||||
;; PuTTY is installed. We don't take it, if it is installed on a
|
||||
;; non-windows system, or pscp from the pssh (parallel ssh) package
|
||||
|
@ -314,16 +318,16 @@ shouldn't return t when it isn't."
|
|||
"plink"))
|
||||
;; There is an ssh installation.
|
||||
((executable-find "scp")
|
||||
(cond
|
||||
((tramp-detect-ssh-controlmaster) "scpc")
|
||||
((or (fboundp 'password-read)
|
||||
(fboundp 'auth-source-user-or-password)
|
||||
(fboundp 'auth-source-search)
|
||||
;; ssh-agent is running.
|
||||
(getenv "SSH_AUTH_SOCK")
|
||||
(getenv "SSH_AGENT_PID"))
|
||||
"scp")
|
||||
(t "ssh")))
|
||||
(if (or (fboundp 'password-read)
|
||||
(fboundp 'auth-source-user-or-password)
|
||||
(fboundp 'auth-source-search)
|
||||
;; ssh-agent is running.
|
||||
(getenv "SSH_AUTH_SOCK")
|
||||
(getenv "SSH_AGENT_PID")
|
||||
;; We could reuse the connection.
|
||||
tramp-ssh-controlmaster-template)
|
||||
"scp"
|
||||
"ssh"))
|
||||
;; Fallback.
|
||||
(t "ftp"))
|
||||
"Default method to use for transferring files.
|
||||
|
|
Loading…
Add table
Reference in a new issue