[Top][All Lists]

[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: Thu, 15 Apr 2010 19:53:32 -0400

Hi Michael,

I believe the following patch should do it. It's a bit less than 15
lines, but if that's still a problem, I've already written
address@hidden asking for papers to make it completely legal.

One issue is that the detection is currently fragile in the sense that
it will return nil if the response isn't formatted exactly as it
expects, even if the ssh program supports the ControlMaster argument -
but it seems to me that false positives are the thing to worry about
here, since false negatives are essentially exactly what the current
scheme gives anyway.

As for a ChangeLog entry, how about this?

    lisp/net/tramp.el: Detect ssh 'ControlMaster' argument
automatically in some cases.

Thank you very much
Noah Lavine

--- lisp/net/tramp-old.el       2010-04-08 10:40:26.000000000 -0400
+++ lisp/net/tramp.el   2010-04-15 19:45:21.000000000 -0400
@@ -653,38 +653,47 @@
 `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 with invalid arguments to try 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"
+  (with-temp-buffer
+    (let ((ssh-call (condition-case nil
+                        (call-process "ssh" nil t nil "-o" "ControlMaster")
+                      (error nil))))
+      (and ssh-call
+           (goto-char (point-min))
+           (looking-at "command-line line 0: Missing ControlMaster

 (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
+    ((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.
 See `tramp-methods' for possibilities.
 Also see `tramp-default-method-alist'."

On Wed, Apr 14, 2010 at 11:31 PM, Michael Albinus
<address@hidden> wrote:
> Noah Lavine <address@hidden> writes:
>> Hi Michael,
> Hi Noah,
>> That sounds excellent. I'll try to submit a patch soon to implement
>> that. Is it correct that patches like that should go to
>> address@hidden
> It depends. In this case, it would be sufficient, if you simply post the
> diff + a ChangeLog entry; I would commit it then for you.
> However, the change in tramp.el shall not be longer than ~15 lines, this
> is acceptable if you have not signed the FSF papers. If you intend to
> contribute further on, I recommend you to contact the FSF and sign the
> papers; somebody has told earlier where to find information about.
>> Noah
> Thanks, and best regards, Michael.

reply via email to

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