emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] Tramp Scpc Autodetection


From: Noah Lavine
Subject: [patch] Tramp Scpc Autodetection
Date: Thu, 8 Apr 2010 10:56:50 -0400

I recently noticed that Tramp won't use the "scpc" method of transfer
by default when it detects an ssh installation, even though it's
somewhat superior to the "ssh" method. It can't do this because only
OpenSSH 4.0 and greater have the ability to share SSH connections with
other programs. This patch gives Emacs the ability to check whether
OpenSSH 4.0 or greater is installed, and if so, to use the scpc
mechanism automatically.

I'd like to do whatever is necessary to contribute this patch to
emacs. What is necessary for that?

More generally, I couldn't find any information on the emacs website
or in the manual about how to contribute to Emacs. Is this list the
right place to send things like this?

Thank you
Noah Lavine

--- tramp-old.el        2010-04-08 10:40:26.000000000 -0400
+++ tramp.el    2010-04-08 10:41:03.000000000 -0400
@@ -653,38 +653,49 @@
 `localhost' or the name of the local host.  Another host name is
 useful only in combination with `tramp-default-proxies-alist'.")

-
+(defun detect-scpc ()
+  (with-temp-buffer
+    (let ((ssh-call (condition-case nil
+                        (call-process "ssh" nil t nil "-V")
+                      (error nil))))
+      (and ssh-call
+           (goto-char (point-min))
+           (search-forward "OpenSSH_" nil t)
+           (looking-at "[0-9.]*")
+           (let ((ssl-version (read (match-string 0))))
+             (>= ssl-version 4.0))))))

 (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
   ;; for small files.  But it must be ensured that there aren't
   ;; permanent password queries.  Either a password agent like
-  ;; "ssh-agent" or "Pageant" shall run, or the optional password.el
-  ;; package 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.
-  (cond
-   ;; PuTTY is installed.
-   ((executable-find "pscp")
-    (if        (or (fboundp 'password-read)
+  ;; "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.
+  cond
+  ;; PuTTY is installed.
+  ((executable-find "pscp")
+   (if (or (fboundp 'password-read)
+           (fboundp 'auth-source-user-or-password)
            ;; Pageant is running.
-           (and (fboundp 'w32-window-exists-p)
-                (funcall (symbol-function 'w32-window-exists-p)
-                         "Pageant" "Pageant")))
-       "pscp"
-      "plink"))
-   ;; There is an ssh installation.
-   ((executable-find "scp")
-    (if        (or (fboundp 'password-read)
-           ;; ssh-agent is running.
-           (getenv "SSH_AUTH_SOCK")
-           (getenv "SSH_AGENT_PID"))
-       "scp"
-      "ssh"))
-   ;; Fallback.
-   (t "ftp"))
+           (tramp-compat-process-running-p "Pageant"))
+       "pscp"
+     "plink"))
+  ;; There is an ssh installation.
+  ((executable-find "scp")
+   (cond
+    ((detect-scpc) "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.
 See `tramp-methods' for possibilities.
 Also see `tramp-default-method-alist'."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]