diff options
| author | Michael Albinus | 2016-12-07 17:16:57 +0100 |
|---|---|---|
| committer | Michael Albinus | 2016-12-07 17:16:57 +0100 |
| commit | f41097adf3e7155f9c0db6d90de0aa1623d89232 (patch) | |
| tree | f82990e1edf2ab3071bd58f421ef9a6f283879e0 | |
| parent | 6d410fb03c53a892d2cf19238b15c5957ec1a7d8 (diff) | |
| download | emacs-f41097adf3e7155f9c0db6d90de0aa1623d89232.tar.gz emacs-f41097adf3e7155f9c0db6d90de0aa1623d89232.zip | |
Fix problems in quoting Tramp file names
* lisp/net/tramp.el (tramp-get-remote-tmpdir): Add also hop to result.
(tramp-unquote-shell-quote-argument): New defun.
(tramp-shell-quote-argument):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-make-copy-program-file-name):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory)
(tramp-smb-handle-file-acl, tramp-smb-handle-set-file-acl)
(tramp-smb-shell-quote-argument): Use it.
| -rw-r--r-- | lisp/net/tramp-sh.el | 9 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 19 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 23 |
3 files changed, 31 insertions, 20 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index c87b4068630..a2949f1f204 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2415,10 +2415,10 @@ The method used must be an out-of-band method." | |||
| 2415 | 'identity) | 2415 | 'identity) |
| 2416 | (if t1 | 2416 | (if t1 |
| 2417 | (tramp-make-copy-program-file-name v) | 2417 | (tramp-make-copy-program-file-name v) |
| 2418 | (shell-quote-argument filename))) | 2418 | (tramp-unquote-shell-quote-argument filename))) |
| 2419 | target (if t2 | 2419 | target (if t2 |
| 2420 | (tramp-make-copy-program-file-name v) | 2420 | (tramp-make-copy-program-file-name v) |
| 2421 | (shell-quote-argument newname))) | 2421 | (tramp-unquote-shell-quote-argument newname))) |
| 2422 | 2422 | ||
| 2423 | ;; Check for host and port number. We cannot use | 2423 | ;; Check for host and port number. We cannot use |
| 2424 | ;; `tramp-file-name-port', because this returns also | 2424 | ;; `tramp-file-name-port', because this returns also |
| @@ -5175,8 +5175,9 @@ Return ATTR." | |||
| 5175 | ((tramp-get-method-parameter vec 'tramp-remote-copy-program) | 5175 | ((tramp-get-method-parameter vec 'tramp-remote-copy-program) |
| 5176 | localname) | 5176 | localname) |
| 5177 | ((not (zerop (length user))) | 5177 | ((not (zerop (length user))) |
| 5178 | (shell-quote-argument (format "%s@%s:%s" user host localname))) | 5178 | (tramp-unquote-shell-quote-argument |
| 5179 | (t (shell-quote-argument (format "%s:%s" host localname)))))) | 5179 | (format "%s@%s:%s" user host localname))) |
| 5180 | (t (tramp-unquote-shell-quote-argument (format "%s:%s" host localname)))))) | ||
| 5180 | 5181 | ||
| 5181 | (defun tramp-method-out-of-band-p (vec size) | 5182 | (defun tramp-method-out-of-band-p (vec size) |
| 5182 | "Return t if this is an out-of-band method, nil otherwise." | 5183 | "Return t if this is an out-of-band method, nil otherwise." |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index e52296faaf7..d6d4669c912 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -478,15 +478,19 @@ pass to the OPERATION." | |||
| 478 | (if t1 | 478 | (if t1 |
| 479 | ;; Source is remote. | 479 | ;; Source is remote. |
| 480 | (append args | 480 | (append args |
| 481 | (list "-D" (shell-quote-argument localname) | 481 | (list "-D" (tramp-unquote-shell-quote-argument |
| 482 | localname) | ||
| 482 | "-c" (shell-quote-argument "tar qc - *") | 483 | "-c" (shell-quote-argument "tar qc - *") |
| 483 | "|" "tar" "xfC" "-" | 484 | "|" "tar" "xfC" "-" |
| 484 | (shell-quote-argument tmpdir))) | 485 | (tramp-unquote-shell-quote-argument |
| 486 | tmpdir))) | ||
| 485 | ;; Target is remote. | 487 | ;; Target is remote. |
| 486 | (append (list "tar" "cfC" "-" | 488 | (append (list "tar" "cfC" "-" |
| 487 | (shell-quote-argument dirname) "." "|") | 489 | (tramp-unquote-shell-quote-argument dirname) |
| 490 | "." "|") | ||
| 488 | args | 491 | args |
| 489 | (list "-D" (shell-quote-argument localname) | 492 | (list "-D" (tramp-unquote-shell-quote-argument |
| 493 | localname) | ||
| 490 | "-c" (shell-quote-argument "tar qx -"))))) | 494 | "-c" (shell-quote-argument "tar qx -"))))) |
| 491 | 495 | ||
| 492 | (unwind-protect | 496 | (unwind-protect |
| @@ -760,7 +764,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 760 | (setq args (append args (list "-s" tramp-smb-conf)))) | 764 | (setq args (append args (list "-s" tramp-smb-conf)))) |
| 761 | (setq | 765 | (setq |
| 762 | args | 766 | args |
| 763 | (append args (list (shell-quote-argument localname) "2>/dev/null"))) | 767 | (append args (list (tramp-unquote-shell-quote-argument localname) |
| 768 | "2>/dev/null"))) | ||
| 764 | 769 | ||
| 765 | (unwind-protect | 770 | (unwind-protect |
| 766 | (with-temp-buffer | 771 | (with-temp-buffer |
| @@ -1354,7 +1359,7 @@ target of the symlink differ." | |||
| 1354 | (setq args (append args (list "-s" tramp-smb-conf)))) | 1359 | (setq args (append args (list "-s" tramp-smb-conf)))) |
| 1355 | (setq | 1360 | (setq |
| 1356 | args | 1361 | args |
| 1357 | (append args (list (shell-quote-argument localname) | 1362 | (append args (list (tramp-unquote-shell-quote-argument localname) |
| 1358 | "&&" "echo" "tramp_exit_status" "0" | 1363 | "&&" "echo" "tramp_exit_status" "0" |
| 1359 | "||" "echo" "tramp_exit_status" "1"))) | 1364 | "||" "echo" "tramp_exit_status" "1"))) |
| 1360 | 1365 | ||
| @@ -2038,7 +2043,7 @@ Returns nil if an error message has appeared." | |||
| 2038 | (defun tramp-smb-shell-quote-argument (s) | 2043 | (defun tramp-smb-shell-quote-argument (s) |
| 2039 | "Similar to `shell-quote-argument', but uses windows cmd syntax." | 2044 | "Similar to `shell-quote-argument', but uses windows cmd syntax." |
| 2040 | (let ((system-type 'ms-dos)) | 2045 | (let ((system-type 'ms-dos)) |
| 2041 | (shell-quote-argument s))) | 2046 | (tramp-unquote-shell-quote-argument s))) |
| 2042 | 2047 | ||
| 2043 | (add-hook 'tramp-unload-hook | 2048 | (add-hook 'tramp-unload-hook |
| 2044 | (lambda () | 2049 | (lambda () |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 1eb66cf59ef..48ae6e06000 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -4033,16 +4033,17 @@ be granted." | |||
| 4033 | 4033 | ||
| 4034 | (defun tramp-get-remote-tmpdir (vec) | 4034 | (defun tramp-get-remote-tmpdir (vec) |
| 4035 | "Return directory for temporary files on the remote host identified by VEC." | 4035 | "Return directory for temporary files on the remote host identified by VEC." |
| 4036 | (let ((dir (tramp-make-tramp-file-name | 4036 | (with-tramp-connection-property vec "tmpdir" |
| 4037 | (tramp-file-name-method vec) | 4037 | (let ((dir (tramp-make-tramp-file-name |
| 4038 | (tramp-file-name-user vec) | 4038 | (tramp-file-name-method vec) |
| 4039 | (tramp-file-name-host vec) | 4039 | (tramp-file-name-user vec) |
| 4040 | (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp")))) | 4040 | (tramp-file-name-host vec) |
| 4041 | (with-tramp-connection-property vec "tmpdir" | 4041 | (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp") |
| 4042 | (tramp-file-name-hop vec)))) | ||
| 4042 | (or (and (file-directory-p dir) (file-writable-p dir) | 4043 | (or (and (file-directory-p dir) (file-writable-p dir) |
| 4043 | (file-remote-p dir 'localname)) | 4044 | (file-remote-p dir 'localname)) |
| 4044 | (tramp-error vec 'file-error "Directory %s not accessible" dir))) | 4045 | (tramp-error vec 'file-error "Directory %s not accessible" dir)) |
| 4045 | dir)) | 4046 | dir))) |
| 4046 | 4047 | ||
| 4047 | ;;;###tramp-autoload | 4048 | ;;;###tramp-autoload |
| 4048 | (defun tramp-make-tramp-temp-file (vec) | 4049 | (defun tramp-make-tramp-temp-file (vec) |
| @@ -4304,6 +4305,10 @@ T1 and T2 are time values (as returned by `current-time' for example)." | |||
| 4304 | ;; Starting with Emacs 25.1, we could change this to use `time-subtract'. | 4305 | ;; Starting with Emacs 25.1, we could change this to use `time-subtract'. |
| 4305 | (float-time (tramp-compat-funcall 'subtract-time t1 t2))) | 4306 | (float-time (tramp-compat-funcall 'subtract-time t1 t2))) |
| 4306 | 4307 | ||
| 4308 | (defun tramp-unquote-shell-quote-argument (s) | ||
| 4309 | "Remove quotation prefix \"/:\" from string S, and quote it then for shell." | ||
| 4310 | (shell-quote-argument (tramp-unquote-name s))) | ||
| 4311 | |||
| 4307 | ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | 4312 | ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' |
| 4308 | ;; does not deal well with newline characters. Newline is replaced by | 4313 | ;; does not deal well with newline characters. Newline is replaced by |
| 4309 | ;; backslash newline. But if, say, the string `a backslash newline b' | 4314 | ;; backslash newline. But if, say, the string `a backslash newline b' |
| @@ -4335,7 +4340,7 @@ T1 and T2 are time values (as returned by `current-time' for example)." | |||
| 4335 | Only works for Bourne-like shells." | 4340 | Only works for Bourne-like shells." |
| 4336 | (let ((system-type 'not-windows)) | 4341 | (let ((system-type 'not-windows)) |
| 4337 | (save-match-data | 4342 | (save-match-data |
| 4338 | (let ((result (shell-quote-argument (tramp-unquote-name s))) | 4343 | (let ((result (tramp-unquote-shell-quote-argument s)) |
| 4339 | (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | 4344 | (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) |
| 4340 | (when (and (>= (length result) 2) | 4345 | (when (and (>= (length result) 2) |
| 4341 | (string= (substring result 0 2) "\\~")) | 4346 | (string= (substring result 0 2) "\\~")) |