From 9fb24947f40cab608ba0f7d0aa58fbc9f5f4ebc6 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 30 Jan 2025 08:40:34 +0100 Subject: [PATCH] Tramp cleanup * doc/misc/tramp.texi (Predefined connection information): Mention also "androidsu" as special case of "tmpdir". (Remote processes): Signals are not delivered to remote direct async processes. Say, that there are restrictions for transfer of binary data to remote direct async processes. * lisp/net/tramp-compat.el (tramp-compat-temporary-file-directory): Simplify. (cherry picked from commit 6b3d69b16ed50c8a4dea1e3f1f9f231657e66590) --- doc/misc/tramp.texi | 19 +++++++++++++++---- lisp/net/tramp-cache.el | 9 +++++---- lisp/net/tramp-compat.el | 10 ++++++---- lisp/net/tramp-smb.el | 2 +- lisp/net/tramp.el | 6 ++++++ 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 74adea57d23..3108e398b0f 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -2378,9 +2378,9 @@ to a remote home directory, like @option{adb}, @option{rclone} and @item @t{"tmpdir"} The temporary directory on the remote host. If not specified, the -default value is @t{"/data/local/tmp"} for the @option{adb} method, -@t{"/C$/Temp"} for the @option{smb} method, and @t{"/tmp"} otherwise. -@xref{Temporary directory}. +default value is @t{"/data/local/tmp"} for the @option{adb} and +@option{androidsu} methods, @t{"/C$/Temp"} for the @option{smb} +method, and @t{"/tmp"} otherwise. @xref{Temporary directory}. @item @t{"posix"} @@ -4680,7 +4680,9 @@ It cannot be killed via @code{interrupt-process}. It does not report the remote terminal name via @code{process-tty-name}. @item -It does not set process property @code{remote-pid}. +It does not set process property @code{remote-pid}. Consequently, +signals cannot be sent to that remote process; they are sent to the +local process instead, which establishes the connection. @item It fails, when the command is too long. This can happen on @@ -4702,6 +4704,15 @@ by the connection property @t{"direct-async-process"}. This is still supported but deprecated, and it will be removed in a future @value{tramp} version. +@strong{Note}: For the @option{ssh} and @option{scp} methods, +@value{tramp} does not faithfully pass binary sequences on to the +process. You can change this by changing the respective connection +argument (@pxref{Predefined connection information}) via + +@lisp +(add-to-list 'tramp-connection-properties (list "/ssh:" "direct-async" t)) +@end lisp + @node Cleanup remote connections @section Cleanup remote connections diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index 1625eb8e8f9..caa5d3c2d01 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -68,10 +68,10 @@ ;; Some properties are handled special: ;; -;; - Properties which start with a space, like " process-name", are -;; not saved in the file `tramp-persistency-file-name', although -;; being connection properties related to a `tramp-file-name' -;; structure. +;; - Ephemeral properties which start with a space, like +;; " process-name", are not saved in the file +;; `tramp-persistency-file-name', although being connection +;; properties related to a `tramp-file-name' structure. ;; ;; - Reusable properties, which should not be saved, are kept in the ;; process key retrieved by `tramp-get-process' (the main connection @@ -79,6 +79,7 @@ ;; recomputation when a new asynchronous process is created by ;; `make-process'. Examples are "unsafe-temporary-file", ;; "remote-path", "device" (tramp-adb.el) or "share" (tramp-gvfs.el). +;; FIXME: Shall they be converted to ephemeral connection properties? ;;; Code: diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index ed42ac4fe4c..d30c9b8cca0 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -76,10 +76,10 @@ ;; an infloop. We try to follow the XDG specification, for security reasons. (defconst tramp-compat-temporary-file-directory (file-name-as-directory - (if-let ((xdg (xdg-cache-home)) - ((file-directory-p xdg)) - ((file-writable-p xdg))) - (prog1 (setq xdg (file-name-concat xdg "emacs")) + (if-let* ((xdg (xdg-cache-home)) + ((file-directory-p xdg)) + ((file-writable-p xdg))) + (prog1 (setq xdg (expand-file-name "emacs" xdg)) (make-directory xdg t)) (eval (car (get 'temporary-file-directory 'standard-value)) t))) "The default value of `temporary-file-directory' for Tramp.") @@ -243,6 +243,8 @@ value is the default binding of the variable." ;; are developers using `outline-minor-mode' in Lisp files, we still ;; keep this quoting. ;; +;; * Use `with-environment-variables'. +;; ;; * Starting with Emacs 29.1, use `buffer-match-p'. ;; ;; * Starting with Emacs 29.1, use `string-split'. diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 9f48e258383..37633b8ef71 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -737,7 +737,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (tramp-error v 'file-error "Cannot expand tilde in file `%s'" name)) (unless (tramp-run-real-handler #'file-name-absolute-p (list localname)) (setq localname (concat "/" localname))) - ;; Do not keep "/..". + ;; Do not keep "/..". (when (string-match-p (rx bos "/" (** 1 2 ".") eos) localname) (setq localname "/")) ;; Do normal `expand-file-name' (this does "/./" and "/../"), diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 25d977fd4f1..dd525fbd01b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -7200,5 +7200,11 @@ If VEC is `tramp-null-hop', return local null device." ;; ;; * Implement user and host name completion for multi-hops. Some ;; methods in tramp-container.el have it already. +;; +;; * Make it configurable, which environment variables are set in +;; direct async processes. +;; +;; * Pass working dir for direct async processes, for example for +;; container methods. ;;; tramp.el ends here -- 2.39.5