tramp-devel
[Top][All Lists]
Advanced

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

Re: SCPC Detection Program


From: Noah Lavine
Subject: Re: SCPC Detection Program
Date: Mon, 5 Apr 2010 17:31:33 -0400

Dear Tramp Developers,

Here is a more robust version of the program, in the form of a patch
against tramp/lisp/tramp.el.

If this is not the right place to be posting things like this, please
let me know.

Noah Lavine

Index: tramp.el
===================================================================
RCS file: /sources/tramp/tramp/lisp/tramp.el,v
retrieving revision 2.781
diff -u -r2.781 tramp.el
--- tramp.el    19 Mar 2010 14:12:20 -0000      2.781
+++ tramp.el    5 Apr 2010 21:29:02 -0000
@@ -723,6 +723,19 @@
 `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
@@ -730,29 +743,30 @@
   ;; 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.
-  (cond
-   ;; PuTTY is installed.
-   ((executable-find "pscp")
-    (if        (or (fboundp 'password-read)
+  ;; 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.
            (tramp-compat-process-running-p "Pageant"))
-       "pscp"
-      "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"))
-   ;; Fallback.
-   (t "ftp"))
+       "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'."


On Wed, Mar 31, 2010 at 10:30 PM, Noah Lavine <address@hidden> wrote:
> Dear Tramp Developers,
>
> I recently started using Tramp and learned about the different access
> methods. As I understand it, the `scpc` method is superior to the
> `ssh` method, but can't be set as default because of old versions of
> ssh that don't support the ControlMaster argument.
>
> It seems to me that it would be better if Tramp could automatically
> detect whether the version of ssh on a computer supported the
> ControlMaster argument and use scpc if it were possible. Therefore, I
> started working on a program to detect this based on the SSH version
> string. The following program correctly detects the presence of an SSH
> version greater than 4.0 on my computer:
>
> ;; I'm assuming this is called in the definition of
> tramp-default-method, after we've found an ssh install
> (defun detect-scpc ()
>  (with-temp-buffer
>    (let ((ssh-call (call-process "ssh" nil t nil "-V")))
>      (goto-char (point-min))
>      (and (search-forward "OpenSSH_" nil t)
>           (looking-at "[0-9.]*")
>           (let ((ssl-version (read (match-string 0))))
>             (>= ssl-version 4.0))))))
>
> Unfortunately, I'm not very experienced with emacs programming, and in
> any case I don't have other computers available to test this on.
> Therefore, I'd like to offer this to the tramp developers. I'd be
> happy to do whatever is necessary to get this program ready for
> inclusion into tramp, but I'm not sure what that is. Please tell me
> what changes to make, and I hope this can help make Tramp a bit easier
> to use for future users.
>
> Noah Lavine
>




reply via email to

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