aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2024-02-20 12:52:40 +0100
committerMichael Albinus2024-02-20 12:52:40 +0100
commit4e9993cada32a866a75b458092de0028db2f5f41 (patch)
tree8687fe6e6cf17747b3076b4fe2c7bf22dc38a0c1
parenta1cbc4d810bc1b525fa46b23249b414c1ad6b031 (diff)
downloademacs-4e9993cada32a866a75b458092de0028db2f5f41.tar.gz
emacs-4e9993cada32a866a75b458092de0028db2f5f41.zip
Add Tramp methods dockercp and podmancp
* doc/misc/tramp.texi (External methods): Add dockercp and podmancp. * etc/NEWS: Add Tramp methods "dockercp" and "podmancp". * lisp/net/tramp.el (tramp-handle-make-process): * lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band) (tramp-maybe-open-connection): * lisp/net/tramp-sshfs.el (tramp-sshfs-handle-process-file) (tramp-sshfs-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command): Adapt `tramp-expand-args' calls. * lisp/net/tramp-container.el (tramp-dockercp-method) (tramp-podmancp-method): New defconst. (tramp-methods) <dockercp, podmancp>: Add new methods. (tramp-container--completion-function): Adapt docstring. Use it for "dockercp" and "podmancp" completion. * lisp/net/tramp.el (tramp-get-remote-tmpdir): * lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-maybe-open-connection): Use a default value with `tramp-get-method-parameter'. * lisp/net/tramp-sh.el (tramp-methods) <nc>: Add `tramp-copy-file-name'. (tramp-default-copy-file-name): New defconst. (tramp-make-copy-file-name): Rename from `tramp-make-copy-program-file-name'. Use method parameter `tramp-copy-file-name'. (Bug#69085) (tramp-do-copy-or-rename-file-out-of-band): Adapt callees. * lisp/net/tramp.el (tramp-methods): Adapt docstring. (tramp-get-method-parameter, tramp-expand-args): New optional argument DEFAULT. * test/lisp/net/tramp-tests.el (tramp--test-container-p): Adapt. (tramp--test-container-oob-p): New defun. (tramp-test17-dired-with-wildcards, tramp-test35-remote-path) (tramp-test41-special-characters): Use it. (tramp--test-set-ert-test-documentation): Use `split-string'.
-rw-r--r--doc/misc/tramp.texi14
-rw-r--r--etc/NEWS12
-rw-r--r--lisp/net/tramp-adb.el2
-rw-r--r--lisp/net/tramp-container.el60
-rw-r--r--lisp/net/tramp-gvfs.el4
-rw-r--r--lisp/net/tramp-sh.el38
-rw-r--r--lisp/net/tramp-sshfs.el4
-rw-r--r--lisp/net/tramp-sudoedit.el2
-rw-r--r--lisp/net/tramp.el35
-rw-r--r--test/lisp/net/tramp-tests.el85
10 files changed, 182 insertions, 74 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index affd760730b..6d4654f1a8a 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -1059,6 +1059,20 @@ session.
1059 1059
1060These methods support the @samp{-P} argument. 1060These methods support the @samp{-P} argument.
1061 1061
1062@item @option{dockercp}
1063@item @option{podmancp}
1064@cindex method @option{dockercp}
1065@cindex @option{dockercp} method
1066@cindex method @option{podmancp}
1067@cindex @option{podmancp} method
1068
1069These methods are similar to @option{docker} or @option{podman}, but
1070they use the command @command{docker cp} or @command{podman cp} for
1071transferring large files.
1072
1073These copy commands do not support file globs, and they ignore a user
1074name.
1075
1062@item @option{fcp} 1076@item @option{fcp}
1063@cindex method @option{fcp} 1077@cindex method @option{fcp}
1064@cindex @option{fcp} method 1078@cindex @option{fcp} method
diff --git a/etc/NEWS b/etc/NEWS
index 4477116248e..7b248c3fe78 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -885,6 +885,10 @@ mode line. 'header' will display in the header line;
885** Tramp 885** Tramp
886 886
887+++ 887+++
888*** New connection methods "dockercp" and "podmancp".
889These are the external methods counterparts of "docker" and "podman".
890
891+++
888*** New connection methods "toolbox" and "flatpak". 892*** New connection methods "toolbox" and "flatpak".
889They allow accessing system containers provided by Toolbox or 893They allow accessing system containers provided by Toolbox or
890sandboxes provided by Flatpak. 894sandboxes provided by Flatpak.
@@ -1121,7 +1125,7 @@ the user option 'nnweb-type' to 'gmane'.
1121*** New user option 'gnus-mode-line-logo'. 1125*** New user option 'gnus-mode-line-logo'.
1122This allows the user to either disable the display of any logo or 1126This allows the user to either disable the display of any logo or
1123specify which logo will be displayed as part of the 1127specify which logo will be displayed as part of the
1124buffer-identification in the mode-line of Gnus-buffers. 1128buffer-identification in the mode-line of Gnus buffers.
1125 1129
1126** Rmail 1130** Rmail
1127 1131
@@ -1333,7 +1337,7 @@ chat buffers use by default.
1333This command toggles the display of internal buffers in Buffer Menu mode; 1337This command toggles the display of internal buffers in Buffer Menu mode;
1334that is, buffers not visiting a file and whose names start with a space. 1338that is, buffers not visiting a file and whose names start with a space.
1335Previously, such buffers were never shown. This command is bound to 'I' 1339Previously, such buffers were never shown. This command is bound to 'I'
1336in Buffer menu mode. 1340in Buffer Menu mode.
1337 1341
1338** Customize 1342** Customize
1339 1343
@@ -1429,7 +1433,7 @@ current project configuration, and later updates it as you edit the
1429files and save the changes. 1433files and save the changes.
1430 1434
1431+++ 1435+++
1432** New package Compat 1436** New package Compat.
1433Emacs now comes with a stub implementation of the 1437Emacs now comes with a stub implementation of the
1434forwards-compatibility Compat package from GNU ELPA. This allows 1438forwards-compatibility Compat package from GNU ELPA. This allows
1435built-in packages to use the library more effectively, and helps 1439built-in packages to use the library more effectively, and helps
@@ -1560,7 +1564,7 @@ values.
1560 1564
1561+++ 1565+++
1562** Pcase's functions (in 'pred' and 'app') can specify the argument position. 1566** Pcase's functions (in 'pred' and 'app') can specify the argument position.
1563For example, instead of (pred (< 5)) you can write (pred (> _ 5)). 1567For example, instead of '(pred (< 5))' you can write '(pred (> _ 5))'.
1564 1568
1565+++ 1569+++
1566** 'define-advice' now sets the new advice's 'name' property to NAME. 1570** 'define-advice' now sets the new advice's 'name' property to NAME.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 2e4ad1cc412..96625fc5680 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1230,7 +1230,7 @@ connection if a previous connection has died for some reason."
1230 (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? 1230 (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct?
1231 (process-connection-type tramp-process-connection-type) 1231 (process-connection-type tramp-process-connection-type)
1232 (args (tramp-expand-args 1232 (args (tramp-expand-args
1233 vec 'tramp-login-args ?d (or device ""))) 1233 vec 'tramp-login-args nil ?d (or device "")))
1234 (p (let ((default-directory 1234 (p (let ((default-directory
1235 tramp-compat-temporary-file-directory)) 1235 tramp-compat-temporary-file-directory))
1236 (apply 1236 (apply
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index 1f578949e4d..30639cbeb85 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -31,15 +31,20 @@
31;; Open a file on a running Docker container: 31;; Open a file on a running Docker container:
32;; 32;;
33;; C-x C-f /docker:USER@CONTAINER:/path/to/file 33;; C-x C-f /docker:USER@CONTAINER:/path/to/file
34;; C-x C-f /dockercp:USER@CONTAINER:/path/to/file
34;; 35;;
35;; or Podman: 36;; or Podman:
36;; 37;;
37;; C-x C-f /podman:USER@CONTAINER:/path/to/file 38;; C-x C-f /podman:USER@CONTAINER:/path/to/file
39;; C-x C-f /podmancp:USER@CONTAINER:/path/to/file
38;; 40;;
39;; Where: 41;; Where:
40;; USER is the user on the container to connect as (optional). 42;; USER is the user on the container to connect as (optional).
41;; CONTAINER is the container to connect to. 43;; CONTAINER is the container to connect to.
42;; 44;;
45;; "docker" and "podman" are inline methods, "dockercp" and "podmancp"
46;; are out-of-band methods.
47;;
43;; 48;;
44;; 49;;
45;; Open file in a Kubernetes container: 50;; Open file in a Kubernetes container:
@@ -142,10 +147,20 @@ If it is nil, the default context will be used."
142 "Tramp method name to use to connect to Docker containers.") 147 "Tramp method name to use to connect to Docker containers.")
143 148
144;;;###tramp-autoload 149;;;###tramp-autoload
150(defconst tramp-dockercp-method "dockercp"
151 "Tramp method name to use to connect to Docker containers.
152This is for out-of-band connections.")
153
154;;;###tramp-autoload
145(defconst tramp-podman-method "podman" 155(defconst tramp-podman-method "podman"
146 "Tramp method name to use to connect to Podman containers.") 156 "Tramp method name to use to connect to Podman containers.")
147 157
148;;;###tramp-autoload 158;;;###tramp-autoload
159(defconst tramp-podmancp-method "podmancp"
160 "Tramp method name to use to connect to Podman containers.
161This is for out-of-band connections.")
162
163;;;###tramp-autoload
149(defconst tramp-kubernetes-method "kubernetes" 164(defconst tramp-kubernetes-method "kubernetes"
150 "Tramp method name to use to connect to Kubernetes containers.") 165 "Tramp method name to use to connect to Kubernetes containers.")
151 166
@@ -183,7 +198,8 @@ BODY is the backend specific code."
183(defun tramp-container--completion-function (method) 198(defun tramp-container--completion-function (method)
184 "List running containers available for connection. 199 "List running containers available for connection.
185METHOD is the Tramp method to be used for \"ps\", either 200METHOD is the Tramp method to be used for \"ps\", either
186`tramp-docker-method' or `tramp-podman-method'. 201`tramp-docker-method', `tramp-dockercp-method', `tramp-podman-method',
202or `tramp-podmancp-method'.
187 203
188This function is used by `tramp-set-completion-function', please 204This function is used by `tramp-set-completion-function', please
189see its function help for a description of the format." 205see its function help for a description of the format."
@@ -376,6 +392,23 @@ see its function help for a description of the format."
376 (tramp-remote-shell-args ("-i" "-c")))) 392 (tramp-remote-shell-args ("-i" "-c"))))
377 393
378 (add-to-list 'tramp-methods 394 (add-to-list 'tramp-methods
395 `(,tramp-dockercp-method
396 (tramp-login-program ,tramp-docker-program)
397 (tramp-login-args (("exec")
398 ("-it")
399 ("-u" "%u")
400 ("%h")
401 ("%l")))
402 (tramp-direct-async (,tramp-default-remote-shell "-c"))
403 (tramp-remote-shell ,tramp-default-remote-shell)
404 (tramp-remote-shell-login ("-l"))
405 (tramp-remote-shell-args ("-i" "-c"))
406 (tramp-copy-program ,tramp-docker-program)
407 (tramp-copy-args (("cp")))
408 (tramp-copy-file-name (("%h" ":") ("%f")))
409 (tramp-copy-recursive t)))
410
411 (add-to-list 'tramp-methods
379 `(,tramp-podman-method 412 `(,tramp-podman-method
380 (tramp-login-program ,tramp-podman-program) 413 (tramp-login-program ,tramp-podman-program)
381 (tramp-login-args (("exec") 414 (tramp-login-args (("exec")
@@ -389,6 +422,23 @@ see its function help for a description of the format."
389 (tramp-remote-shell-args ("-i" "-c")))) 422 (tramp-remote-shell-args ("-i" "-c"))))
390 423
391 (add-to-list 'tramp-methods 424 (add-to-list 'tramp-methods
425 `(,tramp-podmancp-method
426 (tramp-login-program ,tramp-podman-program)
427 (tramp-login-args (("exec")
428 ("-it")
429 ("-u" "%u")
430 ("%h")
431 ("%l")))
432 (tramp-direct-async (,tramp-default-remote-shell "-c"))
433 (tramp-remote-shell ,tramp-default-remote-shell)
434 (tramp-remote-shell-login ("-l"))
435 (tramp-remote-shell-args ("-i" "-c"))
436 (tramp-copy-program ,tramp-podman-program)
437 (tramp-copy-args (("cp")))
438 (tramp-copy-file-name (("%h" ":") ("%f")))
439 (tramp-copy-recursive t)))
440
441 (add-to-list 'tramp-methods
392 `(,tramp-kubernetes-method 442 `(,tramp-kubernetes-method
393 (tramp-login-program ,tramp-kubernetes-program) 443 (tramp-login-program ,tramp-kubernetes-program)
394 (tramp-login-args (("%x") ; context and namespace. 444 (tramp-login-args (("%x") ; context and namespace.
@@ -432,10 +482,18 @@ see its function help for a description of the format."
432 `((tramp-container--completion-function ,tramp-docker-method))) 482 `((tramp-container--completion-function ,tramp-docker-method)))
433 483
434 (tramp-set-completion-function 484 (tramp-set-completion-function
485 tramp-dockercp-method
486 `((tramp-container--completion-function ,tramp-dockercp-method)))
487
488 (tramp-set-completion-function
435 tramp-podman-method 489 tramp-podman-method
436 `((tramp-container--completion-function ,tramp-podman-method))) 490 `((tramp-container--completion-function ,tramp-podman-method)))
437 491
438 (tramp-set-completion-function 492 (tramp-set-completion-function
493 tramp-podmancp-method
494 `((tramp-container--completion-function ,tramp-podmancp-method)))
495
496 (tramp-set-completion-function
439 tramp-kubernetes-method 497 tramp-kubernetes-method
440 `((tramp-kubernetes--completion-function ,tramp-kubernetes-method))) 498 `((tramp-kubernetes--completion-function ,tramp-kubernetes-method)))
441 499
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 4e949e7e60b..93071ed7350 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -2294,8 +2294,8 @@ connection if a previous connection has died for some reason."
2294 ;; indicated by the "mounted" signal, i.e. the 2294 ;; indicated by the "mounted" signal, i.e. the
2295 ;; "fuse-mountpoint" file property. 2295 ;; "fuse-mountpoint" file property.
2296 (with-timeout 2296 (with-timeout
2297 ((or (tramp-get-method-parameter vec 'tramp-connection-timeout) 2297 ((tramp-get-method-parameter
2298 tramp-connection-timeout) 2298 vec 'tramp-connection-timeout tramp-connection-timeout)
2299 (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec)) 2299 (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec))
2300 (tramp-error 2300 (tramp-error
2301 vec 'file-error 2301 vec 'file-error
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 3557b3a1b64..66e648624b2 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -282,6 +282,7 @@ The string is used in `tramp-methods'.")
282 (tramp-copy-program "nc") 282 (tramp-copy-program "nc")
283 ;; We use "-v" for better error tracking. 283 ;; We use "-v" for better error tracking.
284 (tramp-copy-args (("-w" "1") ("-v") ("%h") ("%r"))) 284 (tramp-copy-args (("-w" "1") ("-v") ("%h") ("%r")))
285 (tramp-copy-file-name (("%f")))
285 (tramp-remote-copy-program "nc") 286 (tramp-remote-copy-program "nc")
286 ;; We use "-p" as required for newer busyboxes. For older 287 ;; We use "-p" as required for newer busyboxes. For older
287 ;; busybox/nc versions, the value must be (("-l") ("%r")). This 288 ;; busybox/nc versions, the value must be (("-l") ("%r")). This
@@ -428,6 +429,9 @@ The string is used in `tramp-methods'.")
428 eos) 429 eos)
429 nil ,(user-login-name)))) 430 nil ,(user-login-name))))
430 431
432(defconst tramp-default-copy-file-name '(("%u" "@") ("%h" ":") ("%f"))
433 "Default `tramp-copy-file-name' entry for out-of-band methods.")
434
431;;;###tramp-autoload 435;;;###tramp-autoload
432(defconst tramp-completion-function-alist-rsh 436(defconst tramp-completion-function-alist-rsh
433 '((tramp-parse-rhosts "/etc/hosts.equiv") 437 '((tramp-parse-rhosts "/etc/hosts.equiv")
@@ -2399,10 +2403,10 @@ The method used must be an out-of-band method."
2399 #'file-name-as-directory 2403 #'file-name-as-directory
2400 #'identity) 2404 #'identity)
2401 (if v1 2405 (if v1
2402 (tramp-make-copy-program-file-name v1) 2406 (tramp-make-copy-file-name v1)
2403 (file-name-unquote filename))) 2407 (file-name-unquote filename)))
2404 target (if v2 2408 target (if v2
2405 (tramp-make-copy-program-file-name v2) 2409 (tramp-make-copy-file-name v2)
2406 (file-name-unquote newname))) 2410 (file-name-unquote newname)))
2407 2411
2408 ;; Check for listener port. 2412 ;; Check for listener port.
@@ -2441,7 +2445,7 @@ The method used must be an out-of-band method."
2441 ;; " " has either been a replacement of "%k" (when 2445 ;; " " has either been a replacement of "%k" (when
2442 ;; KEEP-DATE argument is non-nil), or a replacement for 2446 ;; KEEP-DATE argument is non-nil), or a replacement for
2443 ;; the whole keep-date sublist. 2447 ;; the whole keep-date sublist.
2444 (delete " " (apply #'tramp-expand-args v 'tramp-copy-args spec)) 2448 (delete " " (apply #'tramp-expand-args v 'tramp-copy-args nil spec))
2445 ;; `tramp-ssh-controlmaster-options' is a string instead 2449 ;; `tramp-ssh-controlmaster-options' is a string instead
2446 ;; of a list. Unflatten it. 2450 ;; of a list. Unflatten it.
2447 copy-args 2451 copy-args
@@ -2450,11 +2454,11 @@ The method used must be an out-of-band method."
2450 (lambda (x) (if (tramp-compat-string-search " " x) 2454 (lambda (x) (if (tramp-compat-string-search " " x)
2451 (split-string x) x)) 2455 (split-string x) x))
2452 copy-args)) 2456 copy-args))
2453 copy-env (apply #'tramp-expand-args v 'tramp-copy-env spec) 2457 copy-env (apply #'tramp-expand-args v 'tramp-copy-env nil spec)
2454 remote-copy-program 2458 remote-copy-program
2455 (tramp-get-method-parameter v 'tramp-remote-copy-program) 2459 (tramp-get-method-parameter v 'tramp-remote-copy-program)
2456 remote-copy-args 2460 remote-copy-args
2457 (apply #'tramp-expand-args v 'tramp-remote-copy-args spec)) 2461 (apply #'tramp-expand-args v 'tramp-remote-copy-args nil spec))
2458 2462
2459 ;; Check for local copy program. 2463 ;; Check for local copy program.
2460 (unless (executable-find copy-program) 2464 (unless (executable-find copy-program)
@@ -5290,7 +5294,8 @@ connection if a previous connection has died for some reason."
5290 (tramp-get-method-parameter hop 'tramp-async-args))) 5294 (tramp-get-method-parameter hop 'tramp-async-args)))
5291 (connection-timeout 5295 (connection-timeout
5292 (tramp-get-method-parameter 5296 (tramp-get-method-parameter
5293 hop 'tramp-connection-timeout)) 5297 hop 'tramp-connection-timeout
5298 tramp-connection-timeout))
5294 (command 5299 (command
5295 (tramp-get-method-parameter 5300 (tramp-get-method-parameter
5296 hop 'tramp-login-program)) 5301 hop 'tramp-login-program))
@@ -5348,7 +5353,7 @@ connection if a previous connection has died for some reason."
5348 ;; Add arguments for asynchronous processes. 5353 ;; Add arguments for asynchronous processes.
5349 (when process-name async-args) 5354 (when process-name async-args)
5350 (tramp-expand-args 5355 (tramp-expand-args
5351 hop 'tramp-login-args 5356 hop 'tramp-login-args nil
5352 ?h (or l-host "") ?u (or l-user "") ?p (or l-port "") 5357 ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
5353 ?c (format-spec options (format-spec-make ?t tmpfile)) 5358 ?c (format-spec options (format-spec-make ?t tmpfile))
5354 ?n (concat 5359 ?n (concat
@@ -5365,8 +5370,7 @@ connection if a previous connection has died for some reason."
5365 p vec 5370 p vec
5366 (min 5371 (min
5367 pos (with-current-buffer (process-buffer p) (point-max))) 5372 pos (with-current-buffer (process-buffer p) (point-max)))
5368 tramp-actions-before-shell 5373 tramp-actions-before-shell connection-timeout)
5369 (or connection-timeout tramp-connection-timeout))
5370 (tramp-message 5374 (tramp-message
5371 vec 3 "Found remote shell prompt on `%s'" l-host) 5375 vec 3 "Found remote shell prompt on `%s'" l-host)
5372 5376
@@ -5559,8 +5563,8 @@ raises an error."
5559 string 5563 string
5560 "")) 5564 ""))
5561 5565
5562(defun tramp-make-copy-program-file-name (vec) 5566(defun tramp-make-copy-file-name (vec)
5563 "Create a file name suitable for `scp', `pscp', or `nc' and workalikes." 5567 "Create a file name suitable for out-of-band methods."
5564 (let ((method (tramp-file-name-method vec)) 5568 (let ((method (tramp-file-name-method vec))
5565 (user (tramp-file-name-user vec)) 5569 (user (tramp-file-name-user vec))
5566 (host (tramp-file-name-host vec)) 5570 (host (tramp-file-name-host vec))
@@ -5571,13 +5575,13 @@ raises an error."
5571 ;; This does not work for MS Windows scp, if there are characters 5575 ;; This does not work for MS Windows scp, if there are characters
5572 ;; to be quoted. OpenSSH 8 supports disabling of strict file name 5576 ;; to be quoted. OpenSSH 8 supports disabling of strict file name
5573 ;; checking in scp, we use it when available. 5577 ;; checking in scp, we use it when available.
5574 (unless (string-match-p (rx "ftp" eos) method) 5578 (unless (string-match-p (rx (| "dockercp" "podmancp" "ftp") eos) method)
5575 (setq localname (tramp-unquote-shell-quote-argument localname))) 5579 (setq localname (tramp-unquote-shell-quote-argument localname)))
5576 (cond 5580 (string-join
5577 ((tramp-get-method-parameter vec 'tramp-remote-copy-program) 5581 (apply #'tramp-expand-args vec
5578 localname) 5582 'tramp-copy-file-name tramp-default-copy-file-name
5579 ((tramp-string-empty-or-nil-p user) (format "%s:%s" host localname)) 5583 (list ?h (or host "") ?u (or user "") ?f localname))
5580 (t (format "%s@%s:%s" user host localname))))) 5584 "")))
5581 5585
5582(defun tramp-method-out-of-band-p (vec size) 5586(defun tramp-method-out-of-band-p (vec size)
5583 "Return t if this is an out-of-band method, nil otherwise." 5587 "Return t if this is an out-of-band method, nil otherwise."
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 8dad599c7e7..d0d56b8967e 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -322,7 +322,7 @@ arguments to pass to the OPERATION."
322 v (tramp-get-method-parameter v 'tramp-login-program) 322 v (tramp-get-method-parameter v 'tramp-login-program)
323 nil outbuf display 323 nil outbuf display
324 (tramp-expand-args 324 (tramp-expand-args
325 v 'tramp-login-args 325 v 'tramp-login-args nil
326 ?h (or (tramp-file-name-host v) "") 326 ?h (or (tramp-file-name-host v) "")
327 ?u (or (tramp-file-name-user v) "") 327 ?u (or (tramp-file-name-user v) "")
328 ?p (or (tramp-file-name-port v) "") 328 ?p (or (tramp-file-name-port v) "")
@@ -424,7 +424,7 @@ connection if a previous connection has died for some reason."
424 (tramp-fuse-mount-spec vec) 424 (tramp-fuse-mount-spec vec)
425 (tramp-fuse-mount-point vec) 425 (tramp-fuse-mount-point vec)
426 (tramp-expand-args 426 (tramp-expand-args
427 vec 'tramp-mount-args 427 vec 'tramp-mount-args nil
428 ?p (or (tramp-file-name-port vec) "")))))) 428 ?p (or (tramp-file-name-port vec) ""))))))
429 (tramp-error 429 (tramp-error
430 vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec))) 430 vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec)))
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index 0c717c4a5aa..7bbfec62753 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -771,7 +771,7 @@ in case of error, t otherwise."
771 (tramp-get-connection-name vec) (current-buffer) 771 (tramp-get-connection-name vec) (current-buffer)
772 (append 772 (append
773 (tramp-expand-args 773 (tramp-expand-args
774 vec 'tramp-sudo-login 774 vec 'tramp-sudo-login nil
775 ?h (or (tramp-file-name-host vec) "") 775 ?h (or (tramp-file-name-host vec) "")
776 ?u (or (tramp-file-name-user vec) "")) 776 ?u (or (tramp-file-name-user vec) ""))
777 (flatten-tree args)))) 777 (flatten-tree args))))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 2efee2344d2..e6d6eb0ee66 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -301,6 +301,15 @@ pair of the form (KEY VALUE). The following KEYs are defined:
301 This specifies the list of parameters to pass to the above mentioned 301 This specifies the list of parameters to pass to the above mentioned
302 program, the hints for `tramp-login-args' also apply here. 302 program, the hints for `tramp-login-args' also apply here.
303 303
304 * `tramp-copy-file-name'
305 The remote source or destination file name for out-of-band methods.
306 You can use \"%u\" and \"%h\" like in `tramp-login-args'.
307 Additionally, \"%f\" denotes the local file name part. This list
308 will be expanded to a string without spaces between the elements of
309 the list.
310
311 The default value is `tramp-default-copy-file-name'.
312
304 * `tramp-copy-env' 313 * `tramp-copy-env'
305 A list of environment variables and their values, which will 314 A list of environment variables and their values, which will
306 be set when calling `tramp-copy-program'. 315 be set when calling `tramp-copy-program'.
@@ -1545,21 +1554,23 @@ LOCALNAME and HOP do not count."
1545 (equal (tramp-file-name-unify vec1) 1554 (equal (tramp-file-name-unify vec1)
1546 (tramp-file-name-unify vec2)))) 1555 (tramp-file-name-unify vec2))))
1547 1556
1548(defun tramp-get-method-parameter (vec param) 1557(defun tramp-get-method-parameter (vec param &optional default)
1549 "Return the method parameter PARAM. 1558 "Return the method parameter PARAM.
1550If VEC is a vector, check first in connection properties. 1559If VEC is a vector, check first in connection properties.
1551Afterwards, check in `tramp-methods'. If the `tramp-methods' 1560Afterwards, check in `tramp-methods'. If the `tramp-methods'
1552entry does not exist, return nil." 1561entry does not exist, return DEFAULT."
1553 (let ((hash-entry 1562 (let ((hash-entry
1554 (replace-regexp-in-string (rx bos "tramp-") "" (symbol-name param)))) 1563 (replace-regexp-in-string (rx bos "tramp-") "" (symbol-name param))))
1555 (if (tramp-connection-property-p vec hash-entry) 1564 (if (tramp-connection-property-p vec hash-entry)
1556 ;; We use the cached property. 1565 ;; We use the cached property.
1557 (tramp-get-connection-property vec hash-entry) 1566 (tramp-get-connection-property vec hash-entry)
1558 ;; Use the static value from `tramp-methods'. 1567 ;; Use the static value from `tramp-methods'.
1559 (when-let ((methods-entry 1568 (if-let ((methods-entry
1560 (assoc 1569 (assoc
1561 param (assoc (tramp-file-name-method vec) tramp-methods)))) 1570 param (assoc (tramp-file-name-method vec) tramp-methods))))
1562 (cadr methods-entry))))) 1571 (cadr methods-entry)
1572 ;; Return the default value.
1573 default))))
1563 1574
1564;; The localname can be quoted with "/:". Extract this. 1575;; The localname can be quoted with "/:". Extract this.
1565(defun tramp-file-name-unquote-localname (vec) 1576(defun tramp-file-name-unquote-localname (vec)
@@ -3943,6 +3954,9 @@ Let-bind it when necessary.")
3943 (tramp-get-method-parameter v 'tramp-case-insensitive) 3954 (tramp-get-method-parameter v 'tramp-case-insensitive)
3944 3955
3945 ;; There isn't. So we must check, in case there's a connection already. 3956 ;; There isn't. So we must check, in case there's a connection already.
3957 ;; Note: We cannot use it as DEFAULT value of
3958 ;; `tramp-get-method-parameter', because it would be evalled
3959 ;; during the call.
3946 (and (let ((non-essential t)) (tramp-connectable-p v)) 3960 (and (let ((non-essential t)) (tramp-connectable-p v))
3947 (with-tramp-connection-property v "case-insensitive" 3961 (with-tramp-connection-property v "case-insensitive"
3948 (ignore-errors 3962 (ignore-errors
@@ -4752,15 +4766,15 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
4752(defvar tramp-extra-expand-args nil 4766(defvar tramp-extra-expand-args nil
4753 "Method specific arguments.") 4767 "Method specific arguments.")
4754 4768
4755(defun tramp-expand-args (vec parameter &rest spec-list) 4769(defun tramp-expand-args (vec parameter default &rest spec-list)
4756 "Expand login arguments as given by PARAMETER in `tramp-methods'. 4770 "Expand login arguments as given by PARAMETER in `tramp-methods'.
4757PARAMETER is a symbol like `tramp-login-args', denoting a list of 4771PARAMETER is a symbol like `tramp-login-args', denoting a list of
4758list of strings from `tramp-methods', containing %-sequences for 4772list of strings from `tramp-methods', containing %-sequences for
4759substitution. 4773substitution. DEFAULT is used when PARAMETER is not specified.
4760SPEC-LIST is a list of char/value pairs used for 4774SPEC-LIST is a list of char/value pairs used for
4761`format-spec-make'. It is appended by `tramp-extra-expand-args', 4775`format-spec-make'. It is appended by `tramp-extra-expand-args',
4762a connection-local variable." 4776a connection-local variable."
4763 (let ((args (tramp-get-method-parameter vec parameter)) 4777 (let ((args (tramp-get-method-parameter vec parameter default))
4764 (extra-spec-list 4778 (extra-spec-list
4765 (mapcar 4779 (mapcar
4766 #'eval 4780 #'eval
@@ -4939,7 +4953,7 @@ a connection-local variable."
4939 (mapcar 4953 (mapcar
4940 (lambda (x) (split-string x " ")) 4954 (lambda (x) (split-string x " "))
4941 (tramp-expand-args 4955 (tramp-expand-args
4942 v 'tramp-login-args 4956 v 'tramp-login-args nil
4943 ?h (or host "") ?u (or user "") ?p (or port "") 4957 ?h (or host "") ?u (or user "") ?p (or port "")
4944 ?c (format-spec (or options "") (format-spec-make ?t tmpfile)) 4958 ?c (format-spec (or options "") (format-spec-make ?t tmpfile))
4945 ?d (or device "") ?a (or pta "") ?l "")))) 4959 ?d (or device "") ?a (or pta "") ?l ""))))
@@ -6326,9 +6340,8 @@ This handles also chrooted environments, which are not regarded as local."
6326(defun tramp-get-remote-tmpdir (vec) 6340(defun tramp-get-remote-tmpdir (vec)
6327 "Return directory for temporary files on the remote host identified by VEC." 6341 "Return directory for temporary files on the remote host identified by VEC."
6328 (with-tramp-connection-property (tramp-get-process vec) "remote-tmpdir" 6342 (with-tramp-connection-property (tramp-get-process vec) "remote-tmpdir"
6329 (let ((dir 6343 (let ((dir (tramp-make-tramp-file-name
6330 (tramp-make-tramp-file-name 6344 vec (tramp-get-method-parameter vec 'tramp-tmpdir "/tmp"))))
6331 vec (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp"))))
6332 (or (and (file-directory-p dir) (file-writable-p dir) 6345 (or (and (file-directory-p dir) (file-writable-p dir)
6333 (tramp-file-local-name dir)) 6346 (tramp-file-local-name dir))
6334 (tramp-error vec 'file-error "Directory %s not accessible" dir)) 6347 (tramp-error vec 'file-error "Directory %s not accessible" dir))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 623e0860a01..cdd2a1efdb2 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3493,6 +3493,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3493 (skip-unless (not (tramp--test-rsync-p))) 3493 (skip-unless (not (tramp--test-rsync-p)))
3494 ;; Wildcards are not supported in tramp-crypt.el. 3494 ;; Wildcards are not supported in tramp-crypt.el.
3495 (skip-unless (not (tramp--test-crypt-p))) 3495 (skip-unless (not (tramp--test-crypt-p)))
3496 ;; Wildcards are not supported with "docker cp ..." or "podman cp ...".
3497 (skip-unless (not (tramp--test-container-oob-p)))
3496 3498
3497 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) 3499 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
3498 (let* ((tmp-name1 3500 (let* ((tmp-name1
@@ -3819,7 +3821,7 @@ This tests also `access-file', `file-readable-p',
3819 "Set the documentation string for a derived test. 3821 "Set the documentation string for a derived test.
3820The test is derived from TEST and COMMAND." 3822The test is derived from TEST and COMMAND."
3821 (let ((test-doc 3823 (let ((test-doc
3822 (string-split (ert-test-documentation (get test 'ert--test)) "\n"))) 3824 (split-string (ert-test-documentation (get test 'ert--test)) "\n")))
3823 ;; The first line must be extended. 3825 ;; The first line must be extended.
3824 (setcar 3826 (setcar
3825 test-doc (format "%s Use the \"%s\" command." (car test-doc) command)) 3827 test-doc (format "%s Use the \"%s\" command." (car test-doc) command))
@@ -6379,33 +6381,35 @@ INPUT, if non-nil, is a string sent to the process."
6379 (setq tramp-remote-path orig-tramp-remote-path) 6381 (setq tramp-remote-path orig-tramp-remote-path)
6380 6382
6381 ;; We make a super long `tramp-remote-path'. 6383 ;; We make a super long `tramp-remote-path'.
6382 (make-directory tmp-name) 6384 (unless (tramp--test-container-oob-p)
6383 (should (file-directory-p tmp-name)) 6385 (make-directory tmp-name)
6384 (while (tramp-compat-length< (string-join orig-exec-path ":") 5000) 6386 (should (file-directory-p tmp-name))
6385 (let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir))) 6387 (while (tramp-compat-length< (string-join orig-exec-path ":") 5000)
6386 (should (file-directory-p dir)) 6388 (let ((dir (make-temp-file
6387 (setq tramp-remote-path 6389 (file-name-as-directory tmp-name) 'dir)))
6388 (append 6390 (should (file-directory-p dir))
6389 tramp-remote-path `(,(file-remote-p dir 'localname))) 6391 (setq tramp-remote-path
6390 orig-exec-path 6392 (append
6391 (append 6393 tramp-remote-path `(,(file-remote-p dir 'localname)))
6392 (butlast orig-exec-path) 6394 orig-exec-path
6393 `(,(file-remote-p dir 'localname)) 6395 (append
6394 (last orig-exec-path))))) 6396 (butlast orig-exec-path)
6395 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 6397 `(,(file-remote-p dir 'localname))
6396 (should (equal (exec-path) orig-exec-path)) 6398 (last orig-exec-path)))))
6397 ;; Ignore trailing newline. 6399 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
6398 (setq path (substring (shell-command-to-string "echo $PATH") nil -1)) 6400 (should (equal (exec-path) orig-exec-path))
6399 ;; The shell doesn't handle such long strings. 6401 ;; Ignore trailing newline.
6400 (unless (tramp-compat-length> 6402 (setq path (substring (shell-command-to-string "echo $PATH") nil -1))
6401 path 6403 ;; The shell doesn't handle such long strings.
6402 (tramp-get-connection-property 6404 (unless (tramp-compat-length>
6403 tramp-test-vec "pipe-buf" 4096)) 6405 path
6404 ;; The last element of `exec-path' is `exec-directory'. 6406 (tramp-get-connection-property
6405 (should 6407 tramp-test-vec "pipe-buf" 4096))
6406 (string-equal path (string-join (butlast orig-exec-path) ":")))) 6408 ;; The last element of `exec-path' is `exec-directory'.
6407 ;; The shell "sh" shall always exist. 6409 (should
6408 (should (executable-find "sh" 'remote))) 6410 (string-equal path (string-join (butlast orig-exec-path) ":"))))
6411 ;; The shell "sh" shall always exist.
6412 (should (executable-find "sh" 'remote))))
6409 6413
6410 ;; Cleanup. 6414 ;; Cleanup.
6411 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 6415 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
@@ -7056,17 +7060,24 @@ This is used in tests which we don't want to tag
7056 (not (and (tramp--test-adb-p) 7060 (not (and (tramp--test-adb-p)
7057 (string-match-p (rx multibyte) default-directory))))) 7061 (string-match-p (rx multibyte) default-directory)))))
7058 7062
7059(defun tramp--test-crypt-p ()
7060 "Check, whether the remote directory is encrypted."
7061 (tramp-crypt-file-name-p ert-remote-temporary-file-directory))
7062
7063(defun tramp--test-container-p () 7063(defun tramp--test-container-p ()
7064 "Check, whether a container method is used. 7064 "Check, whether a container method is used.
7065This does not support some special file names." 7065This does not support some special file names."
7066 (string-match-p 7066 (string-match-p
7067 (rx bol (| "docker" "podman") eol) 7067 (rx bol (| "docker" "podman"))
7068 (file-remote-p ert-remote-temporary-file-directory 'method))) 7068 (file-remote-p ert-remote-temporary-file-directory 'method)))
7069 7069
7070(defun tramp--test-container-oob-p ()
7071 "Check, whether the dockercp or podmancp method is used.
7072They does not support wildcard copy."
7073 (string-match-p
7074 (rx bol (| "dockercp" "podmancp") eol)
7075 (file-remote-p ert-remote-temporary-file-directory 'method)))
7076
7077(defun tramp--test-crypt-p ()
7078 "Check, whether the remote directory is encrypted."
7079 (tramp-crypt-file-name-p ert-remote-temporary-file-directory))
7080
7070(defun tramp--test-expensive-test-p () 7081(defun tramp--test-expensive-test-p ()
7071 "Whether expensive tests are run. 7082 "Whether expensive tests are run.
7072This is used in tests which we don't want to tag `:expensive' 7083This is used in tests which we don't want to tag `:expensive'
@@ -7483,7 +7494,8 @@ This requires restrictions of file name syntax."
7483 (tramp--test-gvfs-p) 7494 (tramp--test-gvfs-p)
7484 (tramp--test-windows-nt-or-smb-p)) 7495 (tramp--test-windows-nt-or-smb-p))
7485 "?foo?bar?baz?") 7496 "?foo?bar?baz?")
7486 (unless (or (tramp--test-ftp-p) 7497 (unless (or (tramp--test-container-oob-p)
7498 (tramp--test-ftp-p)
7487 (tramp--test-gvfs-p) 7499 (tramp--test-gvfs-p)
7488 (tramp--test-windows-nt-or-smb-p)) 7500 (tramp--test-windows-nt-or-smb-p))
7489 "*foo+bar*baz+") 7501 "*foo+bar*baz+")
@@ -7503,7 +7515,10 @@ This requires restrictions of file name syntax."
7503 (unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 7515 (unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
7504 "<foo>bar<baz>") 7516 "<foo>bar<baz>")
7505 "(foo)bar(baz)" 7517 "(foo)bar(baz)"
7506 (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]") 7518 (unless (or (tramp--test-container-oob-p)
7519 (tramp--test-ftp-p)
7520 (tramp--test-gvfs-p))
7521 "[foo]bar[baz]")
7507 "{foo}bar{baz}"))) 7522 "{foo}bar{baz}")))
7508 ;; Simplify test in order to speed up. 7523 ;; Simplify test in order to speed up.
7509 (apply #'tramp--test-check-files 7524 (apply #'tramp--test-check-files