1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Tramp: Rework handling of temporary connection properties

* doc/misc/tramp.texi (Ad-hoc multi-hops): Precise use of parallel
multi-hops.

* lisp/net/tramp-cache.el:
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-androidsu.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el: Rename connection properties "process-name",
"process-buffer" and "first-password-request" to " process-name",
" process-buffer" and " first-password-request, repectively".

* lisp/net/tramp-cache.el (tramp-dump-connection-properties):
Don't dump properties starting with a space.
This commit is contained in:
Michael Albinus 2024-11-13 16:23:27 +01:00
parent 986621ae1f
commit 22900b5990
10 changed files with 62 additions and 59 deletions

View File

@ -3937,6 +3937,9 @@ parallel. In the following, on both remote hosts @samp{host1} and
@trampfn{ssh@value{postfixhop}user2@@host2|docker,name,}
@end example
If you use the shortened name @samp{@trampfn{docker,name,}}, the last
used proxy definition is expanded for.
@node Home directories
@section Expanding @file{~} to home directory

View File

@ -811,10 +811,10 @@ will be used."
v 'file-error "Cannot apply multibyte command `%s'" command))
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
;; Set the new process properties.
(tramp-set-connection-property v "process-name" name)
(tramp-set-connection-property v "process-buffer" buffer)
(tramp-set-connection-property v " process-name" name)
(tramp-set-connection-property v " process-buffer" buffer)
(with-current-buffer (tramp-get-connection-buffer v)
(unwind-protect
;; We catch this event. Otherwise, `make-process'
@ -857,8 +857,8 @@ will be used."
;; We must flush them here already;
;; otherwise `rename-file', `delete-file'
;; or `insert-file-contents' will fail.
(tramp-flush-connection-property v "process-name")
(tramp-flush-connection-property v "process-buffer")
(tramp-flush-connection-property v " process-name")
(tramp-flush-connection-property v " process-buffer")
;; Copy tmpstderr file.
(when (and (stringp stderr)
(not (tramp-tramp-file-p stderr)))

View File

@ -111,7 +111,7 @@ multibyte mode and waits for the shell prompt to appear."
(with-tramp-debug-message vec "Opening connection"
(let ((p (tramp-get-connection-process vec))
(process-name (tramp-get-connection-property vec "process-name"))
(process-name (tramp-get-connection-property vec " process-name"))
(process-environment (copy-sequence process-environment)))
;; Open a new connection.
(condition-case err

View File

@ -68,7 +68,7 @@
;; Some properties are handled special:
;;
;; - "process-name", "process-buffer" and "first-password-request" are
;; - 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.
@ -554,7 +554,7 @@ PROPERTIES is a list of file properties (strings)."
(lambda (key)
(and (tramp-file-name-p key)
(null (tramp-file-name-localname key))
(tramp-connection-property-p key "process-buffer")
(tramp-connection-property-p key " process-buffer")
key))
(hash-table-keys tramp-cache-data))))
@ -586,10 +586,9 @@ PROPERTIES is a list of file properties (strings)."
(not (tramp-file-name-localname key))
(not (gethash "login-as" value))
(not (gethash "started" value)))
(progn
(remhash "process-name" value)
(remhash "process-buffer" value)
(remhash "first-password-request" value))
(dolist (k (hash-table-keys value))
(when (string-prefix-p " " k)
(remhash k value)))
(remhash key cache)))
cache)
;; Dump it.

View File

@ -173,7 +173,7 @@ interactively, a Tramp connection has to be selected."
(get-buffer (tramp-debug-buffer-name vec)))
(unless keep-debug
(get-buffer (tramp-trace-buffer-name vec)))
(tramp-get-connection-property vec "process-buffer")))
(tramp-get-connection-property vec " process-buffer")))
(when (bufferp buf) (kill-buffer buf)))
;; Flush file cache.

View File

@ -352,7 +352,7 @@ connection if a previous connection has died for some reason."
(tramp-compat-make-temp-file " .nocrypt" 'dir-flag))))
;; Enable `auth-source', unless "emacs -Q" has been called.
(tramp-set-connection-property
vec "first-password-request" tramp-cache-read-persistent-data)
vec " first-password-request" tramp-cache-read-persistent-data)
(with-temp-buffer
(insert
(tramp-read-passwd
@ -408,7 +408,7 @@ ARGS are the arguments. It returns t if ran successful, and nil otherwise."
(args (delq nil args)))
;; Enable `auth-source', unless "emacs -Q" has been called.
(tramp-set-connection-property
vec "first-password-request" tramp-cache-read-persistent-data)
vec " first-password-request" tramp-cache-read-persistent-data)
(insert
(tramp-read-passwd
(tramp-get-connection-process vec)

View File

@ -1801,7 +1801,7 @@ a downcased host name only."
(setq domain (read-string "Domain name: ")))
(tramp-message l 6 "%S %S %S %d" message user domain flags)
(unless (tramp-get-connection-property l "first-password-request")
(unless (tramp-get-connection-property l " first-password-request")
(tramp-clear-passwd l))
(setq password (tramp-read-passwd
@ -2252,7 +2252,7 @@ connection if a previous connection has died for some reason."
;; Enable `auth-source'.
(tramp-set-connection-property
vec "first-password-request" tramp-cache-read-persistent-data)
vec " first-password-request" tramp-cache-read-persistent-data)
;; There will be a callback of "askPassword" when a password is needed.
(dbus-register-method

View File

@ -2558,16 +2558,16 @@ The method used must be an out-of-band method."
(with-temp-buffer
(unwind-protect
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
;; The default directory must be remote.
(let ((default-directory
(file-name-directory (if v1 filename newname)))
(process-environment (copy-sequence process-environment)))
;; Set the transfer process properties.
(tramp-set-connection-property
v "process-name" (buffer-name (current-buffer)))
v " process-name" (buffer-name (current-buffer)))
(tramp-set-connection-property
v "process-buffer" (current-buffer))
v " process-buffer" (current-buffer))
(when copy-env
(tramp-message
v 6 "%s=\"%s\""
@ -3075,10 +3075,10 @@ will be used."
:file-handler t))
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
;; Set the new process properties.
(tramp-set-connection-property v "process-name" name)
(tramp-set-connection-property v "process-buffer" buffer)
(tramp-set-connection-property v " process-name" name)
(tramp-set-connection-property v " process-buffer" buffer)
(with-current-buffer (tramp-get-connection-buffer v)
(unwind-protect
;; We catch this event. Otherwise, `make-process'
@ -3160,8 +3160,8 @@ will be used."
(set-marker (process-mark p) (point)))
;; We must flush them here already; otherwise
;; `delete-file' will fail.
(tramp-flush-connection-property v "process-name")
(tramp-flush-connection-property v "process-buffer")
(tramp-flush-connection-property v " process-name")
(tramp-flush-connection-property v " process-buffer")
;; Kill stderr process and delete named pipe.
(when (bufferp stderr)
(add-function
@ -4319,7 +4319,7 @@ file exists and nonzero exit status otherwise."
(defun tramp-find-shell (vec)
"Open a shell on the remote host which groks tilde expansion."
;; If we are in `make-process', we don't need another shell.
(unless (tramp-get-connection-property vec "process-name")
(unless (tramp-get-connection-property vec " process-name")
(with-current-buffer (tramp-get-buffer vec)
(let ((default-shell (tramp-get-method-parameter vec 'tramp-remote-shell))
shell)
@ -4424,7 +4424,7 @@ process to set up. VEC specifies the connection."
(let* ((old-uname (tramp-get-connection-property vec "uname"))
(uname
;; If we are in `make-process', we don't need to recompute.
(if (and old-uname (tramp-get-connection-property vec "process-name"))
(if (and old-uname (tramp-get-connection-property vec " process-name"))
old-uname
(tramp-set-connection-property
vec "uname"
@ -4438,7 +4438,7 @@ process to set up. VEC specifies the connection."
(and config-check-function
;; If we are in `make-process', we don't need to recompute.
(if (and old-config-check
(tramp-get-connection-property vec "process-name"))
(tramp-get-connection-property vec " process-name"))
old-config-check
(tramp-set-connection-property
vec "config-check-data"
@ -5106,7 +5106,7 @@ connection if a previous connection has died for some reason."
(with-tramp-debug-message vec "Opening connection"
(let ((p (tramp-get-connection-process vec))
(process-name (tramp-get-connection-property vec "process-name"))
(process-name (tramp-get-connection-property vec " process-name"))
(process-environment (copy-sequence process-environment))
(pos (with-current-buffer (tramp-get-connection-buffer vec) (point))))

View File

@ -526,13 +526,13 @@ arguments to pass to the OPERATION."
(unwind-protect
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
(with-temp-buffer
;; Set the transfer process properties.
(tramp-set-connection-property
v "process-name" (buffer-name (current-buffer)))
v " process-name" (buffer-name (current-buffer)))
(tramp-set-connection-property
v "process-buffer" (current-buffer))
v " process-buffer" (current-buffer))
(when t1
;; The smbclient tar command creates
@ -799,13 +799,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(concat "2>" (tramp-get-remote-null-device v)))))
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
(with-temp-buffer
;; Set the transfer process properties.
(tramp-set-connection-property
v "process-name" (buffer-name (current-buffer)))
v " process-name" (buffer-name (current-buffer)))
(tramp-set-connection-property
v "process-buffer" (current-buffer))
v " process-buffer" (current-buffer))
;; Use an asynchronous process. By this, password
;; can be handled.
@ -1247,11 +1247,11 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Call it.
(condition-case nil
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
;; Set the new process properties.
(tramp-set-connection-property v "process-name" name1)
(tramp-set-connection-property v " process-name" name1)
(tramp-set-connection-property
v "process-buffer"
v " process-buffer"
(or outbuf (generate-new-buffer tramp-temp-buffer-name)))
(with-current-buffer (tramp-get-connection-buffer v)
;; Preserve buffer contents.
@ -1287,9 +1287,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Cleanup. We remove all file cache values for the connection,
;; because the remote process could have changed them.
(when tmpinput (delete-file tmpinput))
;; FIXME: Does connection-property "process-buffer" still exist?
;; FIXME: Does connection-property " process-buffer" still exist?
(unless outbuf
(kill-buffer (tramp-get-connection-property v "process-buffer")))
(kill-buffer (tramp-get-connection-property v " process-buffer")))
(when process-file-side-effects
(tramp-flush-directory-properties v "/"))
@ -1388,13 +1388,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
"||" "echo" "tramp_exit_status" "1")))
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
(with-temp-buffer
;; Set the transfer process properties.
(tramp-set-connection-property
v "process-name" (buffer-name (current-buffer)))
v " process-name" (buffer-name (current-buffer)))
(tramp-set-connection-property
v "process-buffer" (current-buffer))
v " process-buffer" (current-buffer))
;; Use an asynchronous process. By this, password
;; can be handled.
@ -1450,7 +1450,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
p)
(unwind-protect
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
(save-excursion
(save-restriction
(while (get-process name1)
@ -1458,8 +1458,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq i (1+ i)
name1 (format "%s<%d>" name i)))
;; Set the new process properties.
(tramp-set-connection-property v "process-name" name1)
(tramp-set-connection-property v "process-buffer" buffer)
(tramp-set-connection-property v " process-name" name1)
(tramp-set-connection-property v " process-buffer" buffer)
;; Activate narrowing in order to save BUFFER contents.
(with-current-buffer (tramp-get-connection-buffer v)
(let ((buffer-undo-list t))

View File

@ -1956,11 +1956,11 @@ Unless DONT-CREATE, the buffer is created when it doesn't exist yet."
(or (get-buffer (tramp-buffer-name vec))
(unless dont-create
(with-current-buffer (get-buffer-create (tramp-buffer-name vec))
;; We use the existence of connection property "process-buffer"
;; We use the existence of connection property " process-buffer"
;; as indication, whether a connection is active.
(tramp-set-connection-property
vec "process-buffer"
(tramp-get-connection-property vec "process-buffer"))
vec " process-buffer"
(tramp-get-connection-property vec " process-buffer"))
(setq buffer-undo-list t
default-directory
(tramp-make-tramp-file-name vec 'noloc))
@ -1972,14 +1972,14 @@ Unless DONT-CREATE, the buffer is created when it doesn't exist yet."
Unless DONT-CREATE, the buffer is created when it doesn't exist yet.
In case a second asynchronous communication has been started, it is different
from `tramp-get-buffer'."
(or (tramp-get-connection-property vec "process-buffer")
(or (tramp-get-connection-property vec " process-buffer")
(tramp-get-buffer vec dont-create)))
(defun tramp-get-connection-name (vec)
"Get the connection name to be used for VEC.
In case a second asynchronous communication has been started, it is different
from the default one."
(or (tramp-get-connection-property vec "process-name")
(or (tramp-get-connection-property vec " process-name")
(tramp-buffer-name vec)))
(defun tramp-get-unique-process-name (name)
@ -2477,7 +2477,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
(with-tramp-debug-message
v (format "Running `%S'" (cons operation args))
;; We flush connection properties
;; "process-name" and "process-buffer",
;; " process-name" and " process-buffer",
;; because the operations shall be applied
;; in the main connection process. In order
;; to avoid superfluous debug buffers during
@ -2492,12 +2492,12 @@ Fall back to normal file name handler if no Tramp file name handler exists."
;; a short time frame.
;; In both cases, we try the default handler then.
(with-tramp-saved-connection-properties
v '("process-name" "process-buffer")
v '(" process-name" " process-buffer")
(let ((tramp-verbose
(if minibuffer-completing-file-name
0 tramp-verbose)))
(tramp-flush-connection-property v "process-name")
(tramp-flush-connection-property v "process-buffer"))
(tramp-flush-connection-property v " process-name")
(tramp-flush-connection-property v " process-buffer"))
(setq result
(catch 'non-essential
(catch 'suppress
@ -5694,7 +5694,7 @@ of."
;; Sometimes, the process returns a new password request
;; immediately after rejecting the previous (wrong) one.
(unless (or tramp-password-prompt-not-unique
(tramp-get-connection-property vec "first-password-request"))
(tramp-get-connection-property vec " first-password-request"))
(tramp-clear-passwd vec))
(goto-char (point-min))
(tramp-check-for-regexp proc tramp-process-action-regexp)
@ -5901,7 +5901,7 @@ performed successfully. Any other value means an error."
(tramp-set-connection-property
(tramp-get-connection-property
proc "password-vector" (process-get proc 'tramp-vector))
"first-password-request" tramp-cache-read-persistent-data)
" first-password-request" tramp-cache-read-persistent-data)
(save-restriction
(with-tramp-progress-reporter
proc 3 "Waiting for prompts from remote shell"
@ -6872,7 +6872,8 @@ Consults the auth-source package."
(setq tramp-password-save-function nil)
;; See if auth-sources contains something useful.
(ignore-errors
(and (tramp-get-connection-property vec "first-password-request")
(and auth-sources
(tramp-get-connection-property vec " first-password-request")
;; Try with Tramp's current method. If there is no
;; user name, `:create' triggers to ask for. We
;; suppress it.
@ -6894,7 +6895,7 @@ Consults the auth-source package."
(lambda () (password-cache-add key auth-passwd)))
auth-passwd))
(tramp-set-connection-property vec "first-password-request" nil))))
(tramp-set-connection-property vec " first-password-request" nil))))
(defun tramp-read-passwd-without-cache (proc &optional prompt)
"Read a password from user (compat function)."