]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp: Rework handling of temporary connection properties
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 13 Nov 2024 15:23:27 +0000 (16:23 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 20 Nov 2024 12:32:13 +0000 (13:32 +0100)
* 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.

(cherry picked from commit 22900b5990888cb231d65755562879108c626088)

doc/misc/tramp.texi
lisp/net/tramp-adb.el
lisp/net/tramp-androidsu.el
lisp/net/tramp-cache.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
lisp/net/tramp.el

index 8b8cd1ae55331bc8b33d7870e1969ea27b4dbc4c..dac0701bd5b25c5b1580d231a81cc70f9a24abb3 100644 (file)
@@ -3941,6 +3941,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
index ad82aad6a32ca3b9301258238506f9842c7c6e51..5a7176c3ec8140c662335314b229820b7b9763c6 100644 (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)))
index 473cecf7a1bb456e0a7e738c3ea3c705b37fe85e..9e99838f751748b0c1207d19059147ca82b83f2e 100644 (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
index 16893ea8c826591313c698f2c70c54a523169d3e..85fe295358e526ad8833bc47bfc2d29fb4684c98 100644 (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.
index d37bb61225586e12370a128d6dabf32652d9ad64..733c96fcfaaeef4034d114912e2d8aea462b1ce7 100644 (file)
@@ -171,7 +171,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.
index 8954d06b9b517383f6ae9b91f64473b40074f726..8f151e0dc03e15e0b86916529657f8d56d779591 100644 (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)
index 7b85ecc119278888a37a2b09700e15f68c99de95..9895777919f79e8b987d63e336a101f9525efba2 100644 (file)
@@ -1799,7 +1799,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
@@ -2249,7 +2249,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
index 8703087f66d3c269f4bcc05d840826e698793ca3..eab1dd41d76097cc4cd108c92b88f893a788f6c6 100644 (file)
@@ -2567,16 +2567,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\""
@@ -3084,10 +3084,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'
@@ -3169,8 +3169,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
@@ -4326,7 +4326,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)
@@ -4431,7 +4431,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"
@@ -4445,7 +4445,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"
@@ -5113,7 +5113,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))))
 
index 2699dc130433a6498bf836c73ecfd3f4df06bff3..c138600be67906c9db907e29b8695408c615332f 100644 (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))
index a4e8fe420481643d05503088e170d2b7b1a3e4b8..6e1b9e66478976bbb99b99608a827248da57c462 100644 (file)
@@ -1959,11 +1959,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))
@@ -1975,14 +1975,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)
@@ -2481,7 +2481,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
@@ -2496,12 +2496,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
@@ -5689,7 +5689,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)
@@ -5896,7 +5896,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"
@@ -6898,7 +6898,7 @@ Consults the auth-source package."
         ;; See if auth-sources contains something useful.
         (ignore-errors
           (and auth-sources
-                (tramp-get-connection-property vec "first-password-request")
+                (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.
@@ -6920,7 +6920,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)."