aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2015-03-15 16:07:03 +0100
committerMichael Albinus2015-03-15 16:07:03 +0100
commit28caedba0f5c387d9c8e8fc8de26b5399afeb68b (patch)
tree1d9b17b2839c9be0fd6148e6e4bb43b04d410d32
parent51e7e463e93708a0e40688f91200e9e9869ec662 (diff)
downloademacs-28caedba0f5c387d9c8e8fc8de26b5399afeb68b.tar.gz
emacs-28caedba0f5c387d9c8e8fc8de26b5399afeb68b.zip
In Tramp. check ssh Control* options only when needed
Fixes: debbugs:20015 * net/tramp-adb.el: * net/tramp-gvfs.el: * net/tramp-sh.el: * net/tramp-smb.el: Set tramp-autoload cookie for all defcustoms. * net/tramp-sh.el (tramp-use-ssh-controlmaster-options): New defcustom, moved from tramp.el. (tramp-ssh-controlmaster-options): New defvar, moved from tramp.el but with a nil initial value. (tramp-ssh-controlmaster-options): New defun. (tramp-do-copy-or-rename-file-out-of-band) (tramp-maybe-open-connection): Use it. * net/tramp.el (tramp-ssh-controlmaster-options) (tramp-use-ssh-controlmaster-options): Move them to tramp-sh.el. (tramp-default-method): Do not check for `tramp-ssh-controlmaster-options'.
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/net/tramp-adb.el3
-rw-r--r--lisp/net/tramp-gvfs.el2
-rw-r--r--lisp/net/tramp-sh.el75
-rw-r--r--lisp/net/tramp-smb.el6
-rw-r--r--lisp/net/tramp.el41
6 files changed, 101 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 73ba0353d9d..747a1d6c650 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,23 @@
12015-03-15 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp-adb.el:
4 * net/tramp-gvfs.el:
5 * net/tramp-sh.el:
6 * net/tramp-smb.el: Set tramp-autoload cookie for all defcustoms.
7
8 * net/tramp.el (tramp-ssh-controlmaster-options)
9 (tramp-use-ssh-controlmaster-options): Move them to tramp-sh.el.
10 (tramp-default-method): Do not check for
11 `tramp-ssh-controlmaster-options'.
12
13 * net/tramp-sh.el (tramp-use-ssh-controlmaster-options):
14 New defcustom, moved from tramp.el.
15 (tramp-ssh-controlmaster-options): New defvar, moved from tramp.el
16 but with a nil initial value.
17 (tramp-ssh-controlmaster-options): New defun.
18 (tramp-do-copy-or-rename-file-out-of-band)
19 (tramp-maybe-open-connection): Use it. (Bug#20015)
20
12015-03-15 Tassilo Horn <tsdh@gnu.org> 212015-03-15 Tassilo Horn <tsdh@gnu.org>
2 22
3 * emacs-lisp/lisp-mode.el (lisp--el-macro-regexp): New defconst. 23 * emacs-lisp/lisp-mode.el (lisp--el-macro-regexp): New defconst.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 6696dcf1505..a92ca4df51c 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -38,12 +38,14 @@
38;; Pacify byte-compiler. 38;; Pacify byte-compiler.
39(defvar directory-sep-char) 39(defvar directory-sep-char)
40 40
41;;;###tramp-autoload
41(defcustom tramp-adb-program "adb" 42(defcustom tramp-adb-program "adb"
42 "Name of the Android Debug Bridge program." 43 "Name of the Android Debug Bridge program."
43 :group 'tramp 44 :group 'tramp
44 :version "24.4" 45 :version "24.4"
45 :type 'string) 46 :type 'string)
46 47
48;;;###tramp-autoload
47(defcustom tramp-adb-connect-if-not-connected nil 49(defcustom tramp-adb-connect-if-not-connected nil
48 "Try to run `adb connect' if provided device is not connected currently. 50 "Try to run `adb connect' if provided device is not connected currently.
49It is used for TCP/IP devices." 51It is used for TCP/IP devices."
@@ -55,6 +57,7 @@ It is used for TCP/IP devices."
55(defconst tramp-adb-method "adb" 57(defconst tramp-adb-method "adb"
56 "*When this method name is used, forward all calls to Android Debug Bridge.") 58 "*When this method name is used, forward all calls to Android Debug Bridge.")
57 59
60;;;###tramp-autoload
58(defcustom tramp-adb-prompt 61(defcustom tramp-adb-prompt
59 "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" 62 "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
60 "Regexp used as prompt in almquist shell." 63 "Regexp used as prompt in almquist shell."
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 1ea52eb670d..5988a284c6e 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -127,6 +127,7 @@
127;;;###tramp-autoload 127;;;###tramp-autoload
128(add-to-list 'tramp-default-user-alist '("\\`synce\\'" nil nil)) 128(add-to-list 'tramp-default-user-alist '("\\`synce\\'" nil nil))
129 129
130;;;###tramp-autoload
130(defcustom tramp-gvfs-zeroconf-domain "local" 131(defcustom tramp-gvfs-zeroconf-domain "local"
131 "Zeroconf domain to be used for discovering services, like host names." 132 "Zeroconf domain to be used for discovering services, like host names."
132 :group 'tramp 133 :group 'tramp
@@ -374,6 +375,7 @@ It has been changed in GVFS 1.14.")
374;; </signal> 375;; </signal>
375;; </interface> 376;; </interface>
376 377
378;;;###tramp-autoload
377(defcustom tramp-bluez-discover-devices-timeout 60 379(defcustom tramp-bluez-discover-devices-timeout 60
378 "Defines seconds since last bluetooth device discovery before rescanning. 380 "Defines seconds since last bluetooth device discovery before rescanning.
379A value of 0 would require an immediate discovery during hostname 381A value of 0 would require an immediate discovery during hostname
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 76d2b014917..73ad8c7e4ef 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -40,6 +40,7 @@
40(defvar vc-git-program) 40(defvar vc-git-program)
41(defvar vc-hg-program) 41(defvar vc-hg-program)
42 42
43;;;###tramp-autoload
43(defcustom tramp-inline-compress-start-size 4096 44(defcustom tramp-inline-compress-start-size 4096
44 "The minimum size of compressing where inline transfer. 45 "The minimum size of compressing where inline transfer.
45When inline transfer, compress transferred data of file 46When inline transfer, compress transferred data of file
@@ -48,6 +49,7 @@ If it is nil, no compression at all will be applied."
48 :group 'tramp 49 :group 'tramp
49 :type '(choice (const nil) integer)) 50 :type '(choice (const nil) integer))
50 51
52;;;###tramp-autoload
51(defcustom tramp-copy-size-limit 10240 53(defcustom tramp-copy-size-limit 10240
52 "The maximum file size where inline copying is preferred over an \ 54 "The maximum file size where inline copying is preferred over an \
53out-of-the-band copy. 55out-of-the-band copy.
@@ -105,6 +107,27 @@ detected as prompt when being sent on echoing hosts, therefore.")
105(defconst tramp-end-of-heredoc (md5 tramp-end-of-output) 107(defconst tramp-end-of-heredoc (md5 tramp-end-of-output)
106 "String used to recognize end of heredoc strings.") 108 "String used to recognize end of heredoc strings.")
107 109
110;;;###tramp-autoload
111(defcustom tramp-use-ssh-controlmaster-options t
112 "Whether to use `tramp-ssh-controlmaster-options'."
113 :group 'tramp
114 :version "24.4"
115 :type 'boolean)
116
117(defvar tramp-ssh-controlmaster-options nil
118 "Which ssh Control* arguments to use.
119
120If it is a string, it should have the form
121\"-o ControlMaster=auto -o ControlPath='tramp.%%r@%%h:%%p'
122-o ControlPersist=no\". Percent characters in the ControlPath
123spec must be doubled, because the string is used as format string.
124
125Otherwise, it will be auto-detected by Tramp, if
126`tramp-use-ssh-controlmaster-options' is non-nil. The value
127depends on the installed local ssh version.
128
129The string is used in `tramp-methods'.")
130
108;; Initialize `tramp-methods' with the supported methods. 131;; Initialize `tramp-methods' with the supported methods.
109;;;###tramp-autoload 132;;;###tramp-autoload
110(add-to-list 'tramp-methods 133(add-to-list 'tramp-methods
@@ -489,6 +512,7 @@ not be set here. Instead, it should be set via `tramp-remote-path'."
489 :version "24.4" 512 :version "24.4"
490 :type '(repeat string)) 513 :type '(repeat string))
491 514
515;;;###tramp-autoload
492(defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile")) 516(defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
493 "Alist specifying extra arguments to pass to the remote shell. 517 "Alist specifying extra arguments to pass to the remote shell.
494Entries are (REGEXP . ARGS) where REGEXP is a regular expression 518Entries are (REGEXP . ARGS) where REGEXP is a regular expression
@@ -2354,10 +2378,7 @@ The method used must be an out-of-band method."
2354 spec (format-spec-make 2378 spec (format-spec-make
2355 ?t (tramp-get-connection-property 2379 ?t (tramp-get-connection-property
2356 (tramp-get-connection-process v) "temp-file" "")) 2380 (tramp-get-connection-process v) "temp-file" ""))
2357 options (format-spec 2381 options (format-spec (tramp-ssh-controlmaster-options v) spec)
2358 (if tramp-use-ssh-controlmaster-options
2359 tramp-ssh-controlmaster-options "")
2360 spec)
2361 spec (format-spec-make 2382 spec (format-spec-make
2362 ?h host ?u user ?p port ?r listener ?c options 2383 ?h host ?u user ?p port ?r listener ?c options
2363 ?k (if keep-date " " "")) 2384 ?k (if keep-date " " ""))
@@ -4566,6 +4587,49 @@ Gateway hops are already opened."
4566 ;; Result. 4587 ;; Result.
4567 target-alist)) 4588 target-alist))
4568 4589
4590(defun tramp-ssh-controlmaster-options (vec)
4591 "Return the Control* arguments of the local ssh."
4592 (cond
4593 ;; No options to be computed.
4594 ((or (null tramp-use-ssh-controlmaster-options)
4595 (null (assoc "%c" (tramp-get-method-parameter
4596 (tramp-file-name-method vec) 'tramp-login-args))))
4597 "")
4598
4599 ;; There is already a value to be used.
4600 ((stringp tramp-ssh-controlmaster-options) tramp-ssh-controlmaster-options)
4601
4602 ;; Determine the options.
4603 (t (setq tramp-ssh-controlmaster-options "")
4604 (let ((case-fold-search t))
4605 (ignore-errors
4606 (when (executable-find "ssh")
4607 (with-temp-buffer
4608 (tramp-call-process vec "ssh" nil t nil "-o" "ControlMaster")
4609 (goto-char (point-min))
4610 (when (search-forward-regexp "missing.+argument" nil t)
4611 (setq tramp-ssh-controlmaster-options "-o ControlMaster=auto")))
4612 (unless (zerop (length tramp-ssh-controlmaster-options))
4613 (with-temp-buffer
4614 (tramp-call-process
4615 vec "ssh" nil t nil
4616 "-o" "ControlPath=%C" "host.does.not.exist")
4617 (goto-char (point-min))
4618 (setq tramp-ssh-controlmaster-options
4619 (if (search-forward-regexp "unknown.+key" nil t)
4620 (concat tramp-ssh-controlmaster-options
4621 " -o ControlPath='tramp.%%r@%%h:%%p'")
4622 (concat tramp-ssh-controlmaster-options
4623 " -o ControlPath='tramp.%%C'"))))
4624 (with-temp-buffer
4625 (tramp-call-process vec "ssh" nil t nil "-o" "ControlPersist")
4626 (goto-char (point-min))
4627 (when (search-forward-regexp "missing.+argument" nil t)
4628 (setq tramp-ssh-controlmaster-options
4629 (concat tramp-ssh-controlmaster-options
4630 " -o ControlPersist=no"))))))))
4631 tramp-ssh-controlmaster-options)))
4632
4569(defun tramp-maybe-open-connection (vec) 4633(defun tramp-maybe-open-connection (vec)
4570 "Maybe open a connection VEC. 4634 "Maybe open a connection VEC.
4571Does not do anything if a connection is already open, but re-opens the 4635Does not do anything if a connection is already open, but re-opens the
@@ -4647,8 +4711,7 @@ connection if a previous connection has died for some reason."
4647 (let* ((target-alist (tramp-compute-multi-hops vec)) 4711 (let* ((target-alist (tramp-compute-multi-hops vec))
4648 ;; We will apply `tramp-ssh-controlmaster-options' 4712 ;; We will apply `tramp-ssh-controlmaster-options'
4649 ;; only for the first hop. 4713 ;; only for the first hop.
4650 (options (if tramp-use-ssh-controlmaster-options 4714 (options (tramp-ssh-controlmaster-options vec))
4651 tramp-ssh-controlmaster-options ""))
4652 (process-connection-type tramp-process-connection-type) 4715 (process-connection-type tramp-process-connection-type)
4653 (process-adaptive-read-buffering nil) 4716 (process-adaptive-read-buffering nil)
4654 (coding-system-for-read nil) 4717 (coding-system-for-read nil)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index d5fe17f0939..14360b96fe6 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -70,17 +70,20 @@
70 tramp-smb-method 70 tramp-smb-method
71 '((tramp-parse-netrc "~/.netrc")))) 71 '((tramp-parse-netrc "~/.netrc"))))
72 72
73;;;###tramp-autoload
73(defcustom tramp-smb-program "smbclient" 74(defcustom tramp-smb-program "smbclient"
74 "Name of SMB client to run." 75 "Name of SMB client to run."
75 :group 'tramp 76 :group 'tramp
76 :type 'string) 77 :type 'string)
77 78
79;;;###tramp-autoload
78(defcustom tramp-smb-acl-program "smbcacls" 80(defcustom tramp-smb-acl-program "smbcacls"
79 "Name of SMB acls to run." 81 "Name of SMB acls to run."
80 :group 'tramp 82 :group 'tramp
81 :type 'string 83 :type 'string
82 :version "24.4") 84 :version "24.4")
83 85
86;;;###tramp-autoload
84(defcustom tramp-smb-conf "/dev/null" 87(defcustom tramp-smb-conf "/dev/null"
85 "Path of the smb.conf file. 88 "Path of the smb.conf file.
86If it is nil, no smb.conf will be added to the `tramp-smb-program' 89If it is nil, no smb.conf will be added to the `tramp-smb-program'
@@ -280,6 +283,7 @@ See `tramp-actions-before-shell' for more info.")
280Operations not mentioned here will be handled by the default Emacs primitives.") 283Operations not mentioned here will be handled by the default Emacs primitives.")
281 284
282;; Options for remote processes via winexe. 285;; Options for remote processes via winexe.
286;;;###tramp-autoload
283(defcustom tramp-smb-winexe-program "winexe" 287(defcustom tramp-smb-winexe-program "winexe"
284 "Name of winexe client to run. 288 "Name of winexe client to run.
285If it isn't found in the local $PATH, the absolute path of winexe 289If it isn't found in the local $PATH, the absolute path of winexe
@@ -288,6 +292,7 @@ shall be given. This is needed for remote processes."
288 :type 'string 292 :type 'string
289 :version "24.3") 293 :version "24.3")
290 294
295;;;###tramp-autoload
291(defcustom tramp-smb-winexe-shell-command "powershell.exe" 296(defcustom tramp-smb-winexe-shell-command "powershell.exe"
292 "Shell to be used for processes on remote machines. 297 "Shell to be used for processes on remote machines.
293This must be Powershell V2 compatible." 298This must be Powershell V2 compatible."
@@ -295,6 +300,7 @@ This must be Powershell V2 compatible."
295 :type 'string 300 :type 'string
296 :version "24.3") 301 :version "24.3")
297 302
303;;;###tramp-autoload
298(defcustom tramp-smb-winexe-shell-command-switch "-file -" 304(defcustom tramp-smb-winexe-shell-command-switch "-file -"
299 "Command switch used together with `tramp-smb-winexe-shell-command'. 305 "Command switch used together with `tramp-smb-winexe-shell-command'.
300This can be used to disable echo etc." 306This can be used to disable echo etc."
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 953525f37e4..10bb76983aa 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -307,43 +307,6 @@ started on the local host. You should specify a remote host
307`localhost' or the name of the local host. Another host name is 307`localhost' or the name of the local host. Another host name is
308useful only in combination with `tramp-default-proxies-alist'.") 308useful only in combination with `tramp-default-proxies-alist'.")
309 309
310;;;###tramp-autoload
311(defconst tramp-ssh-controlmaster-options
312 (let ((result "")
313 (case-fold-search t))
314 (ignore-errors
315 (when (executable-find "ssh")
316 (with-temp-buffer
317 (call-process "ssh" nil t nil "-o" "ControlMaster")
318 (goto-char (point-min))
319 (when (search-forward-regexp "missing.+argument" nil t)
320 (setq result "-o ControlMaster=auto")))
321 (unless (zerop (length result))
322 (with-temp-buffer
323 (call-process
324 "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist")
325 (goto-char (point-min))
326 (if (search-forward-regexp "unknown.+key" nil t)
327 (setq result
328 (concat result " -o ControlPath='tramp.%%r@%%h:%%p'"))
329 (setq result (concat result " -o ControlPath='tramp.%%C'"))))
330 (with-temp-buffer
331 (call-process "ssh" nil t nil "-o" "ControlPersist")
332 (goto-char (point-min))
333 (when (search-forward-regexp "missing.+argument" nil t)
334 (setq result (concat result " -o ControlPersist=no")))))))
335 result)
336 "Call ssh to detect whether it supports the Control* arguments.
337Return a string to be used in `tramp-methods'.")
338
339;;;###tramp-autoload
340(defcustom tramp-use-ssh-controlmaster-options
341 (not (zerop (length tramp-ssh-controlmaster-options)))
342 "Whether to use `tramp-ssh-controlmaster-options'."
343 :group 'tramp
344 :version "24.4"
345 :type 'boolean)
346
347(defcustom tramp-default-method 310(defcustom tramp-default-method
348 ;; An external copy method seems to be preferred, because it performs 311 ;; An external copy method seems to be preferred, because it performs
349 ;; much better for large files, and it hasn't too serious delays 312 ;; much better for large files, and it hasn't too serious delays
@@ -374,9 +337,7 @@ Return a string to be used in `tramp-methods'.")
374 (fboundp 'auth-source-search) 337 (fboundp 'auth-source-search)
375 ;; ssh-agent is running. 338 ;; ssh-agent is running.
376 (getenv "SSH_AUTH_SOCK") 339 (getenv "SSH_AUTH_SOCK")
377 (getenv "SSH_AGENT_PID") 340 (getenv "SSH_AGENT_PID"))
378 ;; We could reuse the connection.
379 (> (length tramp-ssh-controlmaster-options) 0))
380 "scp" 341 "scp"
381 "ssh")) 342 "ssh"))
382 ;; Fallback. 343 ;; Fallback.