unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Noah Lavine <noah549@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: tramp-devel@gnu.org, emacs-devel@gnu.org
Subject: Re: SCPC Detection Program
Date: Thu, 15 Apr 2010 19:53:32 -0400	[thread overview]
Message-ID: <k2y16d22e431004151653xa5442191nd141346a61901cfe@mail.gmail.com> (raw)
In-Reply-To: <87y6gptmrf.fsf@gmx.de>

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
copyright-clerk@fsf.org 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
argument.")))))

 (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
<michael.albinus@gmx.de> wrote:
> Noah Lavine <noah549@gmail.com> 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
>> bug-gnu-emacs@gnu.org?
>
> 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	other threads:[~2010-04-15 23:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <x2m16d22e431003311930ob1f64d28t6ea61f44b5131f8e@mail.gmail.com>
2010-04-11 16:19 ` SCPC Detection Program Michael Albinus
2010-04-12 19:06   ` Noah Lavine
2010-04-12 19:18     ` Michael Albinus
2010-04-12 19:36       ` Noah Lavine
2010-04-12 19:55         ` Michael Albinus
2010-04-13 19:56           ` Noah Lavine
2010-04-13 21:01             ` Michael Albinus
2010-04-14 23:57               ` Noah Lavine
2010-04-15  3:31                 ` Michael Albinus
2010-04-15 23:53                   ` Noah Lavine [this message]
2010-04-22 11:24                     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=k2y16d22e431004151653xa5442191nd141346a61901cfe@mail.gmail.com \
    --to=noah549@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=tramp-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).