From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.emacs.devel Subject: [patch] Tramp Scpc Autodetection Date: Thu, 8 Apr 2010 10:56:50 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1270743532 16329 80.91.229.12 (8 Apr 2010 16:18:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Apr 2010 16:18:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 08 18:18:43 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NzuRF-0006Bm-FA for ged-emacs-devel@m.gmane.org; Thu, 08 Apr 2010 18:18:41 +0200 Original-Received: from localhost ([127.0.0.1]:59713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzuRE-0004mR-Po for ged-emacs-devel@m.gmane.org; Thu, 08 Apr 2010 12:18:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NztA7-0000ck-Te for emacs-devel@gnu.org; Thu, 08 Apr 2010 10:56:55 -0400 Original-Received: from [140.186.70.92] (port=49564 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NztA6-0000Zw-JG for emacs-devel@gnu.org; Thu, 08 Apr 2010 10:56:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NztA5-0003Mi-8f for emacs-devel@gnu.org; Thu, 08 Apr 2010 10:56:54 -0400 Original-Received: from mail-pw0-f41.google.com ([209.85.160.41]:43134) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NztA5-0003ML-2X for emacs-devel@gnu.org; Thu, 08 Apr 2010 10:56:53 -0400 Original-Received: by pwi2 with SMTP id 2so2471825pwi.0 for ; Thu, 08 Apr 2010 07:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=+ugZeRC4So6PyOJsVcRb0MdltOnOfzj4QVsSUW0oxbE=; b=fs1dQNlWdHrCf0eUL44ZgW/sSbDE2T+diiH4A3AsLs7yjKvctURGAiKJJ18lwZCXMr mk8XnABbxpNIIpy0Casz/fJl/+tHqTc5uKIYdDoCgTviUTVBYYTHfpahrDVmXnK3g5Y6 OyiFW48Sian3ShlTz23XAvH9O/4Q4iWaZonSc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=e2M3ebs8nkJc776lDAKQcpA8RrGNnrom6n4h60sYbI1nWTfLo+2Um31DbZjhezxidr WZVTT75NBqzlvodpTNvnBt0QVu1M8CIk8JKeORxxOycdWatF255+oUkm+wPdDaJmwhPo jjehhOnVhpJltAUfEFzs/rYwdWk3cSFFIu29w= Original-Received: by 10.231.37.2 with HTTP; Thu, 8 Apr 2010 07:56:50 -0700 (PDT) Original-Received: by 10.114.188.31 with SMTP id l31mr506306waf.32.1270738610779; Thu, 08 Apr 2010 07:56:50 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Thu, 08 Apr 2010 12:18:36 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:123348 Archived-At: 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'."