diff options
| author | Michael Albinus | 2016-12-21 12:42:22 +0100 |
|---|---|---|
| committer | Michael Albinus | 2016-12-21 12:42:22 +0100 |
| commit | 8661313efd5fd5b0a27fe82f276a1ff862646424 (patch) | |
| tree | acdb27c91f2380b3aa13e25c36dc26a8e1cea5a5 /lisp | |
| parent | 221d3a9767422ba783aedcd354fd1fe2d60e9bb3 (diff) | |
| download | emacs-8661313efd5fd5b0a27fe82f276a1ff862646424.tar.gz emacs-8661313efd5fd5b0a27fe82f276a1ff862646424.zip | |
Remove gateway methods in Tramp
* doc/misc/tramp.texi (Top, Configuration): Remove section
`Gateway methods', insert section `Firewalls' in menu.
(History): Gateways are removed now.
(Gateway methods): Remove section.
(Multi-hops, Traces and Profiles): Don't reference to gateways anymore.
(Firewalls): New section.
* etc/NEWS: Gateway methods in Tramp have been removed.
* lisp/net/tramp.el (tramp-methods): Adapt docstring.
(tramp-file-name-port, tramp-accept-process-output): Simplify.
* lisp/net/tramp-gw.el: Remove.
* lisp/net/tramp-sh.el (tramp-gw-tunnel-method)
(tramp-gw-socks-method): Remove declarations.
(tramp-methods) <scp, scpx, ssh, sshx, telnet, nc, plink, pscp>:
Remove `tramp-gw-args' and `tramp-default-port'. (Bug#18967)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-compute-multi-hops, tramp-maybe-open-connection):
Remove gateway support.
* test/lisp/net/tramp-tests.el (tramp-test03-file-name-defaults):
Remove gateway tests.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/net/tramp-gw.el | 339 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 105 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 31 |
3 files changed, 23 insertions, 452 deletions
diff --git a/lisp/net/tramp-gw.el b/lisp/net/tramp-gw.el deleted file mode 100644 index 8f8f107ec10..00000000000 --- a/lisp/net/tramp-gw.el +++ /dev/null | |||
| @@ -1,339 +0,0 @@ | |||
| 1 | ;;; tramp-gw.el --- Tramp utility functions for HTTP tunnels and SOCKS gateways | ||
| 2 | |||
| 3 | ;; Copyright (C) 2007-2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Michael Albinus <michael.albinus@gmx.de> | ||
| 6 | ;; Keywords: comm, processes | ||
| 7 | ;; Package: tramp | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Commentary: | ||
| 25 | |||
| 26 | ;; Access functions for HTTP tunnels and SOCKS gateways from Tramp. | ||
| 27 | ;; SOCKS functionality is implemented by socks.el from the w3 package. | ||
| 28 | ;; HTTP tunnels are partly implemented in socks.el and url-http.el; | ||
| 29 | ;; both implementations are not complete. Therefore, it is | ||
| 30 | ;; implemented in this package. | ||
| 31 | |||
| 32 | ;;; Code: | ||
| 33 | |||
| 34 | (require 'tramp) | ||
| 35 | |||
| 36 | ;; Pacify byte-compiler. | ||
| 37 | (eval-when-compile | ||
| 38 | (require 'cl) | ||
| 39 | (require 'custom)) | ||
| 40 | (defvar socks-noproxy) | ||
| 41 | |||
| 42 | ;; We don't add the following methods to `tramp-methods', in order to | ||
| 43 | ;; exclude them from file name completion. | ||
| 44 | |||
| 45 | ;; Define HTTP tunnel method ... | ||
| 46 | ;;;###tramp-autoload | ||
| 47 | (defconst tramp-gw-tunnel-method "tunnel" | ||
| 48 | "Method to connect HTTP gateways.") | ||
| 49 | |||
| 50 | ;; ... and port. | ||
| 51 | (defconst tramp-gw-default-tunnel-port 8080 | ||
| 52 | "Default port for HTTP gateways.") | ||
| 53 | |||
| 54 | ;; Define SOCKS method ... | ||
| 55 | ;;;###tramp-autoload | ||
| 56 | (defconst tramp-gw-socks-method "socks" | ||
| 57 | "Method to connect SOCKS servers.") | ||
| 58 | |||
| 59 | ;; ... and port. | ||
| 60 | (defconst tramp-gw-default-socks-port 1080 | ||
| 61 | "Default port for SOCKS servers.") | ||
| 62 | |||
| 63 | ;; Autoload the socks library. It is used only when we access a SOCKS server. | ||
| 64 | (autoload 'socks-open-network-stream "socks") | ||
| 65 | (defvar socks-username (user-login-name)) | ||
| 66 | (defvar socks-server | ||
| 67 | (list "Default server" "socks" tramp-gw-default-socks-port 5)) | ||
| 68 | |||
| 69 | ;; Add a default for `tramp-default-user-alist'. Default is the local user. | ||
| 70 | ;;;###tramp-autoload | ||
| 71 | (add-to-list | ||
| 72 | 'tramp-default-user-alist | ||
| 73 | (list (concat "\\`" | ||
| 74 | (regexp-opt (list tramp-gw-tunnel-method tramp-gw-socks-method)) | ||
| 75 | "\\'") | ||
| 76 | nil (user-login-name))) | ||
| 77 | |||
| 78 | ;; Internal file name functions and variables. | ||
| 79 | |||
| 80 | (defvar tramp-gw-vector nil | ||
| 81 | "Keeps the remote host identification. Needed for Tramp messages.") | ||
| 82 | |||
| 83 | (defvar tramp-gw-gw-vector nil | ||
| 84 | "Current gateway identification vector.") | ||
| 85 | |||
| 86 | (defvar tramp-gw-gw-proc nil | ||
| 87 | "Current gateway process.") | ||
| 88 | |||
| 89 | ;; This variable keeps the listening process, in order to reuse it for | ||
| 90 | ;; new processes. | ||
| 91 | (defvar tramp-gw-aux-proc nil | ||
| 92 | "Process listening on local port, as mediation between SSH and the gateway.") | ||
| 93 | |||
| 94 | (defun tramp-gw-gw-proc-sentinel (proc _event) | ||
| 95 | "Delete auxiliary process when we are deleted." | ||
| 96 | (unless (tramp-compat-process-live-p proc) | ||
| 97 | (tramp-message | ||
| 98 | tramp-gw-vector 4 "Deleting auxiliary process `%s'" tramp-gw-gw-proc) | ||
| 99 | (let* ((tramp-verbose 0) | ||
| 100 | (p (tramp-get-connection-property proc "process" nil))) | ||
| 101 | (when (processp p) (delete-process p))))) | ||
| 102 | |||
| 103 | (defun tramp-gw-aux-proc-sentinel (proc _event) | ||
| 104 | "Activate the different filters for involved gateway and auxiliary processes." | ||
| 105 | (when (tramp-compat-process-live-p proc) | ||
| 106 | ;; A new process has been spawned from `tramp-gw-aux-proc'. | ||
| 107 | (tramp-message | ||
| 108 | tramp-gw-vector 4 | ||
| 109 | "Opening auxiliary process `%s', speaking with process `%s'" | ||
| 110 | proc tramp-gw-gw-proc) | ||
| 111 | (set-process-query-on-exit-flag proc nil) | ||
| 112 | ;; We don't want debug messages, because the corresponding debug | ||
| 113 | ;; buffer might be undecided. | ||
| 114 | (let ((tramp-verbose 0)) | ||
| 115 | (tramp-set-connection-property tramp-gw-gw-proc "process" proc) | ||
| 116 | (tramp-set-connection-property proc "process" tramp-gw-gw-proc)) | ||
| 117 | ;; Set the process-filter functions for both processes. | ||
| 118 | (set-process-filter proc 'tramp-gw-process-filter) | ||
| 119 | (set-process-filter tramp-gw-gw-proc 'tramp-gw-process-filter) | ||
| 120 | ;; There might be already some output from the gateway process. | ||
| 121 | (with-current-buffer (process-buffer tramp-gw-gw-proc) | ||
| 122 | (unless (= (point-min) (point-max)) | ||
| 123 | (let ((s (buffer-string))) | ||
| 124 | (delete-region (point) (point-max)) | ||
| 125 | (tramp-gw-process-filter tramp-gw-gw-proc s)))))) | ||
| 126 | |||
| 127 | (defun tramp-gw-process-filter (proc string) | ||
| 128 | "Resend the string to the other process." | ||
| 129 | (let ((tramp-verbose 0)) | ||
| 130 | ;; The other process might have been stopped already. We don't | ||
| 131 | ;; want to be interrupted then. | ||
| 132 | (ignore-errors | ||
| 133 | (process-send-string | ||
| 134 | (tramp-get-connection-property proc "process" nil) string)))) | ||
| 135 | |||
| 136 | ;;;###tramp-autoload | ||
| 137 | (defun tramp-gw-open-connection (vec gw-vec target-vec) | ||
| 138 | "Open a remote connection to VEC (see `tramp-file-name' structure). | ||
| 139 | Take GW-VEC as SOCKS or HTTP gateway, i.e. its method must be a | ||
| 140 | gateway method. TARGET-VEC identifies where to connect to via | ||
| 141 | the gateway, it can be different from VEC when there are more | ||
| 142 | hops to be applied. | ||
| 143 | |||
| 144 | It returns a string like \"localhost#port\", which must be used | ||
| 145 | instead of the host name declared in TARGET-VEC." | ||
| 146 | |||
| 147 | ;; Remember vectors for property retrieval. | ||
| 148 | (setq tramp-gw-vector vec | ||
| 149 | tramp-gw-gw-vector gw-vec) | ||
| 150 | |||
| 151 | ;; Start listening auxiliary process. | ||
| 152 | (unless (tramp-compat-process-live-p tramp-gw-aux-proc) | ||
| 153 | (let ((aux-vec | ||
| 154 | (vector "aux" (tramp-file-name-user gw-vec) | ||
| 155 | (tramp-file-name-host gw-vec) nil nil))) | ||
| 156 | (setq tramp-gw-aux-proc | ||
| 157 | (make-network-process | ||
| 158 | :name (tramp-buffer-name aux-vec) :buffer nil :host 'local | ||
| 159 | :server t :noquery t :service t :coding 'binary)) | ||
| 160 | (set-process-sentinel tramp-gw-aux-proc 'tramp-gw-aux-proc-sentinel) | ||
| 161 | (set-process-query-on-exit-flag tramp-gw-aux-proc nil) | ||
| 162 | (tramp-message | ||
| 163 | vec 4 "Opening auxiliary process `%s', listening on port %d" | ||
| 164 | tramp-gw-aux-proc (process-contact tramp-gw-aux-proc :service)))) | ||
| 165 | |||
| 166 | (let* ((gw-method | ||
| 167 | (intern | ||
| 168 | (tramp-find-method | ||
| 169 | (tramp-file-name-method gw-vec) | ||
| 170 | (tramp-file-name-user gw-vec) | ||
| 171 | (tramp-file-name-host gw-vec)))) | ||
| 172 | (socks-username | ||
| 173 | (tramp-find-user | ||
| 174 | (tramp-file-name-method gw-vec) | ||
| 175 | (tramp-file-name-user gw-vec) | ||
| 176 | (tramp-file-name-host gw-vec))) | ||
| 177 | ;; Declare the SOCKS server to be used. | ||
| 178 | (socks-server | ||
| 179 | (list "Tramp temporary socks server list" | ||
| 180 | ;; Host name. | ||
| 181 | (tramp-file-name-real-host gw-vec) | ||
| 182 | ;; Port number. | ||
| 183 | (or (tramp-file-name-port gw-vec) | ||
| 184 | (case gw-method | ||
| 185 | (tunnel tramp-gw-default-tunnel-port) | ||
| 186 | (socks tramp-gw-default-socks-port))) | ||
| 187 | ;; Type. We support only http and socks5, NO socks4. | ||
| 188 | ;; 'http could be used when HTTP tunnel works in socks.el. | ||
| 189 | 5)) | ||
| 190 | ;; The function to be called. | ||
| 191 | (socks-function | ||
| 192 | (case gw-method | ||
| 193 | (tunnel 'tramp-gw-open-network-stream) | ||
| 194 | (socks 'socks-open-network-stream))) | ||
| 195 | socks-noproxy) | ||
| 196 | |||
| 197 | ;; Open SOCKS process. | ||
| 198 | (setq tramp-gw-gw-proc | ||
| 199 | (funcall | ||
| 200 | socks-function | ||
| 201 | (let ((tramp-verbose 0)) (tramp-get-connection-name gw-vec)) | ||
| 202 | (let ((tramp-verbose 0)) (tramp-get-connection-buffer gw-vec)) | ||
| 203 | (tramp-file-name-real-host target-vec) | ||
| 204 | (tramp-file-name-port target-vec))) | ||
| 205 | (set-process-sentinel tramp-gw-gw-proc 'tramp-gw-gw-proc-sentinel) | ||
| 206 | (set-process-coding-system tramp-gw-gw-proc 'binary 'binary) | ||
| 207 | (set-process-query-on-exit-flag tramp-gw-gw-proc nil) | ||
| 208 | (tramp-message | ||
| 209 | vec 4 "Opened %s process `%s'" | ||
| 210 | (case gw-method ('tunnel "HTTP tunnel") ('socks "SOCKS")) | ||
| 211 | tramp-gw-gw-proc) | ||
| 212 | |||
| 213 | ;; Return the new host for gateway access. | ||
| 214 | (format "localhost#%d" (process-contact tramp-gw-aux-proc :service)))) | ||
| 215 | |||
| 216 | (defun tramp-gw-open-network-stream (name buffer host service) | ||
| 217 | "Open stream to proxy server HOST:SERVICE. | ||
| 218 | Resulting process has name NAME and buffer BUFFER. If | ||
| 219 | authentication is requested from proxy server, provide it." | ||
| 220 | (let ((command (format (concat | ||
| 221 | "CONNECT %s:%d HTTP/1.1\r\n" | ||
| 222 | "Host: %s:%d\r\n" | ||
| 223 | "Connection: keep-alive\r\n" | ||
| 224 | "User-Agent: Tramp/%s\r\n") | ||
| 225 | host service host service tramp-version)) | ||
| 226 | (authentication "") | ||
| 227 | (first t) | ||
| 228 | found proc) | ||
| 229 | |||
| 230 | (while (not found) | ||
| 231 | ;; Clean up. | ||
| 232 | (when (processp proc) (delete-process proc)) | ||
| 233 | (with-current-buffer buffer (erase-buffer)) | ||
| 234 | ;; Open network stream. | ||
| 235 | (setq proc (open-network-stream | ||
| 236 | name buffer (nth 1 socks-server) (nth 2 socks-server))) | ||
| 237 | (set-process-coding-system proc 'binary 'binary) | ||
| 238 | (set-process-query-on-exit-flag proc nil) | ||
| 239 | ;; Send CONNECT command. | ||
| 240 | (process-send-string proc (format "%s%s\r\n" command authentication)) | ||
| 241 | (tramp-message | ||
| 242 | tramp-gw-vector 6 "\n%s" | ||
| 243 | (format | ||
| 244 | "%s%s\r\n" command | ||
| 245 | (replace-regexp-in-string ;; no password in trace! | ||
| 246 | "Basic [^\r\n]+" "Basic xxxxx" authentication t))) | ||
| 247 | (with-current-buffer buffer | ||
| 248 | ;; Trap errors to be traced in the right trace buffer. Often, | ||
| 249 | ;; proxies have a timeout of 60". We wait 65" in order to | ||
| 250 | ;; receive an answer this case. | ||
| 251 | (ignore-errors | ||
| 252 | (let ((tramp-verbose 0)) | ||
| 253 | (tramp-wait-for-regexp proc 65 "\r?\n\r?\n"))) | ||
| 254 | ;; Check return code. | ||
| 255 | (goto-char (point-min)) | ||
| 256 | (narrow-to-region | ||
| 257 | (point-min) | ||
| 258 | (or (search-forward-regexp "\r?\n\r?\n" nil t) (point-max))) | ||
| 259 | (tramp-message tramp-gw-vector 6 "\n%s" (buffer-string)) | ||
| 260 | (goto-char (point-min)) | ||
| 261 | (search-forward-regexp "^HTTP/[1-9]\\.[0-9]" nil t) | ||
| 262 | (case (condition-case nil (read (current-buffer)) (error)) | ||
| 263 | ;; Connected. | ||
| 264 | (200 (setq found t)) | ||
| 265 | ;; We need basic authentication. | ||
| 266 | (401 (setq authentication (tramp-gw-basic-authentication nil first))) | ||
| 267 | ;; Access forbidden. | ||
| 268 | (403 (tramp-error-with-buffer | ||
| 269 | (current-buffer) tramp-gw-vector 'file-error | ||
| 270 | "Connection to %s:%d forbidden." host service)) | ||
| 271 | ;; Target host not found. | ||
| 272 | (404 (tramp-error-with-buffer | ||
| 273 | (current-buffer) tramp-gw-vector 'file-error | ||
| 274 | "Host %s not found." host)) | ||
| 275 | ;; We need basic proxy authentication. | ||
| 276 | (407 (setq authentication (tramp-gw-basic-authentication t first))) | ||
| 277 | ;; Connection failed. | ||
| 278 | (503 (tramp-error-with-buffer | ||
| 279 | (current-buffer) tramp-gw-vector 'file-error | ||
| 280 | "Connection to %s:%d failed." host service)) | ||
| 281 | ;; That doesn't work at all. | ||
| 282 | (t (tramp-error-with-buffer | ||
| 283 | (current-buffer) tramp-gw-vector 'file-error | ||
| 284 | "Access to HTTP server %s:%d failed." | ||
| 285 | (nth 1 socks-server) (nth 2 socks-server)))) | ||
| 286 | ;; Remove HTTP headers. | ||
| 287 | (delete-region (point-min) (point-max)) | ||
| 288 | (widen) | ||
| 289 | (setq first nil))) | ||
| 290 | ;; Return the process. | ||
| 291 | proc)) | ||
| 292 | |||
| 293 | (defun tramp-gw-basic-authentication (proxy pw-cache) | ||
| 294 | "Return authentication header for CONNECT, based on server request. | ||
| 295 | PROXY is an indication whether we need a Proxy-Authorization header | ||
| 296 | or an Authorization header. If PW-CACHE is non-nil, check for | ||
| 297 | password in password cache. This is done for the first try only." | ||
| 298 | |||
| 299 | ;; `tramp-current-*' must be set for `tramp-read-passwd'. | ||
| 300 | (let ((tramp-current-method (tramp-file-name-method tramp-gw-gw-vector)) | ||
| 301 | (tramp-current-user (tramp-file-name-user tramp-gw-gw-vector)) | ||
| 302 | (tramp-current-host (tramp-file-name-host tramp-gw-gw-vector))) | ||
| 303 | (unless pw-cache (tramp-clear-passwd tramp-gw-gw-vector)) | ||
| 304 | ;; We are already in the right buffer. | ||
| 305 | (tramp-message | ||
| 306 | tramp-gw-vector 5 "%s required" | ||
| 307 | (if proxy "Proxy authentication" "Authentication")) | ||
| 308 | ;; Search for request header. We accept only basic authentication. | ||
| 309 | (goto-char (point-min)) | ||
| 310 | (search-forward-regexp | ||
| 311 | "^\\(Proxy\\|WWW\\)-Authenticate:\\s-*Basic\\s-+realm=") | ||
| 312 | ;; Return authentication string. | ||
| 313 | (format | ||
| 314 | "%s: Basic %s\r\n" | ||
| 315 | (if proxy "Proxy-Authorization" "Authorization") | ||
| 316 | (base64-encode-string | ||
| 317 | (format | ||
| 318 | "%s:%s" | ||
| 319 | socks-username | ||
| 320 | (tramp-read-passwd | ||
| 321 | nil | ||
| 322 | (format | ||
| 323 | "Password for %s@[%s]: " socks-username (read (current-buffer))))))))) | ||
| 324 | |||
| 325 | (add-hook 'tramp-unload-hook | ||
| 326 | (lambda () | ||
| 327 | (unload-feature 'tramp-gw 'force))) | ||
| 328 | |||
| 329 | (provide 'tramp-gw) | ||
| 330 | |||
| 331 | ;;; TODO: | ||
| 332 | |||
| 333 | ;; * Provide descriptive Commentary. | ||
| 334 | ;; | ||
| 335 | ;; * Enable it for several gateway processes in parallel. | ||
| 336 | ;; | ||
| 337 | ;; * Use `url-https-proxy-connect' as of Emacs 26. | ||
| 338 | |||
| 339 | ;;; tramp-gw.el ends here | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index fbf44b77a12..57cb6e11d21 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -32,8 +32,6 @@ | |||
| 32 | (eval-when-compile | 32 | (eval-when-compile |
| 33 | (require 'cl) | 33 | (require 'cl) |
| 34 | (require 'dired)) | 34 | (require 'dired)) |
| 35 | (defvar tramp-gw-tunnel-method) | ||
| 36 | (defvar tramp-gw-socks-method) | ||
| 37 | (defvar vc-handled-backends) | 35 | (defvar vc-handled-backends) |
| 38 | (defvar vc-bzr-program) | 36 | (defvar vc-bzr-program) |
| 39 | (defvar vc-git-program) | 37 | (defvar vc-git-program) |
| @@ -172,11 +170,7 @@ The string is used in `tramp-methods'.") | |||
| 172 | (tramp-copy-program "scp") | 170 | (tramp-copy-program "scp") |
| 173 | (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") ("-r") ("%c"))) | 171 | (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") ("-r") ("%c"))) |
| 174 | (tramp-copy-keep-date t) | 172 | (tramp-copy-keep-date t) |
| 175 | (tramp-copy-recursive t) | 173 | (tramp-copy-recursive t))) |
| 176 | (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") | ||
| 177 | ("-o" "UserKnownHostsFile=/dev/null") | ||
| 178 | ("-o" "StrictHostKeyChecking=no"))) | ||
| 179 | (tramp-default-port 22))) | ||
| 180 | ;;;###tramp-autoload | 174 | ;;;###tramp-autoload |
| 181 | (add-to-list 'tramp-methods | 175 | (add-to-list 'tramp-methods |
| 182 | '("scpx" | 176 | '("scpx" |
| @@ -191,11 +185,7 @@ The string is used in `tramp-methods'.") | |||
| 191 | (tramp-copy-args (("-P" "%p") ("-p" "%k") | 185 | (tramp-copy-args (("-P" "%p") ("-p" "%k") |
| 192 | ("-q") ("-r") ("%c"))) | 186 | ("-q") ("-r") ("%c"))) |
| 193 | (tramp-copy-keep-date t) | 187 | (tramp-copy-keep-date t) |
| 194 | (tramp-copy-recursive t) | 188 | (tramp-copy-recursive t))) |
| 195 | (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") | ||
| 196 | ("-o" "UserKnownHostsFile=/dev/null") | ||
| 197 | ("-o" "StrictHostKeyChecking=no"))) | ||
| 198 | (tramp-default-port 22))) | ||
| 199 | ;;;###tramp-autoload | 189 | ;;;###tramp-autoload |
| 200 | (add-to-list 'tramp-methods | 190 | (add-to-list 'tramp-methods |
| 201 | '("rsync" | 191 | '("rsync" |
| @@ -237,11 +227,7 @@ The string is used in `tramp-methods'.") | |||
| 237 | (tramp-async-args (("-q"))) | 227 | (tramp-async-args (("-q"))) |
| 238 | (tramp-remote-shell "/bin/sh") | 228 | (tramp-remote-shell "/bin/sh") |
| 239 | (tramp-remote-shell-login ("-l")) | 229 | (tramp-remote-shell-login ("-l")) |
| 240 | (tramp-remote-shell-args ("-c")) | 230 | (tramp-remote-shell-args ("-c")))) |
| 241 | (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") | ||
| 242 | ("-o" "UserKnownHostsFile=/dev/null") | ||
| 243 | ("-o" "StrictHostKeyChecking=no"))) | ||
| 244 | (tramp-default-port 22))) | ||
| 245 | ;;;###tramp-autoload | 231 | ;;;###tramp-autoload |
| 246 | (add-to-list 'tramp-methods | 232 | (add-to-list 'tramp-methods |
| 247 | '("sshx" | 233 | '("sshx" |
| @@ -251,11 +237,7 @@ The string is used in `tramp-methods'.") | |||
| 251 | (tramp-async-args (("-q"))) | 237 | (tramp-async-args (("-q"))) |
| 252 | (tramp-remote-shell "/bin/sh") | 238 | (tramp-remote-shell "/bin/sh") |
| 253 | (tramp-remote-shell-login ("-l")) | 239 | (tramp-remote-shell-login ("-l")) |
| 254 | (tramp-remote-shell-args ("-c")) | 240 | (tramp-remote-shell-args ("-c")))) |
| 255 | (tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null") | ||
| 256 | ("-o" "UserKnownHostsFile=/dev/null") | ||
| 257 | ("-o" "StrictHostKeyChecking=no"))) | ||
| 258 | (tramp-default-port 22))) | ||
| 259 | ;;;###tramp-autoload | 241 | ;;;###tramp-autoload |
| 260 | (add-to-list 'tramp-methods | 242 | (add-to-list 'tramp-methods |
| 261 | '("telnet" | 243 | '("telnet" |
| @@ -263,8 +245,7 @@ The string is used in `tramp-methods'.") | |||
| 263 | (tramp-login-args (("%h") ("%p") ("2>/dev/null"))) | 245 | (tramp-login-args (("%h") ("%p") ("2>/dev/null"))) |
| 264 | (tramp-remote-shell "/bin/sh") | 246 | (tramp-remote-shell "/bin/sh") |
| 265 | (tramp-remote-shell-login ("-l")) | 247 | (tramp-remote-shell-login ("-l")) |
| 266 | (tramp-remote-shell-args ("-c")) | 248 | (tramp-remote-shell-args ("-c")))) |
| 267 | (tramp-default-port 23))) | ||
| 268 | ;;;###tramp-autoload | 249 | ;;;###tramp-autoload |
| 269 | (add-to-list 'tramp-methods | 250 | (add-to-list 'tramp-methods |
| 270 | '("nc" | 251 | '("nc" |
| @@ -280,8 +261,7 @@ The string is used in `tramp-methods'.") | |||
| 280 | ;; We use "-p" as required for newer busyboxes. For older | 261 | ;; We use "-p" as required for newer busyboxes. For older |
| 281 | ;; busybox/nc versions, the value must be (("-l") ("%r")). This | 262 | ;; busybox/nc versions, the value must be (("-l") ("%r")). This |
| 282 | ;; can be achieved by tweaking `tramp-connection-properties'. | 263 | ;; can be achieved by tweaking `tramp-connection-properties'. |
| 283 | (tramp-remote-copy-args (("-l") ("-p" "%r") ("2>/dev/null"))) | 264 | (tramp-remote-copy-args (("-l") ("-p" "%r") ("2>/dev/null"))))) |
| 284 | (tramp-default-port 23))) | ||
| 285 | ;;;###tramp-autoload | 265 | ;;;###tramp-autoload |
| 286 | (add-to-list 'tramp-methods | 266 | (add-to-list 'tramp-methods |
| 287 | '("su" | 267 | '("su" |
| @@ -353,8 +333,7 @@ The string is used in `tramp-methods'.") | |||
| 353 | ("/bin/sh") ("\""))) | 333 | ("/bin/sh") ("\""))) |
| 354 | (tramp-remote-shell "/bin/sh") | 334 | (tramp-remote-shell "/bin/sh") |
| 355 | (tramp-remote-shell-login ("-l")) | 335 | (tramp-remote-shell-login ("-l")) |
| 356 | (tramp-remote-shell-args ("-c")) | 336 | (tramp-remote-shell-args ("-c")))) |
| 357 | (tramp-default-port 22))) | ||
| 358 | ;;;###tramp-autoload | 337 | ;;;###tramp-autoload |
| 359 | (add-to-list 'tramp-methods | 338 | (add-to-list 'tramp-methods |
| 360 | `("plinkx" | 339 | `("plinkx" |
| @@ -386,8 +365,7 @@ The string is used in `tramp-methods'.") | |||
| 386 | (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-scp") ("-p" "%k") | 365 | (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-scp") ("-p" "%k") |
| 387 | ("-q") ("-r"))) | 366 | ("-q") ("-r"))) |
| 388 | (tramp-copy-keep-date t) | 367 | (tramp-copy-keep-date t) |
| 389 | (tramp-copy-recursive t) | 368 | (tramp-copy-recursive t))) |
| 390 | (tramp-default-port 22))) | ||
| 391 | ;;;###tramp-autoload | 369 | ;;;###tramp-autoload |
| 392 | (add-to-list 'tramp-methods | 370 | (add-to-list 'tramp-methods |
| 393 | `("psftp" | 371 | `("psftp" |
| @@ -2395,10 +2373,6 @@ The method used must be an out-of-band method." | |||
| 2395 | v "login-as" nil)) | 2373 | v "login-as" nil)) |
| 2396 | tramp-current-host (tramp-file-name-real-host v)) | 2374 | tramp-current-host (tramp-file-name-real-host v)) |
| 2397 | 2375 | ||
| 2398 | ;; Expand hops. Might be necessary for gateway methods. | ||
| 2399 | (setq v (car (tramp-compute-multi-hops v))) | ||
| 2400 | (aset v 3 localname) | ||
| 2401 | |||
| 2402 | ;; Check which ones of source and target are Tramp files. | 2376 | ;; Check which ones of source and target are Tramp files. |
| 2403 | (setq source (funcall | 2377 | (setq source (funcall |
| 2404 | (if (and (file-directory-p filename) | 2378 | (if (and (file-directory-p filename) |
| @@ -2412,15 +2386,9 @@ The method used must be an out-of-band method." | |||
| 2412 | (tramp-make-copy-program-file-name v) | 2386 | (tramp-make-copy-program-file-name v) |
| 2413 | (tramp-unquote-shell-quote-argument newname))) | 2387 | (tramp-unquote-shell-quote-argument newname))) |
| 2414 | 2388 | ||
| 2415 | ;; Check for host and port number. We cannot use | 2389 | ;; Check for host and port number. |
| 2416 | ;; `tramp-file-name-port', because this returns also | 2390 | (setq host (tramp-file-name-real-host v) |
| 2417 | ;; `tramp-default-port', which might clash with settings in | 2391 | port (tramp-file-name-port v)) |
| 2418 | ;; "~/.ssh/config". | ||
| 2419 | (setq host (tramp-file-name-host v) | ||
| 2420 | port "") | ||
| 2421 | (when (string-match tramp-host-with-port-regexp host) | ||
| 2422 | (setq port (string-to-number (match-string 2 host)) | ||
| 2423 | host (string-to-number (match-string 1 host)))) | ||
| 2424 | 2392 | ||
| 2425 | ;; Check for user. There might be an interactive setting. | 2393 | ;; Check for user. There might be an interactive setting. |
| 2426 | (setq user (or (tramp-file-name-user v) | 2394 | (setq user (or (tramp-file-name-user v) |
| @@ -4504,8 +4472,7 @@ Goes through the list `tramp-inline-compress-commands'." | |||
| 4504 | vec 2 "Couldn't find an inline transfer compress command"))))) | 4472 | vec 2 "Couldn't find an inline transfer compress command"))))) |
| 4505 | 4473 | ||
| 4506 | (defun tramp-compute-multi-hops (vec) | 4474 | (defun tramp-compute-multi-hops (vec) |
| 4507 | "Expands VEC according to `tramp-default-proxies-alist'. | 4475 | "Expands VEC according to `tramp-default-proxies-alist'." |
| 4508 | Gateway hops are already opened." | ||
| 4509 | (let ((target-alist `(,vec)) | 4476 | (let ((target-alist `(,vec)) |
| 4510 | (hops (or (tramp-file-name-hop vec) "")) | 4477 | (hops (or (tramp-file-name-hop vec) "")) |
| 4511 | (item vec) | 4478 | (item vec) |
| @@ -4562,32 +4529,6 @@ Gateway hops are already opened." | |||
| 4562 | ;; Start next search. | 4529 | ;; Start next search. |
| 4563 | (setq choices tramp-default-proxies-alist))))) | 4530 | (setq choices tramp-default-proxies-alist))))) |
| 4564 | 4531 | ||
| 4565 | ;; Handle gateways. | ||
| 4566 | (when (and (boundp 'tramp-gw-tunnel-method) (boundp 'tramp-gw-socks-method) | ||
| 4567 | (string-match | ||
| 4568 | (format | ||
| 4569 | "^\\(%s\\|%s\\)$" tramp-gw-tunnel-method tramp-gw-socks-method) | ||
| 4570 | (tramp-file-name-method (car target-alist)))) | ||
| 4571 | (let ((gw (pop target-alist)) | ||
| 4572 | (hop (pop target-alist))) | ||
| 4573 | ;; Is the method prepared for gateways? | ||
| 4574 | (unless (tramp-file-name-port hop) | ||
| 4575 | (tramp-error | ||
| 4576 | vec 'file-error | ||
| 4577 | "Connection `%s' is not supported for gateway access." hop)) | ||
| 4578 | ;; Open the gateway connection. | ||
| 4579 | (push | ||
| 4580 | (vector | ||
| 4581 | (tramp-file-name-method hop) (tramp-file-name-user hop) | ||
| 4582 | (tramp-gw-open-connection vec gw hop) nil nil) | ||
| 4583 | target-alist) | ||
| 4584 | ;; For the password prompt, we need the correct values. | ||
| 4585 | ;; Therefore, we must remember the gateway vector. But we | ||
| 4586 | ;; cannot do it as connection property, because it shouldn't | ||
| 4587 | ;; be persistent. And we have no started process yet either. | ||
| 4588 | (let ((tramp-verbose 0)) | ||
| 4589 | (tramp-set-file-property (car target-alist) "" "gateway" hop)))) | ||
| 4590 | |||
| 4591 | ;; Foreign and out-of-band methods are not supported for multi-hops. | 4532 | ;; Foreign and out-of-band methods are not supported for multi-hops. |
| 4592 | (when (cdr target-alist) | 4533 | (when (cdr target-alist) |
| 4593 | (setq choices target-alist) | 4534 | (setq choices target-alist) |
| @@ -4802,13 +4743,6 @@ connection if a previous connection has died for some reason." | |||
| 4802 | (connection-timeout | 4743 | (connection-timeout |
| 4803 | (tramp-get-method-parameter | 4744 | (tramp-get-method-parameter |
| 4804 | hop 'tramp-connection-timeout)) | 4745 | hop 'tramp-connection-timeout)) |
| 4805 | (gw-args | ||
| 4806 | (tramp-get-method-parameter hop 'tramp-gw-args)) | ||
| 4807 | (gw (let ((tramp-verbose 0)) | ||
| 4808 | (tramp-get-file-property hop "" "gateway" nil))) | ||
| 4809 | (g-method (and gw (tramp-file-name-method gw))) | ||
| 4810 | (g-user (and gw (tramp-file-name-user gw))) | ||
| 4811 | (g-host (and gw (tramp-file-name-real-host gw))) | ||
| 4812 | (command login-program) | 4746 | (command login-program) |
| 4813 | ;; We don't create the temporary file. In | 4747 | ;; We don't create the temporary file. In |
| 4814 | ;; fact, it is just a prefix for the | 4748 | ;; fact, it is just a prefix for the |
| @@ -4832,12 +4766,6 @@ connection if a previous connection has died for some reason." | |||
| 4832 | (when (and process-name async-args) | 4766 | (when (and process-name async-args) |
| 4833 | (setq login-args (append async-args login-args))) | 4767 | (setq login-args (append async-args login-args))) |
| 4834 | 4768 | ||
| 4835 | ;; Add gateway arguments if necessary. | ||
| 4836 | (when gw | ||
| 4837 | (tramp-set-connection-property p "gateway" t) | ||
| 4838 | (when gw-args | ||
| 4839 | (setq login-args (append gw-args login-args)))) | ||
| 4840 | |||
| 4841 | ;; Check for port number. Until now, there's no | 4769 | ;; Check for port number. Until now, there's no |
| 4842 | ;; need for handling like method, user, host. | 4770 | ;; need for handling like method, user, host. |
| 4843 | (when (string-match tramp-host-with-port-regexp l-host) | 4771 | (when (string-match tramp-host-with-port-regexp l-host) |
| @@ -4850,11 +4778,10 @@ connection if a previous connection has died for some reason." | |||
| 4850 | (setq r-shell t))) | 4778 | (setq r-shell t))) |
| 4851 | 4779 | ||
| 4852 | ;; Set variables for computing the prompt for | 4780 | ;; Set variables for computing the prompt for |
| 4853 | ;; reading password. They can also be derived | 4781 | ;; reading password. |
| 4854 | ;; from a gateway. | 4782 | (setq tramp-current-method l-method |
| 4855 | (setq tramp-current-method (or g-method l-method) | 4783 | tramp-current-user l-user |
| 4856 | tramp-current-user (or g-user l-user) | 4784 | tramp-current-host l-host) |
| 4857 | tramp-current-host (or g-host l-host)) | ||
| 4858 | 4785 | ||
| 4859 | ;; Add login environment. | 4786 | ;; Add login environment. |
| 4860 | (when login-env | 4787 | (when login-env |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index da745524a14..4103a6e76a8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -241,12 +241,7 @@ pair of the form (KEY VALUE). The following KEYs are defined: | |||
| 241 | * `tramp-copy-recursive' | 241 | * `tramp-copy-recursive' |
| 242 | Whether the operation copies directories recursively. | 242 | Whether the operation copies directories recursively. |
| 243 | * `tramp-default-port' | 243 | * `tramp-default-port' |
| 244 | The default port of a method is needed in case of gateway connections. | 244 | The default port of a method. |
| 245 | Additionally, it is used as indication which method is prepared for | ||
| 246 | passing gateways. | ||
| 247 | * `tramp-gw-args' | ||
| 248 | As the attribute name says, additional arguments are specified here | ||
| 249 | when a method is applied via a gateway. | ||
| 250 | * `tramp-tmpdir' | 245 | * `tramp-tmpdir' |
| 251 | A directory on the remote host for temporary files. If not | 246 | A directory on the remote host for temporary files. If not |
| 252 | specified, \"/tmp\" is taken as default. | 247 | specified, \"/tmp\" is taken as default. |
| @@ -277,8 +272,7 @@ See the variables `tramp-local-coding-commands' and | |||
| 277 | 272 | ||
| 278 | So, to summarize: if the method is an out-of-band method, then you | 273 | So, to summarize: if the method is an out-of-band method, then you |
| 279 | must specify `tramp-copy-program' and `tramp-copy-args'. If it is an | 274 | must specify `tramp-copy-program' and `tramp-copy-args'. If it is an |
| 280 | inline method, then these two parameters should be nil. Methods which | 275 | inline method, then these two parameters should be nil. |
| 281 | are fit for gateways must have `tramp-default-port' at least. | ||
| 282 | 276 | ||
| 283 | Notes: | 277 | Notes: |
| 284 | 278 | ||
| @@ -1139,8 +1133,7 @@ entry does not exist, return nil." | |||
| 1139 | (defun tramp-file-name-port (vec) | 1133 | (defun tramp-file-name-port (vec) |
| 1140 | "Return the port number of VEC." | 1134 | "Return the port number of VEC." |
| 1141 | (save-match-data | 1135 | (save-match-data |
| 1142 | (let ((method (tramp-file-name-method vec)) | 1136 | (let ((host (tramp-file-name-host vec))) |
| 1143 | (host (tramp-file-name-host vec))) | ||
| 1144 | (or (and (stringp host) | 1137 | (or (and (stringp host) |
| 1145 | (string-match tramp-host-with-port-regexp host) | 1138 | (string-match tramp-host-with-port-regexp host) |
| 1146 | (string-to-number (match-string 2 host))) | 1139 | (string-to-number (match-string 2 host))) |
| @@ -1267,9 +1260,6 @@ values." | |||
| 1267 | 1260 | ||
| 1268 | (defun tramp-buffer-name (vec) | 1261 | (defun tramp-buffer-name (vec) |
| 1269 | "A name for the connection buffer VEC." | 1262 | "A name for the connection buffer VEC." |
| 1270 | ;; We must use `tramp-file-name-real-host', because for gateway | ||
| 1271 | ;; methods the default port will be expanded later on, which would | ||
| 1272 | ;; tamper the name. | ||
| 1273 | (let ((method (tramp-file-name-method vec)) | 1263 | (let ((method (tramp-file-name-method vec)) |
| 1274 | (user (tramp-file-name-user vec)) | 1264 | (user (tramp-file-name-user vec)) |
| 1275 | (host (tramp-file-name-real-host vec))) | 1265 | (host (tramp-file-name-real-host vec))) |
| @@ -1359,9 +1349,6 @@ version, the function does nothing." | |||
| 1359 | 1349 | ||
| 1360 | (defun tramp-debug-buffer-name (vec) | 1350 | (defun tramp-debug-buffer-name (vec) |
| 1361 | "A name for the debug buffer for VEC." | 1351 | "A name for the debug buffer for VEC." |
| 1362 | ;; We must use `tramp-file-name-real-host', because for gateway | ||
| 1363 | ;; methods the default port will be expanded later on, which would | ||
| 1364 | ;; tamper the name. | ||
| 1365 | (let ((method (tramp-file-name-method vec)) | 1352 | (let ((method (tramp-file-name-method vec)) |
| 1366 | (user (tramp-file-name-user vec)) | 1353 | (user (tramp-file-name-user vec)) |
| 1367 | (host (tramp-file-name-real-host vec))) | 1354 | (host (tramp-file-name-real-host vec))) |
| @@ -3632,17 +3619,13 @@ connection buffer." | |||
| 3632 | This is needed in order to hide `last-coding-system-used', which is set | 3619 | This is needed in order to hide `last-coding-system-used', which is set |
| 3633 | for process communication also." | 3620 | for process communication also." |
| 3634 | (with-current-buffer (process-buffer proc) | 3621 | (with-current-buffer (process-buffer proc) |
| 3635 | ;; FIXME: If there is a gateway process, we need communication | 3622 | (let (buffer-read-only last-coding-system-used) |
| 3636 | ;; between several processes. Too complicate to implement, so we | ||
| 3637 | ;; read output from all processes. | ||
| 3638 | (let ((p (if (tramp-get-connection-property proc "gateway" nil) nil proc)) | ||
| 3639 | buffer-read-only last-coding-system-used) | ||
| 3640 | ;; Under Windows XP, accept-process-output doesn't return | 3623 | ;; Under Windows XP, accept-process-output doesn't return |
| 3641 | ;; sometimes. So we add an additional timeout. | 3624 | ;; sometimes. So we add an additional timeout. |
| 3642 | (with-timeout ((or timeout 1)) | 3625 | (with-timeout ((or timeout 1)) |
| 3643 | (accept-process-output p timeout timeout-msecs (and proc t))) | 3626 | (accept-process-output proc timeout timeout-msecs (and proc t))) |
| 3644 | (tramp-message proc 10 "%s %s %s\n%s" | 3627 | (tramp-message proc 10 "%s %s\n%s" |
| 3645 | proc (process-status proc) p (buffer-string))))) | 3628 | proc (process-status proc) (buffer-string))))) |
| 3646 | 3629 | ||
| 3647 | (defun tramp-check-for-regexp (proc regexp) | 3630 | (defun tramp-check-for-regexp (proc regexp) |
| 3648 | "Check, whether REGEXP is contained in process buffer of PROC. | 3631 | "Check, whether REGEXP is contained in process buffer of PROC. |