# HG changeset patch # User Michael Albinus # Date 1271935299 -7200 # Node ID 186cf99d41224e4cae6c1b5e703bfbd1f4d5f511 # Parent 589643be353e77bcf06082bfdc9467564a24146f Detect ssh 'ControlMaster' argument automatically in some cases. * net/tramp.el (tramp-detect-ssh-controlmaster): New defun. (tramp-default-method): Use it. diff -r 589643be353e -r 186cf99d4122 lisp/ChangeLog --- a/lisp/ChangeLog Thu Apr 22 11:15:27 2010 +0200 +++ b/lisp/ChangeLog Thu Apr 22 13:21:39 2010 +0200 @@ -1,9 +1,18 @@ +2010-04-22 Noah Lavine (tiny change) + + Detect ssh 'ControlMaster' argument automatically in some cases. + + * net/tramp.el (tramp-detect-ssh-controlmaster): New defun. + (tramp-default-method): Use it. + 2010-04-22 Michael Albinus * net/tramp.el (tramp-handle-copy-file): Add new optional parameter `preserve-selinux-context'. (tramp-file-name-for-operation): Add `set-file-selinux-context'. +2010-04-22 Michael Albinus + * net/tramp.el (tramp-completion-handle-file-name-all-completions): Ensure, that non remote files are still checked. Oops. diff -r 589643be353e -r 186cf99d4122 lisp/net/tramp.el --- a/lisp/net/tramp.el Thu Apr 22 11:15:27 2010 +0200 +++ b/lisp/net/tramp.el Thu Apr 22 13:21:39 2010 +0200 @@ -723,6 +723,16 @@ `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)))) + (defcustom tramp-default-method ;; An external copy method seems to be preferred, because it is much ;; more performant for large files, and it hasn't too serious delays @@ -730,9 +740,8 @@ ;; 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" would be another good choice because of - ;; the "ControlMaster" option, but this is a more modern alternative - ;; in OpenSSH 4, which cannot be taken as default. + ;; password caching. "scpc" is chosen if we detect that the user is + ;; running OpenSSH 4.0 or newer. (cond ;; PuTTY is installed. ((executable-find "pscp") @@ -744,13 +753,15 @@ "plink")) ;; There is an ssh installation. ((executable-find "scp") - (if (or (fboundp 'password-read) - (fboundp 'auth-source-user-or-password) - ;; ssh-agent is running. - (getenv "SSH_AUTH_SOCK") - (getenv "SSH_AGENT_PID")) - "scp" - "ssh")) + (cond + ((tramp-detect-ssh-controlmaster) "scpc") + ((or (fboundp 'password-read) + (fboundp 'auth-source-user-or-password) + ;; ssh-agent is running. + (getenv "SSH_AUTH_SOCK") + (getenv "SSH_AGENT_PID")) + "scp") + (t "ssh"))) ;; Fallback. (t "ftp")) "*Default method to use for transferring files.