changeset 108065:186cf99d4122

Detect ssh 'ControlMaster' argument automatically in some cases. * net/tramp.el (tramp-detect-ssh-controlmaster): New defun. (tramp-default-method): Use it.
author Michael Albinus <michael.albinus@gmx.de>
date Thu, 22 Apr 2010 13:21:39 +0200
parents 589643be353e
children 47a124b50bbf
files lisp/ChangeLog lisp/net/tramp.el
diffstat 2 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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  <noah549@gmail.com>  (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  <michael.albinus@gmx.de>
 
 	* 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  <michael.albinus@gmx.de>
+
 	* net/tramp.el (tramp-completion-handle-file-name-all-completions):
 	Ensure, that non remote files are still checked.  Oops.
 
--- 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.