Commit fb39d31e authored by Michael Albinus's avatar Michael Albinus
Browse files

Fix quoting problem in Tramp on w32 systems

* lisp/net/tramp-adb.el (tramp-adb-connection-local-default-profile):
* lisp/net/tramp-integration.el (tramp-connection-local-default-profile):
Revert patch from 2019-05-24.  It is fixed differently.

* lisp/net/tramp.el (tramp-encoding-shell):
(tramp-encoding-command-switch)
(tramp-encoding-command-interactive, )
(tramp-unquote-shell-quote-argument): Suppress `shell-file-name'.
(tramp-set-file-uid-gid):
* lisp/net/tramp-sh.el (tramp-find-inline-compress)
(tramp-make-copy-program-file-name):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
Use `tramp-unquote-shell-quote-argument'.
parent f2e4c34d
......@@ -1294,11 +1294,8 @@ connection if a previous connection has died for some reason."
;; Default settings for connection-local variables.
(defconst tramp-adb-connection-local-default-profile
;; `w32-shell-name' is derived from `shell-file-name'. Don't let it
;; be confused.
(unless (eq system-type 'windows-nt)
'((shell-file-name . "/system/bin/sh")
(shell-command-switch . "-c")))
'((shell-file-name . "/system/bin/sh")
(shell-command-switch . "-c"))
"Default connection-local variables for remote adb connections.")
;; `connection-local-set-profile-variables' and
......
......@@ -174,11 +174,8 @@ NAME must be equal to `tramp-current-connection'."
;;; Default connection-local variables for Tramp:
(defconst tramp-connection-local-default-profile
;; `w32-shell-name' is derived from `shell-file-name'. Don't let it
;; be confused.
(unless (eq system-type 'windows-nt)
'((shell-file-name . "/bin/sh")
(shell-command-switch . "-c")))
'((shell-file-name . "/bin/sh")
(shell-command-switch . "-c"))
"Default connection-local variables for remote connections.")
;; `connection-local-set-profile-variables' and
......
......@@ -4578,9 +4578,11 @@ Goes through the list `tramp-inline-compress-commands'."
;; the pipe symbol be quoted if they use forward
;; slashes as directory separators.
(mapconcat
#'shell-quote-argument (split-string compress) " ")
#'tramp-unquote-shell-quote-argument
(split-string compress) " ")
(mapconcat
#'shell-quote-argument (split-string decompress) " "))
#'tramp-unquote-shell-quote-argument
(split-string decompress) " "))
nil nil))
(throw 'next nil))
(tramp-message
......@@ -5282,8 +5284,9 @@ Return ATTR."
((tramp-get-method-parameter vec 'tramp-remote-copy-program)
localname)
((not (zerop (length user)))
(format "%s@%s:%s" user host (shell-quote-argument localname)))
(t (format "%s:%s" host (shell-quote-argument localname))))))
(format
"%s@%s:%s" user host (tramp-unquote-shell-quote-argument localname)))
(t (format "%s:%s" host (tramp-unquote-shell-quote-argument localname))))))
(defun tramp-method-out-of-band-p (vec size)
"Return t if this is an out-of-band method, nil otherwise."
......
......@@ -468,7 +468,8 @@ pass to the OPERATION."
(append args
(list "-D" (tramp-unquote-shell-quote-argument
localname)
"-c" (shell-quote-argument "tar qc - *")
"-c" (tramp-unquote-shell-quote-argument
"tar qc - *")
"|" "tar" "xfC" "-"
(tramp-unquote-shell-quote-argument
tmpdir)))
......@@ -479,7 +480,8 @@ pass to the OPERATION."
args
(list "-D" (tramp-unquote-shell-quote-argument
localname)
"-c" (shell-quote-argument "tar qx -")))))
"-c" (tramp-unquote-shell-quote-argument
"tar qx -")))))
(unwind-protect
(with-temp-buffer
......
......@@ -135,8 +135,10 @@ This setting has precedence over `auto-save-file-name-transforms'."
:type '(choice (const :tag "Use default" nil)
(directory :tag "Auto save directory name")))
;; Suppress `shell-file-name' for w32 systems.
(defcustom tramp-encoding-shell
(or (tramp-compat-funcall 'w32-shell-name) "/bin/sh")
(let (shell-file-name)
(or (tramp-compat-funcall 'w32-shell-name) "/bin/sh"))
"Use this program for encoding and decoding commands on the local host.
This shell is used to execute the encoding and decoding command on the
local host, so if you want to use `~' in those commands, you should
......@@ -159,15 +161,19 @@ use for the remote host."
:group 'tramp
:type '(file :must-match t))
;; Suppress `shell-file-name' for w32 systems.
(defcustom tramp-encoding-command-switch
(if (tramp-compat-funcall 'w32-shell-dos-semantics) "/c" "-c")
(let (shell-file-name)
(if (tramp-compat-funcall 'w32-shell-dos-semantics) "/c" "-c"))
"Use this switch together with `tramp-encoding-shell' for local commands.
See the variable `tramp-encoding-shell' for more information."
:group 'tramp
:type 'string)
;; Suppress `shell-file-name' for w32 systems.
(defcustom tramp-encoding-command-interactive
(unless (tramp-compat-funcall 'w32-shell-dos-semantics) "-i")
(let (shell-file-name)
(unless (tramp-compat-funcall 'w32-shell-dos-semantics) "-i"))
"Use this switch together with `tramp-encoding-shell' for interactive shells.
See the variable `tramp-encoding-shell' for more information."
:version "24.1"
......@@ -4391,13 +4397,13 @@ If FILENAME is remote, a file name handler is called."
(let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid)))
(if handler
(funcall handler #'tramp-set-file-uid-gid filename uid gid)
;; On W32 "chown" does not work.
;; On W32 systems, "chown" does not work.
(unless (memq system-type '(ms-dos windows-nt))
(let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
(gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
(tramp-call-process
nil "chown" nil nil nil
(format "%d:%d" uid gid) (shell-quote-argument filename)))))))
nil "chown" nil nil nil (format "%d:%d" uid gid)
(tramp-unquote-shell-quote-argument filename)))))))
(defun tramp-get-local-uid (id-format)
"The uid of the local user, in ID-FORMAT.
......@@ -4815,8 +4821,11 @@ T1 and T2 are time values (as returned by `current-time' for example)."
(float-time (time-subtract t1 t2)))
(defun tramp-unquote-shell-quote-argument (s)
"Remove quotation prefix \"/:\" from string S, and quote it then for shell."
(shell-quote-argument (tramp-compat-file-name-unquote s)))
"Remove quotation prefix \"/:\" from string S, and quote it then for shell.
Suppress `shell-file-name'. This is needed on w32 systems, which
would use a wrong quoting for local file names. See `w32-shell-name'."
(let (shell-file-name)
(shell-quote-argument (tramp-compat-file-name-unquote s))))
;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
;; does not deal well with newline characters. Newline is replaced by
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment