diff options
| author | Michael Albinus | 2021-05-06 17:15:30 +0200 |
|---|---|---|
| committer | Michael Albinus | 2021-05-06 17:15:30 +0200 |
| commit | b6f5da3240170fb9750a3304e4b8fa04fe7f2268 (patch) | |
| tree | a73491c1a2393290bbdc7433f746f8a185cc6d4b | |
| parent | 7f317868c5a1be8dd591cd26815e2b34896d31f0 (diff) | |
| download | emacs-b6f5da3240170fb9750a3304e4b8fa04fe7f2268.tar.gz emacs-b6f5da3240170fb9750a3304e4b8fa04fe7f2268.zip | |
In Tramp, use scp "-T" argument if available
* lisp/net/tramp-sh.el (tramp-scp-strict-file-name-checking): New defvar.
(tramp-scp-strict-file-name-checking): New defun.
(tramp-do-copy-or-rename-file-out-of-band): Use it.
(tramp-methods) <scp, scpx>: Use "%x".
(tramp-make-copy-program-file-name): Use local quoting.
(tramp-sh-handle-make-process): Don't call
`tramp-maybe-open-connection', this happens implicitly by
`tramp-send-command'.
* lisp/net/tramp.el (tramp-methods): Adapt docstring.
* test/lisp/net/tramp-tests.el (tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls): Don't skip for
`tramp--test-windows-nt-and-scp-p'.
| -rw-r--r-- | lisp/net/tramp-sh.el | 57 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 2 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 8 |
3 files changed, 50 insertions, 17 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index b51ba11247f..57be9ecf006 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -125,6 +125,15 @@ depends on the installed local ssh version. | |||
| 125 | 125 | ||
| 126 | The string is used in `tramp-methods'.") | 126 | The string is used in `tramp-methods'.") |
| 127 | 127 | ||
| 128 | (defvar tramp-scp-strict-file-name-checking nil | ||
| 129 | "Which scp strict file name checking argument to use. | ||
| 130 | |||
| 131 | It is the string \"-T\" if supported by the local scp (since | ||
| 132 | release 8.0), otherwise the string \"\". If it is nil, it will | ||
| 133 | be auto-detected by Tramp. | ||
| 134 | |||
| 135 | The string is used in `tramp-methods'.") | ||
| 136 | |||
| 128 | ;; Initialize `tramp-methods' with the supported methods. | 137 | ;; Initialize `tramp-methods' with the supported methods. |
| 129 | ;;;###tramp-autoload | 138 | ;;;###tramp-autoload |
| 130 | (tramp--with-startup | 139 | (tramp--with-startup |
| @@ -160,8 +169,8 @@ The string is used in `tramp-methods'.") | |||
| 160 | (tramp-remote-shell-login ("-l")) | 169 | (tramp-remote-shell-login ("-l")) |
| 161 | (tramp-remote-shell-args ("-c")) | 170 | (tramp-remote-shell-args ("-c")) |
| 162 | (tramp-copy-program "scp") | 171 | (tramp-copy-program "scp") |
| 163 | (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q") | 172 | (tramp-copy-args (("-P" "%p") ("-p" "%k") |
| 164 | ("-r") ("%c"))) | 173 | ("%x") ("-q") ("-r") ("%c"))) |
| 165 | (tramp-copy-keep-date t) | 174 | (tramp-copy-keep-date t) |
| 166 | (tramp-copy-recursive t))) | 175 | (tramp-copy-recursive t))) |
| 167 | (add-to-list 'tramp-methods | 176 | (add-to-list 'tramp-methods |
| @@ -177,7 +186,7 @@ The string is used in `tramp-methods'.") | |||
| 177 | (tramp-remote-shell-args ("-c")) | 186 | (tramp-remote-shell-args ("-c")) |
| 178 | (tramp-copy-program "scp") | 187 | (tramp-copy-program "scp") |
| 179 | (tramp-copy-args (("-P" "%p") ("-p" "%k") | 188 | (tramp-copy-args (("-P" "%p") ("-p" "%k") |
| 180 | ("-q") ("-r") ("%c"))) | 189 | ("%x") ("-q") ("-r") ("%c"))) |
| 181 | (tramp-copy-keep-date t) | 190 | (tramp-copy-keep-date t) |
| 182 | (tramp-copy-recursive t))) | 191 | (tramp-copy-recursive t))) |
| 183 | (add-to-list 'tramp-methods | 192 | (add-to-list 'tramp-methods |
| @@ -2279,7 +2288,8 @@ The method used must be an out-of-band method." | |||
| 2279 | spec (list | 2288 | spec (list |
| 2280 | ?h (or host "") ?u (or user "") ?p (or port "") | 2289 | ?h (or host "") ?u (or user "") ?p (or port "") |
| 2281 | ?r listener ?c options ?k (if keep-date " " "") | 2290 | ?r listener ?c options ?k (if keep-date " " "") |
| 2282 | ?n (concat "2>" (tramp-get-remote-null-device v))) | 2291 | ?n (concat "2>" (tramp-get-remote-null-device v)) |
| 2292 | ?x (tramp-scp-strict-file-name-checking v)) | ||
| 2283 | copy-program (tramp-get-method-parameter v 'tramp-copy-program) | 2293 | copy-program (tramp-get-method-parameter v 'tramp-copy-program) |
| 2284 | copy-keep-date (tramp-get-method-parameter | 2294 | copy-keep-date (tramp-get-method-parameter |
| 2285 | v 'tramp-copy-keep-date) | 2295 | v 'tramp-copy-keep-date) |
| @@ -2867,14 +2877,11 @@ alternative implementation will be used." | |||
| 2867 | (if (symbolp coding) coding (cdr coding)))) | 2877 | (if (symbolp coding) coding (cdr coding)))) |
| 2868 | (clear-visited-file-modtime) | 2878 | (clear-visited-file-modtime) |
| 2869 | (narrow-to-region (point-max) (point-max)) | 2879 | (narrow-to-region (point-max) (point-max)) |
| 2870 | ;; We call `tramp-maybe-open-connection', in | ||
| 2871 | ;; order to cleanup the prompt afterwards. | ||
| 2872 | (catch 'suppress | 2880 | (catch 'suppress |
| 2873 | (tramp-maybe-open-connection v) | ||
| 2874 | (setq p (tramp-get-connection-process v)) | ||
| 2875 | ;; Set the pid of the remote shell. This is | 2881 | ;; Set the pid of the remote shell. This is |
| 2876 | ;; needed when sending signals remotely. | 2882 | ;; needed when sending signals remotely. |
| 2877 | (let ((pid (tramp-send-command-and-read v "echo $$"))) | 2883 | (let ((pid (tramp-send-command-and-read v "echo $$"))) |
| 2884 | (setq p (tramp-get-connection-process v)) | ||
| 2878 | (process-put p 'remote-pid pid) | 2885 | (process-put p 'remote-pid pid) |
| 2879 | (tramp-set-connection-property p "remote-pid" pid)) | 2886 | (tramp-set-connection-property p "remote-pid" pid)) |
| 2880 | ;; `tramp-maybe-open-connection' and | 2887 | ;; `tramp-maybe-open-connection' and |
| @@ -4737,6 +4744,31 @@ Goes through the list `tramp-inline-compress-commands'." | |||
| 4737 | " -o ControlPersist=no"))))))))) | 4744 | " -o ControlPersist=no"))))))))) |
| 4738 | tramp-ssh-controlmaster-options))) | 4745 | tramp-ssh-controlmaster-options))) |
| 4739 | 4746 | ||
| 4747 | (defun tramp-scp-strict-file-name-checking (vec) | ||
| 4748 | "Return the strict file name checking argument of the local scp." | ||
| 4749 | (cond | ||
| 4750 | ;; No options to be computed. | ||
| 4751 | ((null (assoc "%x" (tramp-get-method-parameter vec 'tramp-copy-args))) | ||
| 4752 | "") | ||
| 4753 | |||
| 4754 | ;; There is already a value to be used. | ||
| 4755 | ((stringp tramp-scp-strict-file-name-checking) | ||
| 4756 | tramp-scp-strict-file-name-checking) | ||
| 4757 | |||
| 4758 | ;; Determine the options. | ||
| 4759 | (t (setq tramp-scp-strict-file-name-checking "") | ||
| 4760 | (let ((case-fold-search t)) | ||
| 4761 | (ignore-errors | ||
| 4762 | (when (executable-find "scp") | ||
| 4763 | (with-tramp-progress-reporter | ||
| 4764 | vec 4 "Computing strict file name argument" | ||
| 4765 | (with-temp-buffer | ||
| 4766 | (tramp-call-process vec "scp" nil t nil "-T") | ||
| 4767 | (goto-char (point-min)) | ||
| 4768 | (unless (search-forward-regexp "unknown option -- T" nil t) | ||
| 4769 | (setq tramp-scp-strict-file-name-checking "-T"))))))) | ||
| 4770 | tramp-scp-strict-file-name-checking))) | ||
| 4771 | |||
| 4740 | (defun tramp-timeout-session (vec) | 4772 | (defun tramp-timeout-session (vec) |
| 4741 | "Close the connection VEC after a session timeout. | 4773 | "Close the connection VEC after a session timeout. |
| 4742 | If there is just some editing, retry it after 5 seconds." | 4774 | If there is just some editing, retry it after 5 seconds." |
| @@ -5229,12 +5261,11 @@ Return ATTR." | |||
| 5229 | (directory-file-name (tramp-file-name-unquote-localname vec)))) | 5261 | (directory-file-name (tramp-file-name-unquote-localname vec)))) |
| 5230 | (when (string-match-p tramp-ipv6-regexp host) | 5262 | (when (string-match-p tramp-ipv6-regexp host) |
| 5231 | (setq host (format "[%s]" host))) | 5263 | (setq host (format "[%s]" host))) |
| 5232 | ;; This does not work yet for MS Windows scp, if there are | 5264 | ;; This does not work for MS Windows scp, if there are characters |
| 5233 | ;; characters to be quoted. Win32 OpenSSH 7.9 is said to support | 5265 | ;; to be quoted. OpenSSH 8 supports disabling of strict file name |
| 5234 | ;; this, see | 5266 | ;; checking in scp, we use it when available. |
| 5235 | ;; <https://github.com/PowerShell/Win32-OpenSSH/releases/tag/v7.9.0.0p1-Beta> | ||
| 5236 | (unless (string-match-p "ftp$" method) | 5267 | (unless (string-match-p "ftp$" method) |
| 5237 | (setq localname (tramp-shell-quote-argument localname))) | 5268 | (setq localname (shell-quote-argument localname))) |
| 5238 | (cond | 5269 | (cond |
| 5239 | ((tramp-get-method-parameter vec 'tramp-remote-copy-program) | 5270 | ((tramp-get-method-parameter vec 'tramp-remote-copy-program) |
| 5240 | localname) | 5271 | localname) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 015f458a63c..741ea05ceaf 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -252,6 +252,8 @@ pair of the form (KEY VALUE). The following KEYs are defined: | |||
| 252 | - \"%c\" adds additional `tramp-ssh-controlmaster-options' | 252 | - \"%c\" adds additional `tramp-ssh-controlmaster-options' |
| 253 | options for the first hop. | 253 | options for the first hop. |
| 254 | - \"%n\" expands to \"2>/dev/null\". | 254 | - \"%n\" expands to \"2>/dev/null\". |
| 255 | - \"%x\" is replaced by the `tramp-scp-strict-file-name-checking' | ||
| 256 | argument if it is supported. | ||
| 255 | 257 | ||
| 256 | The existence of `tramp-login-args', combined with the | 258 | The existence of `tramp-login-args', combined with the |
| 257 | absence of `tramp-copy-args', is an indication that the | 259 | absence of `tramp-copy-args', is an indication that the |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 1eb0d0ec619..3a199469d6b 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -6114,7 +6114,7 @@ This requires restrictions of file name syntax." | |||
| 6114 | "Check special characters in file names." | 6114 | "Check special characters in file names." |
| 6115 | (skip-unless (tramp--test-enabled)) | 6115 | (skip-unless (tramp--test-enabled)) |
| 6116 | (skip-unless (not (tramp--test-rsync-p))) | 6116 | (skip-unless (not (tramp--test-rsync-p))) |
| 6117 | (skip-unless (not (tramp--test-windows-nt-and-scp-p))) | 6117 | ; (skip-unless (not (tramp--test-windows-nt-and-scp-p))) |
| 6118 | (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) | 6118 | (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) |
| 6119 | 6119 | ||
| 6120 | (tramp--test-special-characters)) | 6120 | (tramp--test-special-characters)) |
| @@ -6126,7 +6126,7 @@ Use the `stat' command." | |||
| 6126 | (skip-unless (tramp--test-enabled)) | 6126 | (skip-unless (tramp--test-enabled)) |
| 6127 | (skip-unless (tramp--test-sh-p)) | 6127 | (skip-unless (tramp--test-sh-p)) |
| 6128 | (skip-unless (not (tramp--test-rsync-p))) | 6128 | (skip-unless (not (tramp--test-rsync-p))) |
| 6129 | (skip-unless (not (tramp--test-windows-nt-and-scp-p))) | 6129 | ; (skip-unless (not (tramp--test-windows-nt-and-scp-p))) |
| 6130 | ;; We cannot use `tramp-test-vec', because this fails during compilation. | 6130 | ;; We cannot use `tramp-test-vec', because this fails during compilation. |
| 6131 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil | 6131 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil |
| 6132 | (skip-unless (tramp-get-remote-stat v))) | 6132 | (skip-unless (tramp-get-remote-stat v))) |
| @@ -6145,7 +6145,7 @@ Use the `perl' command." | |||
| 6145 | (skip-unless (tramp--test-enabled)) | 6145 | (skip-unless (tramp--test-enabled)) |
| 6146 | (skip-unless (tramp--test-sh-p)) | 6146 | (skip-unless (tramp--test-sh-p)) |
| 6147 | (skip-unless (not (tramp--test-rsync-p))) | 6147 | (skip-unless (not (tramp--test-rsync-p))) |
| 6148 | (skip-unless (not (tramp--test-windows-nt-and-scp-p))) | 6148 | ; (skip-unless (not (tramp--test-windows-nt-and-scp-p))) |
| 6149 | ;; We cannot use `tramp-test-vec', because this fails during compilation. | 6149 | ;; We cannot use `tramp-test-vec', because this fails during compilation. |
| 6150 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil | 6150 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil |
| 6151 | (skip-unless (tramp-get-remote-perl v))) | 6151 | (skip-unless (tramp-get-remote-perl v))) |
| @@ -6167,7 +6167,7 @@ Use the `ls' command." | |||
| 6167 | (skip-unless (tramp--test-enabled)) | 6167 | (skip-unless (tramp--test-enabled)) |
| 6168 | (skip-unless (tramp--test-sh-p)) | 6168 | (skip-unless (tramp--test-sh-p)) |
| 6169 | (skip-unless (not (tramp--test-rsync-p))) | 6169 | (skip-unless (not (tramp--test-rsync-p))) |
| 6170 | (skip-unless (not (tramp--test-windows-nt-and-scp-p))) | 6170 | ; (skip-unless (not (tramp--test-windows-nt-and-scp-p))) |
| 6171 | 6171 | ||
| 6172 | (let ((tramp-connection-properties | 6172 | (let ((tramp-connection-properties |
| 6173 | (append | 6173 | (append |