Fix tramp-compat-temporary-file-directory implementation
* lisp/net/tramp-archive.el (tramp-archive-handle-temporary-file-directory): Use `tramp-compat-temporary-file-directory-function'. * lisp/net/tramp-compat.el (tramp-compat-temporary-file-directory): Make it a defconst. * lisp/net/tramp.el (tramp-get-debug-buffer, tramp-get-debug-file-name) (tramp-debug-message, tramp-file-name-handler, tramp-parse-file) (tramp-parse-shostkeys-sknownhosts) (tramp-handle-expand-file-name, tramp-handle-make-process) (tramp-local-host-p, tramp-call-process) (tramp-call-process-region, tramp-process-lines) (tramp-read-passwd): * lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection): * lisp/net/tramp-compat.el (tramp-compat-make-temp-name) (tramp-compat-make-temp-file); * lisp/net/tramp-crypt.el (tramp-crypt-file-name-for-operation) (tramp-crypt-maybe-open-connection, tramp-crypt-send-command) (tramp-crypt-do-encrypt-or-decrypt-file-name): * lisp/net/tramp-fuse.el (tramp-fuse-mount-point, tramp-fuse-mounted-p) (tramp-fuse-unmount): * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-expand-file-name) (tramp-sh-handle-file-local-copy, ) (tramp-sh-handle-write-region, tramp-maybe-open-connection): * lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection): Use it.
This commit is contained in:
parent
b2bb717d4b
commit
2e5752cf98
8 changed files with 38 additions and 39 deletions
|
@ -1273,7 +1273,7 @@ connection if a previous connection has died for some reason."
|
|||
(list "-s" device "shell")
|
||||
(list "shell")))
|
||||
(p (let ((default-directory
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
tramp-compat-temporary-file-directory))
|
||||
(apply #'start-process (tramp-get-connection-name vec) buf
|
||||
tramp-adb-program args)))
|
||||
(prompt (md5 (concat (prin1-to-string process-environment)
|
||||
|
|
|
@ -658,7 +658,7 @@ offered."
|
|||
;; mounted directory, it is returned as it. Not what we want.
|
||||
(with-parsed-tramp-archive-file-name default-directory nil
|
||||
(let ((default-directory (file-name-directory archive)))
|
||||
(tramp-compat-temporary-file-directory))))
|
||||
(tramp-compat-temporary-file-directory-function))))
|
||||
|
||||
(defun tramp-archive-handle-not-implemented (operation &rest args)
|
||||
"Generic handler for operations not implemented for file archives."
|
||||
|
|
|
@ -63,25 +63,24 @@
|
|||
`(when (functionp ,function)
|
||||
(with-no-warnings (funcall ,function ,@arguments))))
|
||||
|
||||
(defsubst tramp-compat-temporary-file-directory ()
|
||||
"Return name of directory for temporary files.
|
||||
It is the default value of `temporary-file-directory'."
|
||||
;; We must return a local directory. If it is remote, we could run
|
||||
;; into an infloop.
|
||||
(eval (car (get 'temporary-file-directory 'standard-value)) t))
|
||||
;; We must use a local directory. If it is remote, we could run into
|
||||
;; an infloop.
|
||||
(defconst tramp-compat-temporary-file-directory
|
||||
(eval (car (get 'temporary-file-directory 'standard-value)) t)
|
||||
"The default value of `temporary-file-directory'.")
|
||||
|
||||
(defsubst tramp-compat-make-temp-name ()
|
||||
"Generate a local temporary file name (compat function)."
|
||||
(make-temp-name
|
||||
(expand-file-name
|
||||
tramp-temp-name-prefix (tramp-compat-temporary-file-directory))))
|
||||
tramp-temp-name-prefix tramp-compat-temporary-file-directory)))
|
||||
|
||||
(defsubst tramp-compat-make-temp-file (f &optional dir-flag)
|
||||
"Create a local temporary file (compat function).
|
||||
Add the extension of F, if existing."
|
||||
(make-temp-file
|
||||
(expand-file-name
|
||||
tramp-temp-name-prefix (tramp-compat-temporary-file-directory))
|
||||
tramp-temp-name-prefix tramp-compat-temporary-file-directory)
|
||||
dir-flag (file-name-extension f t)))
|
||||
|
||||
;; `temporary-file-directory' as function is introduced with Emacs 26.1.
|
||||
|
|
|
@ -247,7 +247,7 @@ Operations not mentioned here will be handled by the default Emacs primitives.")
|
|||
(unless (tramp-crypt-file-name-p tfnfo)
|
||||
(setq tfnfo (apply
|
||||
#'tramp-file-name-for-operation operation
|
||||
(cons (tramp-compat-temporary-file-directory) (cdr args)))))
|
||||
(cons tramp-compat-temporary-file-directory (cdr args)))))
|
||||
tfnfo))
|
||||
|
||||
(defun tramp-crypt-run-real-handler (operation args)
|
||||
|
@ -329,7 +329,7 @@ connection if a previous connection has died for some reason."
|
|||
(copy-file remote-config local-config 'ok 'keep)
|
||||
|
||||
;; Create local encfs6 config file otherwise.
|
||||
(let* ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let* ((default-directory tramp-compat-temporary-file-directory)
|
||||
(tmpdir1 (file-name-as-directory
|
||||
(tramp-compat-make-temp-file " .crypt" 'dir-flag)))
|
||||
(tmpdir2 (file-name-as-directory
|
||||
|
@ -383,7 +383,7 @@ ARGS are the arguments. It returns t if ran successful, and nil otherwise."
|
|||
(with-temp-buffer
|
||||
(let* (;; Don't check for a proper method.
|
||||
(non-essential t)
|
||||
(default-directory (tramp-compat-temporary-file-directory))
|
||||
(default-directory tramp-compat-temporary-file-directory)
|
||||
;; We cannot add it to `process-environment', because
|
||||
;; `tramp-call-process-region' doesn't use it.
|
||||
(encfs-config
|
||||
|
@ -427,7 +427,7 @@ Otherwise, return NAME."
|
|||
crypt-vec localname (concat (symbol-name op) "-file-name")
|
||||
(unless (tramp-crypt-send-command
|
||||
crypt-vec (if (eq op 'encrypt) "encode" "decode")
|
||||
(tramp-compat-temporary-file-directory) localname)
|
||||
tramp-compat-temporary-file-directory localname)
|
||||
(tramp-error
|
||||
crypt-vec 'file-error "%s of file name %s failed."
|
||||
(if (eq op 'encrypt) "Encoding" "Decoding") name))
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
(when (tramp-file-name-user vec)
|
||||
(concat (tramp-file-name-user-domain vec) "@"))
|
||||
(tramp-file-name-host-port vec))
|
||||
(tramp-compat-temporary-file-directory))))
|
||||
tramp-compat-temporary-file-directory)))
|
||||
|
||||
(defun tramp-fuse-mounted-p (vec)
|
||||
"Check, whether fuse volume determined by VEC is mounted."
|
||||
|
@ -163,7 +163,7 @@
|
|||
;; to cache a nil result.
|
||||
(or (tramp-get-connection-property
|
||||
(tramp-get-connection-process vec) "mounted" nil)
|
||||
(let* ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let* ((default-directory tramp-compat-temporary-file-directory)
|
||||
(command (format "mount -t fuse.%s" (tramp-file-name-method vec)))
|
||||
(mount (shell-command-to-string command)))
|
||||
(tramp-message vec 6 "%s\n%s" command mount)
|
||||
|
@ -177,7 +177,7 @@
|
|||
|
||||
(defun tramp-fuse-unmount (vec)
|
||||
"Unmount fuse volume determined by VEC."
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(command (format "fusermount3 -u %s" (tramp-fuse-mount-point vec))))
|
||||
(tramp-message vec 6 "%s\n%s" command (shell-command-to-string command))
|
||||
(tramp-flush-connection-property
|
||||
|
|
|
@ -2391,7 +2391,7 @@ The method used must be an out-of-band method."
|
|||
;; can be handled. We don't set a timeout, because
|
||||
;; the copying of large files can last longer than 60
|
||||
;; secs.
|
||||
p (let ((default-directory (tramp-compat-temporary-file-directory)))
|
||||
p (let ((default-directory tramp-compat-temporary-file-directory))
|
||||
(apply
|
||||
#'start-process
|
||||
(tramp-get-connection-name v)
|
||||
|
@ -2740,7 +2740,7 @@ the result will be a local, non-Tramp, file name."
|
|||
;; `expand-file-name' (this does "/./" and "/../").
|
||||
;; `default-directory' is bound, because on Windows there
|
||||
;; would be problems with UNC shares or Cygwin mounts.
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory)))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory))
|
||||
(tramp-make-tramp-file-name
|
||||
v (tramp-drop-volume-letter
|
||||
(tramp-run-real-handler
|
||||
|
@ -3221,7 +3221,7 @@ implementation will be used."
|
|||
(let (file-name-handler-alist
|
||||
(coding-system-for-write 'binary)
|
||||
(default-directory
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
tramp-compat-temporary-file-directory))
|
||||
(with-temp-file tmpfile
|
||||
(set-buffer-multibyte nil)
|
||||
(insert-buffer-substring (tramp-get-buffer v))
|
||||
|
@ -3314,8 +3314,7 @@ implementation will be used."
|
|||
;; we use it always because this makes the logic
|
||||
;; simpler. We must also set `temporary-file-directory',
|
||||
;; because it could point to a remote directory.
|
||||
(temporary-file-directory
|
||||
(tramp-compat-temporary-file-directory))
|
||||
(temporary-file-directory tramp-compat-temporary-file-directory)
|
||||
(tmpfile (or tramp-temp-buffer-file-name
|
||||
(tramp-compat-make-temp-file filename))))
|
||||
|
||||
|
@ -3408,7 +3407,7 @@ implementation will be used."
|
|||
;; question is a tmp file anyway.
|
||||
(let ((coding-system-for-read 'binary)
|
||||
(default-directory
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
tramp-compat-temporary-file-directory))
|
||||
(insert-file-contents-literally tmpfile)
|
||||
(funcall loc-enc (point-min) (point-max)))
|
||||
|
||||
|
@ -4919,7 +4918,7 @@ connection if a previous connection has died for some reason."
|
|||
;; This must be done in order to avoid our file
|
||||
;; name handler.
|
||||
(p (let ((default-directory
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
tramp-compat-temporary-file-directory))
|
||||
(apply
|
||||
#'start-process
|
||||
(tramp-get-connection-name vec)
|
||||
|
|
|
@ -1962,7 +1962,7 @@ If ARGUMENT is non-nil, use it as argument for
|
|||
;; Otherwise, we must delete the connection cache, because
|
||||
;; capabilities might have changed.
|
||||
(unless (or argument (processp p))
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(command (concat tramp-smb-program " -V")))
|
||||
|
||||
(unless tramp-smb-version
|
||||
|
@ -2049,7 +2049,7 @@ If ARGUMENT is non-nil, use it as argument for
|
|||
(let* ((coding-system-for-read nil)
|
||||
(process-connection-type tramp-process-connection-type)
|
||||
(p (let ((default-directory
|
||||
(tramp-compat-temporary-file-directory))
|
||||
tramp-compat-temporary-file-directory)
|
||||
(process-environment
|
||||
(cons (concat "TERM=" tramp-terminal-type)
|
||||
process-environment)))
|
||||
|
|
|
@ -1899,7 +1899,7 @@ The outline level is equal to the verbosity of the Tramp message."
|
|||
;; `(custom-declare-variable outline-minor-mode-prefix ...)'
|
||||
;; raises on error in `(outline-mode)', we don't want to see it
|
||||
;; in the traces.
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory)))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory))
|
||||
(outline-mode))
|
||||
(setq-local outline-level 'tramp-debug-outline-level)
|
||||
(setq-local font-lock-keywords
|
||||
|
@ -1918,7 +1918,7 @@ The outline level is equal to the verbosity of the Tramp message."
|
|||
"Get the debug file name for VEC."
|
||||
(expand-file-name
|
||||
(tramp-compat-string-replace "/" " " (tramp-debug-buffer-name vec))
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
tramp-compat-temporary-file-directory))
|
||||
|
||||
(put #'tramp-get-debug-file-name 'tramp-suppress-trace t)
|
||||
|
||||
|
@ -1960,7 +1960,8 @@ ARGUMENTS to actually emit the message (if applicable)."
|
|||
(dolist
|
||||
(elt
|
||||
(append
|
||||
(mapcar #'intern (all-completions "tramp-" obarray 'functionp))
|
||||
(mapcar
|
||||
#'intern (all-completions "tramp-" obarray #'functionp))
|
||||
tramp-trace-functions))
|
||||
(unless (get elt 'tramp-suppress-trace)
|
||||
(trace-function-background elt))))
|
||||
|
@ -2586,7 +2587,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
|
|||
;; the bug#9114 for which it was added doesn't
|
||||
;; clarify the core of the problem.
|
||||
(let ((default-directory
|
||||
(tramp-compat-temporary-file-directory))
|
||||
tramp-compat-temporary-file-directory)
|
||||
file-name-handler-alist)
|
||||
(autoload-do-load sf foreign)))
|
||||
;; (tramp-message
|
||||
|
@ -3090,7 +3091,7 @@ User is always nil."
|
|||
User is always nil."
|
||||
;; On Windows, there are problems in completion when
|
||||
;; `default-directory' is remote.
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory)))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory))
|
||||
(when (file-readable-p filename)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents-literally filename)
|
||||
|
@ -3144,7 +3145,7 @@ User is always nil."
|
|||
User is always nil."
|
||||
;; On Windows, there are problems in completion when
|
||||
;; `default-directory' is remote.
|
||||
(let* ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let* ((default-directory tramp-compat-temporary-file-directory)
|
||||
(files (and (file-directory-p dirname) (directory-files dirname))))
|
||||
(cl-loop
|
||||
for f in files
|
||||
|
@ -3378,7 +3379,7 @@ User is always nil."
|
|||
;; Do normal `expand-file-name' (this does "/./" and "/../").
|
||||
;; `default-directory' is bound, because on Windows there would
|
||||
;; be problems with UNC shares or Cygwin mounts.
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory)))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory))
|
||||
(tramp-make-tramp-file-name
|
||||
v (tramp-drop-volume-letter
|
||||
(tramp-run-real-handler #'expand-file-name (list localname))))))))
|
||||
|
@ -4103,7 +4104,7 @@ substitution. SPEC-LIST is a list of char/value pairs used for
|
|||
"An alternative `make-process' implementation for Tramp files."
|
||||
(when args
|
||||
(with-parsed-tramp-file-name (expand-file-name default-directory) nil
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(name (plist-get args :name))
|
||||
(buffer (plist-get args :buffer))
|
||||
(command (plist-get args :command))
|
||||
|
@ -5366,7 +5367,7 @@ This handles also chrooted environments, which are not regarded as local."
|
|||
;; The local temp directory must be writable for the other user.
|
||||
(file-writable-p
|
||||
(tramp-make-tramp-file-name
|
||||
vec (tramp-compat-temporary-file-directory) 'nohop))
|
||||
vec tramp-compat-temporary-file-directory 'nohop))
|
||||
;; On some systems, chown runs only for root.
|
||||
(or (zerop (user-uid))
|
||||
(zerop (tramp-get-remote-uid vec 'integer))))))
|
||||
|
@ -5508,7 +5509,7 @@ ALIST is of the form ((FROM . TO) ...)."
|
|||
It always returns a return code. The Lisp error raised when
|
||||
PROGRAM is nil is trapped also, returning 1. Furthermore, traces
|
||||
are written with verbosity of 6."
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(process-environment (default-toplevel-value 'process-environment))
|
||||
(destination (if (eq destination t) (current-buffer) destination))
|
||||
(vec (or vec (car tramp-current-connection)))
|
||||
|
@ -5542,7 +5543,7 @@ are written with verbosity of 6."
|
|||
It always returns a return code. The Lisp error raised when
|
||||
PROGRAM is nil is trapped also, returning 1. Furthermore, traces
|
||||
are written with verbosity of 6."
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(process-environment (default-toplevel-value 'process-environment))
|
||||
(buffer (if (eq buffer t) (current-buffer) buffer))
|
||||
result)
|
||||
|
@ -5572,7 +5573,7 @@ are written with verbosity of 6."
|
|||
"Call `process-lines' on the local host.
|
||||
If an error occurs, it returns nil. Traces are written with
|
||||
verbosity of 6."
|
||||
(let ((default-directory (tramp-compat-temporary-file-directory))
|
||||
(let ((default-directory tramp-compat-temporary-file-directory)
|
||||
(process-environment (default-toplevel-value 'process-environment))
|
||||
(vec (or vec (car tramp-current-connection)))
|
||||
result)
|
||||
|
@ -5611,7 +5612,7 @@ Invokes `password-read' if available, `read-passwd' else."
|
|||
;; `exec-path' contains a relative file name like ".", it
|
||||
;; could happen that the "gpg" command is not found. So we
|
||||
;; adapt `default-directory'. (Bug#39389, Bug#39489)
|
||||
(default-directory (tramp-compat-temporary-file-directory))
|
||||
(default-directory tramp-compat-temporary-file-directory)
|
||||
(case-fold-search t)
|
||||
(key (tramp-make-tramp-file-name
|
||||
;; In tramp-sh.el, we must use "password-vector" due to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue