aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/dictionary.el2
-rw-r--r--lisp/net/mailcap.el72
-rw-r--r--lisp/net/shr.el13
-rw-r--r--lisp/net/tramp-adb.el10
-rw-r--r--lisp/net/tramp-archive.el5
-rw-r--r--lisp/net/tramp-cache.el2
-rw-r--r--lisp/net/tramp-sh.el24
-rw-r--r--lisp/net/tramp-smb.el5
-rw-r--r--lisp/net/tramp-sshfs.el38
-rw-r--r--lisp/net/tramp-sudoedit.el3
-rw-r--r--lisp/net/tramp.el88
11 files changed, 157 insertions, 105 deletions
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 507363cc0f8..e0824f39716 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -1376,7 +1376,7 @@ any buffer where (dictionary-tooltip-mode 1) has been called."
1376 (dictionary-search word))) 1376 (dictionary-search word)))
1377 1377
1378;;;###autoload 1378;;;###autoload
1379(defun context-menu-dictionary (menu click) 1379(defun dictionary-context-menu (menu click)
1380 "Populate MENU with dictionary commands at CLICK. 1380 "Populate MENU with dictionary commands at CLICK.
1381When you add this function to `context-menu-functions', 1381When you add this function to `context-menu-functions',
1382the context menu will contain an item that searches 1382the context menu will contain an item that searches
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index daa2d5a3fb3..b65f7c25b83 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -319,8 +319,9 @@ attribute name (viewer, test, etc). This looks like:
319 319
320Where VIEWERINFO specifies how the content-type is viewed. Can be 320Where VIEWERINFO specifies how the content-type is viewed. Can be
321a string, in which case it is run through a shell, with appropriate 321a string, in which case it is run through a shell, with appropriate
322parameters, or a symbol, in which case the symbol is `funcall'ed if 322parameters, or a symbol, in which case the symbol must name a function
323and only if it exists as a function, with the buffer as an argument. 323of zero arguments which is called in a buffer holding the MIME part's
324content.
324 325
325TESTINFO is a test for the viewer's applicability, or nil. If nil, it 326TESTINFO is a test for the viewer's applicability, or nil. If nil, it
326means the viewer is always valid. If it is a Lisp function, it is 327means the viewer is always valid. If it is a Lisp function, it is
@@ -1175,34 +1176,45 @@ See \"~/.mailcap\", `mailcap-mime-data' and related files and variables."
1175 (mailcap-parse-mailcaps) 1176 (mailcap-parse-mailcaps)
1176 (let ((command (mailcap-mime-info 1177 (let ((command (mailcap-mime-info
1177 (mailcap-extension-to-mime (file-name-extension file))))) 1178 (mailcap-extension-to-mime (file-name-extension file)))))
1178 (unless command 1179 (if (functionp command)
1179 (error "No viewer for %s" (file-name-extension file))) 1180 ;; command is a viewer function (a mode) expecting the file
1180 ;; Remove quotes around the file name - we'll use shell-quote-argument. 1181 ;; contents to be in the current buffer.
1181 (while (string-match "['\"]%s['\"]" command) 1182 (let ((buf (generate-new-buffer (file-name-nondirectory file))))
1182 (setq command (replace-match "%s" t t command))) 1183 (set-buffer buf)
1183 (setq command (replace-regexp-in-string 1184 (insert-file-contents file)
1184 "%s" 1185 (setq buffer-file-name file)
1185 (shell-quote-argument (convert-standard-filename file)) 1186 (funcall command)
1186 command 1187 (set-buffer-modified-p nil)
1187 nil t)) 1188 (pop-to-buffer buf))
1188 ;; Handlers such as "gio open" and kde-open5 start viewer in background 1189 ;; command is a program to run with file as an argument.
1189 ;; and exit immediately. Avoid `start-process' since it assumes 1190 (unless command
1190 ;; :connection-type `pty' and kills children processes with SIGHUP 1191 (error "No viewer for %s" (file-name-extension file)))
1191 ;; when temporary terminal session is finished (Bug#44824). 1192 ;; Remove quotes around the file name - we'll use shell-quote-argument.
1192 ;; An alternative is `process-connection-type' let-bound to nil for 1193 (while (string-match "['\"]%s['\"]" command)
1193 ;; `start-process-shell-command' call (with no chance to report failure). 1194 (setq command (replace-match "%s" t t command)))
1194 (make-process 1195 (setq command (replace-regexp-in-string
1195 :name "mailcap-view-file" 1196 "%s"
1196 :connection-type 'pipe 1197 (shell-quote-argument (convert-standard-filename file))
1197 :buffer nil ; "*Messages*" may be suitable for debugging 1198 command
1198 :sentinel (lambda (proc event) 1199 nil t))
1199 (when (and (memq (process-status proc) '(exit signal)) 1200 ;; Handlers such as "gio open" and kde-open5 start viewer in background
1200 (/= (process-exit-status proc) 0)) 1201 ;; and exit immediately. Avoid `start-process' since it assumes
1201 (message 1202 ;; :connection-type `pty' and kills children processes with SIGHUP
1202 "Command %s: %s." 1203 ;; when temporary terminal session is finished (Bug#44824).
1203 (mapconcat #'identity (process-command proc) " ") 1204 ;; An alternative is `process-connection-type' let-bound to nil for
1204 (substring event 0 -1)))) 1205 ;; `start-process-shell-command' call (with no chance to report failure).
1205 :command (list shell-file-name shell-command-switch command)))) 1206 (make-process
1207 :name "mailcap-view-file"
1208 :connection-type 'pipe
1209 :buffer nil ; "*Messages*" may be suitable for debugging
1210 :sentinel (lambda (proc event)
1211 (when (and (memq (process-status proc) '(exit signal))
1212 (/= (process-exit-status proc) 0))
1213 (message
1214 "Command %s: %s."
1215 (mapconcat #'identity (process-command proc) " ")
1216 (substring event 0 -1))))
1217 :command (list shell-file-name shell-command-switch command)))))
1206 1218
1207(provide 'mailcap) 1219(provide 'mailcap)
1208 1220
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 7363874cf3c..ff14acfda70 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1467,7 +1467,18 @@ ones, in case fg and bg are nil."
1467 (dom-attr dom 'name)))) ; Obsolete since HTML5. 1467 (dom-attr dom 'name)))) ; Obsolete since HTML5.
1468 (push (cons id (point)) shr--link-targets)) 1468 (push (cons id (point)) shr--link-targets))
1469 (when url 1469 (when url
1470 (shr-urlify (or shr-start start) (shr-expand-url url) title)))) 1470 (shr-urlify (or shr-start start) (shr-expand-url url) title)
1471 ;; Check whether the URL is suspicious.
1472 (when-let ((warning (or (textsec-suspicious-p
1473 (shr-expand-url url) 'url)
1474 (textsec-suspicious-p
1475 (cons (shr-expand-url url)
1476 (buffer-substring (or shr-start start)
1477 (point)))
1478 'link))))
1479 (add-text-properties (or shr-start start) (point)
1480 (list 'face '(shr-link textsec-suspicious)))
1481 (insert (propertize "⚠️" 'help-echo warning))))))
1471 1482
1472(defun shr-tag-abbr (dom) 1483(defun shr-tag-abbr (dom)
1473 (let ((title (dom-attr dom 'title)) 1484 (let ((title (dom-attr dom 'title))
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index ed73a86ef03..75e6b7179b0 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -776,7 +776,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
776(defun tramp-adb-get-signal-strings (vec) 776(defun tramp-adb-get-signal-strings (vec)
777 "Strings to return by `process-file' in case of signals." 777 "Strings to return by `process-file' in case of signals."
778 (with-tramp-connection-property vec "signal-strings" 778 (with-tramp-connection-property vec "signal-strings"
779 (let ((default-directory (tramp-make-tramp-file-name vec 'localname)) 779 (let ((default-directory (tramp-make-tramp-file-name vec 'noloc))
780 ;; `shell-file-name' and `shell-command-switch' are needed 780 ;; `shell-file-name' and `shell-command-switch' are needed
781 ;; for Emacs < 27.1, which doesn't support connection-local 781 ;; for Emacs < 27.1, which doesn't support connection-local
782 ;; variables in `shell-command'. 782 ;; variables in `shell-command'.
@@ -815,7 +815,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
815 ;; Determine input. 815 ;; Determine input.
816 (if (null infile) 816 (if (null infile)
817 (setq input (tramp-get-remote-null-device v)) 817 (setq input (tramp-get-remote-null-device v))
818 (setq infile (expand-file-name infile)) 818 (setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
819 (if (tramp-equal-remote default-directory infile) 819 (if (tramp-equal-remote default-directory infile)
820 ;; INFILE is on the same remote host. 820 ;; INFILE is on the same remote host.
821 (setq input (tramp-file-local-name infile)) 821 (setq input (tramp-file-local-name infile))
@@ -870,7 +870,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
870 (setq ret (tramp-adb-send-command-and-check 870 (setq ret (tramp-adb-send-command-and-check
871 v (format 871 v (format
872 "(cd %s; %s)" 872 "(cd %s; %s)"
873 (tramp-shell-quote-argument localname) command) 873 (tramp-unquote-shell-quote-argument localname)
874 command)
874 t)) 875 t))
875 (unless (natnump ret) (setq ret 1)) 876 (unless (natnump ret) (setq ret 1))
876 ;; We should add the output anyway. 877 ;; We should add the output anyway.
@@ -900,8 +901,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
900 ;; Cleanup. We remove all file cache values for the connection, 901 ;; Cleanup. We remove all file cache values for the connection,
901 ;; because the remote process could have changed them. 902 ;; because the remote process could have changed them.
902 (when tmpinput (delete-file tmpinput)) 903 (when tmpinput (delete-file tmpinput))
903 904 (when process-file-side-effects
904 (unless process-file-side-effects
905 (tramp-flush-directory-properties v "")) 905 (tramp-flush-directory-properties v ""))
906 906
907 ;; Return exit status. 907 ;; Return exit status.
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index 8a88057d38a..d3f427932f3 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -457,7 +457,7 @@ name is kept in slot `hop'"
457 ((tramp-archive-file-name-p archive) 457 ((tramp-archive-file-name-p archive)
458 (let ((archive 458 (let ((archive
459 (tramp-make-tramp-file-name 459 (tramp-make-tramp-file-name
460 (tramp-archive-dissect-file-name archive) nil 'noarchive))) 460 (tramp-archive-dissect-file-name archive))))
461 (setf (tramp-file-name-host vec) (tramp-archive-gvfs-host archive))) 461 (setf (tramp-file-name-host vec) (tramp-archive-gvfs-host archive)))
462 (puthash archive (list vec) tramp-archive-hash)) 462 (puthash archive (list vec) tramp-archive-hash))
463 463
@@ -560,8 +560,7 @@ offered."
560 560
561(defun tramp-archive-gvfs-file-name (name) 561(defun tramp-archive-gvfs-file-name (name)
562 "Return NAME in GVFS syntax." 562 "Return NAME in GVFS syntax."
563 (tramp-make-tramp-file-name 563 (tramp-make-tramp-file-name (tramp-archive-dissect-file-name name)))
564 (tramp-archive-dissect-file-name name) nil 'nohop))
565 564
566 565
567;; File name primitives. 566;; File name primitives.
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 715b537247f..1ab8f4d335b 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -124,7 +124,7 @@ If KEY is `tramp-cache-undefined', don't create anything, and return nil."
124 (dolist (elt tramp-connection-properties) 124 (dolist (elt tramp-connection-properties)
125 (when (tramp-compat-string-search 125 (when (tramp-compat-string-search
126 (or (nth 0 elt) "") 126 (or (nth 0 elt) "")
127 (tramp-make-tramp-file-name key 'noloc 'nohop)) 127 (tramp-make-tramp-file-name key 'noloc))
128 (tramp-set-connection-property key (nth 1 elt) (nth 2 elt))))) 128 (tramp-set-connection-property key (nth 1 elt) (nth 2 elt)))))
129 hash)))) 129 hash))))
130 130
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 72b1ebb3e06..f0ceabe568b 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1149,8 +1149,7 @@ component is used as the target of the symlink."
1149 (when (file-remote-p result) 1149 (when (file-remote-p result)
1150 (setq result (tramp-compat-file-name-quote result 'top))) 1150 (setq result (tramp-compat-file-name-quote result 'top)))
1151 (tramp-message v 4 "True name of `%s' is `%s'" localname result) 1151 (tramp-message v 4 "True name of `%s' is `%s'" localname result)
1152 result)) 1152 result)))))))
1153 'nohop)))))
1154 1153
1155;; Basic functions. 1154;; Basic functions.
1156 1155
@@ -2852,7 +2851,7 @@ implementation will be used."
2852 ;; `shell'. We discard hops, if existing, that's why 2851 ;; `shell'. We discard hops, if existing, that's why
2853 ;; we cannot use `file-remote-p'. 2852 ;; we cannot use `file-remote-p'.
2854 (prompt (format "PS1=%s %s" 2853 (prompt (format "PS1=%s %s"
2855 (tramp-make-tramp-file-name v nil 'nohop) 2854 (tramp-make-tramp-file-name v)
2856 tramp-initial-end-of-output)) 2855 tramp-initial-end-of-output))
2857 ;; We use as environment the difference to toplevel 2856 ;; We use as environment the difference to toplevel
2858 ;; `process-environment'. 2857 ;; `process-environment'.
@@ -3013,7 +3012,7 @@ implementation will be used."
3013 vec 3012 vec
3014 (concat 3013 (concat
3015 "signal-strings-" (tramp-get-method-parameter vec 'tramp-remote-shell)) 3014 "signal-strings-" (tramp-get-method-parameter vec 'tramp-remote-shell))
3016 (let ((default-directory (tramp-make-tramp-file-name vec 'localname)) 3015 (let ((default-directory (tramp-make-tramp-file-name vec 'noloc))
3017 process-file-return-signal-string signals res result) 3016 process-file-return-signal-string signals res result)
3018 (setq signals 3017 (setq signals
3019 (append 3018 (append
@@ -3098,13 +3097,13 @@ implementation will be used."
3098 ;; Determine input. 3097 ;; Determine input.
3099 (if (null infile) 3098 (if (null infile)
3100 (setq input (tramp-get-remote-null-device v)) 3099 (setq input (tramp-get-remote-null-device v))
3101 (setq infile (expand-file-name infile)) 3100 (setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
3102 (if (tramp-equal-remote default-directory infile) 3101 (if (tramp-equal-remote default-directory infile)
3103 ;; INFILE is on the same remote host. 3102 ;; INFILE is on the same remote host.
3104 (setq input (tramp-file-local-name infile)) 3103 (setq input (tramp-file-local-name infile))
3105 ;; INFILE must be copied to remote host. 3104 ;; INFILE must be copied to remote host.
3106 (setq input (tramp-make-tramp-temp-file v) 3105 (setq input (tramp-make-tramp-temp-file v)
3107 tmpinput (tramp-make-tramp-file-name v input 'nohop)) 3106 tmpinput (tramp-make-tramp-file-name v input))
3108 (copy-file infile tmpinput t))) 3107 (copy-file infile tmpinput t)))
3109 (when input (setq command (format "%s <%s" command input))) 3108 (when input (setq command (format "%s <%s" command input)))
3110 3109
@@ -3136,7 +3135,7 @@ implementation will be used."
3136 ;; stderr must be copied to remote host. The temporary 3135 ;; stderr must be copied to remote host. The temporary
3137 ;; file must be deleted after execution. 3136 ;; file must be deleted after execution.
3138 (setq stderr (tramp-make-tramp-temp-file v) 3137 (setq stderr (tramp-make-tramp-temp-file v)
3139 tmpstderr (tramp-make-tramp-file-name v stderr 'nohop)))) 3138 tmpstderr (tramp-make-tramp-file-name v stderr))))
3140 ;; stderr to be discarded. 3139 ;; stderr to be discarded.
3141 ((null (cadr destination)) 3140 ((null (cadr destination))
3142 (setq stderr (tramp-get-remote-null-device v))))) 3141 (setq stderr (tramp-get-remote-null-device v)))))
@@ -3153,7 +3152,8 @@ implementation will be used."
3153 (setq ret (tramp-send-command-and-check 3152 (setq ret (tramp-send-command-and-check
3154 v (format 3153 v (format
3155 "cd %s && %s" 3154 "cd %s && %s"
3156 (tramp-shell-quote-argument localname) command) 3155 (tramp-unquote-shell-quote-argument localname)
3156 command)
3157 t t t)) 3157 t t t))
3158 (unless (natnump ret) (setq ret 1)) 3158 (unless (natnump ret) (setq ret 1))
3159 ;; We should add the output anyway. 3159 ;; We should add the output anyway.
@@ -3184,8 +3184,7 @@ implementation will be used."
3184 ;; Cleanup. We remove all file cache values for the connection, 3184 ;; Cleanup. We remove all file cache values for the connection,
3185 ;; because the remote process could have changed them. 3185 ;; because the remote process could have changed them.
3186 (when tmpinput (delete-file tmpinput)) 3186 (when tmpinput (delete-file tmpinput))
3187 3187 (when process-file-side-effects
3188 (unless process-file-side-effects
3189 (tramp-flush-directory-properties v "")) 3188 (tramp-flush-directory-properties v ""))
3190 3189
3191 ;; Return exit status. 3190 ;; Return exit status.
@@ -3650,8 +3649,7 @@ Fall back to normal file name handler if no Tramp handler exists."
3650(defun tramp-sh-file-name-handler-p (vec) 3649(defun tramp-sh-file-name-handler-p (vec)
3651 "Whether VEC uses a method from `tramp-sh-file-name-handler'." 3650 "Whether VEC uses a method from `tramp-sh-file-name-handler'."
3652 (and (assoc (tramp-file-name-method vec) tramp-methods) 3651 (and (assoc (tramp-file-name-method vec) tramp-methods)
3653 (eq (tramp-find-foreign-file-name-handler 3652 (eq (tramp-find-foreign-file-name-handler vec)
3654 (tramp-make-tramp-file-name vec nil 'nohop))
3655 'tramp-sh-file-name-handler))) 3653 'tramp-sh-file-name-handler)))
3656 3654
3657;; This must be the last entry, because `identity' always matches. 3655;; This must be the last entry, because `identity' always matches.
@@ -5441,7 +5439,7 @@ Nonexistent directories are removed from spec."
5441 (lambda (x) 5439 (lambda (x)
5442 (and 5440 (and
5443 (stringp x) 5441 (stringp x)
5444 (file-directory-p (tramp-make-tramp-file-name vec x 'nohop)) 5442 (file-directory-p (tramp-make-tramp-file-name vec x))
5445 x)) 5443 x))
5446 remote-path)))))) 5444 remote-path))))))
5447 5445
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index c5f423fa3f0..6515519680c 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1281,7 +1281,7 @@ component is used as the target of the symlink."
1281 1281
1282 ;; Determine input. 1282 ;; Determine input.
1283 (when infile 1283 (when infile
1284 (setq infile (expand-file-name infile)) 1284 (setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
1285 (if (tramp-equal-remote default-directory infile) 1285 (if (tramp-equal-remote default-directory infile)
1286 ;; INFILE is on the same remote host. 1286 ;; INFILE is on the same remote host.
1287 (setq input (tramp-file-local-name infile)) 1287 (setq input (tramp-file-local-name infile))
@@ -1373,8 +1373,7 @@ component is used as the target of the symlink."
1373 (when tmpinput (delete-file tmpinput)) 1373 (when tmpinput (delete-file tmpinput))
1374 (unless outbuf 1374 (unless outbuf
1375 (kill-buffer (tramp-get-connection-property v "process-buffer" nil))) 1375 (kill-buffer (tramp-get-connection-property v "process-buffer" nil)))
1376 1376 (when process-file-side-effects
1377 (unless process-file-side-effects
1378 (tramp-flush-directory-properties v "")) 1377 (tramp-flush-directory-properties v ""))
1379 1378
1380 ;; Return exit status. 1379 ;; Return exit status.
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 0a5bf2f43b3..72837793de4 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -137,7 +137,7 @@
137 (set-file-acl . ignore) 137 (set-file-acl . ignore)
138 (set-file-modes . tramp-sshfs-handle-set-file-modes) 138 (set-file-modes . tramp-sshfs-handle-set-file-modes)
139 (set-file-selinux-context . ignore) 139 (set-file-selinux-context . ignore)
140 (set-file-times . ignore) 140 (set-file-times . tramp-sshfs-handle-set-file-times)
141 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) 141 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
142 (shell-command . tramp-handle-shell-command) 142 (shell-command . tramp-handle-shell-command)
143 (start-file-process . tramp-handle-start-file-process) 143 (start-file-process . tramp-handle-start-file-process)
@@ -242,13 +242,28 @@ arguments to pass to the OPERATION."
242 (let ((command 242 (let ((command
243 (format 243 (format
244 "cd %s && exec %s" 244 "cd %s && exec %s"
245 localname 245 (tramp-unquote-shell-quote-argument localname)
246 (mapconcat #'tramp-shell-quote-argument (cons program args) " ")))) 246 (mapconcat #'tramp-shell-quote-argument (cons program args) " ")))
247 input tmpinput)
248
249 ;; Determine input.
250 (if (null infile)
251 (setq input (tramp-get-remote-null-device v))
252 (setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
253 (if (tramp-equal-remote default-directory infile)
254 ;; INFILE is on the same remote host.
255 (setq input (tramp-file-local-name infile))
256 ;; INFILE must be copied to remote host.
257 (setq input (tramp-make-tramp-temp-file v)
258 tmpinput (tramp-make-tramp-file-name v input))
259 (copy-file infile tmpinput t)))
260 (when input (setq command (format "%s <%s" command input)))
261
247 (unwind-protect 262 (unwind-protect
248 (apply 263 (apply
249 #'tramp-call-process 264 #'tramp-call-process
250 v (tramp-get-method-parameter v 'tramp-login-program) 265 v (tramp-get-method-parameter v 'tramp-login-program)
251 infile destination display 266 nil destination display
252 (tramp-expand-args 267 (tramp-expand-args
253 v 'tramp-login-args 268 v 'tramp-login-args
254 ?h (or (tramp-file-name-host v) "") 269 ?h (or (tramp-file-name-host v) "")
@@ -256,7 +271,11 @@ arguments to pass to the OPERATION."
256 ?p (or (tramp-file-name-port v) "") 271 ?p (or (tramp-file-name-port v) "")
257 ?l command)) 272 ?l command))
258 273
259 (unless process-file-side-effects 274 ;; Cleanup. We remove all file cache values for the
275 ;; connection, because the remote process could have changed
276 ;; them.
277 (when tmpinput (delete-file tmpinput))
278 (when process-file-side-effects
260 (tramp-flush-directory-properties v "")))))) 279 (tramp-flush-directory-properties v ""))))))
261 280
262(defun tramp-sshfs-handle-rename-file 281(defun tramp-sshfs-handle-rename-file
@@ -285,6 +304,15 @@ arguments to pass to the OPERATION."
285 (tramp-compat-set-file-modes 304 (tramp-compat-set-file-modes
286 (tramp-fuse-local-file-name filename) mode flag)))) 305 (tramp-fuse-local-file-name filename) mode flag))))
287 306
307(defun tramp-sshfs-handle-set-file-times (filename &optional timestamp flag)
308 "Like `set-file-times' for Tramp files."
309 (or (file-exists-p filename) (write-region "" nil filename nil 0))
310 (with-parsed-tramp-file-name filename nil
311 (unless (and (eq flag 'nofollow) (file-symlink-p filename))
312 (tramp-flush-file-properties v localname)
313 (tramp-compat-set-file-times
314 (tramp-fuse-local-file-name filename) timestamp flag))))
315
288(defun tramp-sshfs-handle-write-region 316(defun tramp-sshfs-handle-write-region
289 (start end filename &optional append visit lockname mustbenew) 317 (start end filename &optional append visit lockname mustbenew)
290 "Like `write-region' for Tramp files." 318 "Like `write-region' for Tramp files."
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index a68d4b3e365..7fbe5412709 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -572,8 +572,7 @@ the result will be a local, non-Tramp, file name."
572 (when (file-remote-p result) 572 (when (file-remote-p result)
573 (setq result (tramp-compat-file-name-quote result 'top))) 573 (setq result (tramp-compat-file-name-quote result 'top)))
574 (tramp-message v 4 "True name of `%s' is `%s'" localname result) 574 (tramp-message v 4 "True name of `%s' is `%s'" localname result)
575 result)) 575 result)))))))
576 'nohop)))))
577 576
578(defun tramp-sudoedit-handle-file-writable-p (filename) 577(defun tramp-sudoedit-handle-file-writable-p (filename)
579 "Like `file-writable-p' for Tramp files." 578 "Like `file-writable-p' for Tramp files."
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7d6157ed8c2..b258121549d 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1713,13 +1713,10 @@ See `tramp-dissect-file-name' for details."
1713 "Construct a Tramp file name from ARGS. 1713 "Construct a Tramp file name from ARGS.
1714 1714
1715ARGS could have two different signatures. The first one is of 1715ARGS could have two different signatures. The first one is of
1716type (VEC &optional LOCALNAME HOP). 1716type (VEC &optional LOCALNAME).
1717If LOCALNAME is nil, the value in VEC is used. If it is a 1717If LOCALNAME is nil, the value in VEC is used. If it is a
1718symbol, a null localname will be used. Otherwise, LOCALNAME is 1718symbol, a null localname will be used. Otherwise, LOCALNAME is
1719expected to be a string, which will be used. 1719expected to be a string, which will be used.
1720If HOP is nil, the value in VEC is used. If it is a symbol, a
1721null hop will be used. Otherwise, HOP is expected to be a
1722string, which will be used.
1723 1720
1724The other signature exists for backward compatibility. It has 1721The other signature exists for backward compatibility. It has
1725the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)." 1722the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
@@ -1735,8 +1732,13 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
1735 hop (tramp-file-name-hop (car args))) 1732 hop (tramp-file-name-hop (car args)))
1736 (when (cadr args) 1733 (when (cadr args)
1737 (setq localname (and (stringp (cadr args)) (cadr args)))) 1734 (setq localname (and (stringp (cadr args)) (cadr args))))
1738 (when (cl-caddr args) 1735 (when hop
1739 (setq hop (and (stringp (cl-caddr args)) (cl-caddr args))))) 1736 (setq hop nil)
1737 ;; Assure that the hops are in `tramp-default-proxies-alist'.
1738 ;; In tramp-archive.el, the slot `hop' is used for the archive
1739 ;; file name.
1740 (unless (string-equal method "archive")
1741 (tramp-add-hops (car args)))))
1740 1742
1741 (t (setq method (nth 0 args) 1743 (t (setq method (nth 0 args)
1742 user (nth 1 args) 1744 user (nth 1 args)
@@ -1769,15 +1771,17 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
1769 localname))) 1771 localname)))
1770 1772
1771(set-advertised-calling-convention 1773(set-advertised-calling-convention
1772 #'tramp-make-tramp-file-name '(vec &optional localname hop) "27.1") 1774 #'tramp-make-tramp-file-name '(vec &optional localname) "29.1")
1773 1775
1774(defun tramp-make-tramp-hop-name (vec) 1776(defun tramp-make-tramp-hop-name (vec)
1775 "Construct a Tramp hop name from VEC." 1777 "Construct a Tramp hop name from VEC."
1776 (replace-regexp-in-string 1778 (concat
1777 tramp-prefix-regexp "" 1779 (tramp-file-name-hop vec)
1778 (replace-regexp-in-string 1780 (replace-regexp-in-string
1779 (concat tramp-postfix-host-regexp "$") tramp-postfix-hop-format 1781 tramp-prefix-regexp ""
1780 (tramp-make-tramp-file-name vec 'noloc)))) 1782 (replace-regexp-in-string
1783 (concat tramp-postfix-host-regexp "$") tramp-postfix-hop-format
1784 (tramp-make-tramp-file-name vec 'noloc)))))
1781 1785
1782(defun tramp-completion-make-tramp-file-name (method user host localname) 1786(defun tramp-completion-make-tramp-file-name (method user host localname)
1783 "Construct a Tramp file name from METHOD, USER, HOST and LOCALNAME. 1787 "Construct a Tramp file name from METHOD, USER, HOST and LOCALNAME.
@@ -1811,7 +1815,7 @@ Unless DONT-CREATE, the buffer is created when it doesn't exist yet."
1811 (tramp-get-connection-property vec "process-buffer" nil)) 1815 (tramp-get-connection-property vec "process-buffer" nil))
1812 (setq buffer-undo-list t 1816 (setq buffer-undo-list t
1813 default-directory 1817 default-directory
1814 (tramp-make-tramp-file-name vec 'noloc 'nohop)) 1818 (tramp-make-tramp-file-name vec 'noloc))
1815 (current-buffer))))) 1819 (current-buffer)))))
1816 1820
1817(defun tramp-get-connection-buffer (vec &optional dont-create) 1821(defun tramp-get-connection-buffer (vec &optional dont-create)
@@ -1926,7 +1930,7 @@ The outline level is equal to the verbosity of the Tramp message."
1926 "A predicate for Tramp interactive commands. 1930 "A predicate for Tramp interactive commands.
1927They are completed by \"M-x TAB\" only in Tramp debug buffers." 1931They are completed by \"M-x TAB\" only in Tramp debug buffers."
1928 (with-current-buffer buffer 1932 (with-current-buffer buffer
1929 (string-equal (buffer-substring 1 10) ";; Emacs:"))) 1933 (string-equal (buffer-substring 1 (min 10 (point-max))) ";; Emacs:")))
1930 1934
1931(put #'tramp-debug-buffer-command-completion-p 'tramp-suppress-trace t) 1935(put #'tramp-debug-buffer-command-completion-p 'tramp-suppress-trace t)
1932 1936
@@ -2596,11 +2600,10 @@ Must be handled by the callers."
2596 ;; Unknown file primitive. 2600 ;; Unknown file primitive.
2597 (t (error "Unknown file I/O primitive: %s" operation)))) 2601 (t (error "Unknown file I/O primitive: %s" operation))))
2598 2602
2599(defun tramp-find-foreign-file-name-handler (filename &optional _operation) 2603(defun tramp-find-foreign-file-name-handler (vec &optional _operation)
2600 "Return foreign file name handler if exists." 2604 "Return foreign file name handler if exists."
2601 (when (tramp-tramp-file-p filename) 2605 (when (tramp-file-name-p vec)
2602 (let ((handler tramp-foreign-file-name-handler-alist) 2606 (let ((handler tramp-foreign-file-name-handler-alist)
2603 (vec (tramp-dissect-file-name filename))
2604 elt func res) 2607 elt func res)
2605 (while handler 2608 (while handler
2606 (setq elt (car handler) 2609 (setq elt (car handler)
@@ -2633,7 +2636,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
2633 (with-parsed-tramp-file-name filename nil 2636 (with-parsed-tramp-file-name filename nil
2634 (let ((current-connection tramp-current-connection) 2637 (let ((current-connection tramp-current-connection)
2635 (foreign 2638 (foreign
2636 (tramp-find-foreign-file-name-handler filename operation)) 2639 (tramp-find-foreign-file-name-handler v operation))
2637 (signal-hook-function #'tramp-signal-hook-function) 2640 (signal-hook-function #'tramp-signal-hook-function)
2638 result) 2641 result)
2639 ;; Set `tramp-current-connection'. 2642 ;; Set `tramp-current-connection'.
@@ -3351,7 +3354,7 @@ User is always nil."
3351 (tramp-compat-funcall 'directory-abbrev-make-regexp home-dir) filename) 3354 (tramp-compat-funcall 'directory-abbrev-make-regexp home-dir) filename)
3352 (tramp-make-tramp-file-name 3355 (tramp-make-tramp-file-name
3353 vec (concat "~" (substring filename (match-beginning 1)))) 3356 vec (concat "~" (substring filename (match-beginning 1))))
3354 filename))) 3357 (tramp-make-tramp-file-name (tramp-dissect-file-name filename)))))
3355 3358
3356(defun tramp-handle-access-file (filename string) 3359(defun tramp-handle-access-file (filename string)
3357 "Like `access-file' for Tramp files." 3360 "Like `access-file' for Tramp files."
@@ -3678,8 +3681,8 @@ User is always nil."
3678 ;; We do not want traces in the debug buffer. 3681 ;; We do not want traces in the debug buffer.
3679 (let ((tramp-verbose (min tramp-verbose 3))) 3682 (let ((tramp-verbose (min tramp-verbose 3)))
3680 (when (tramp-tramp-file-p filename) 3683 (when (tramp-tramp-file-p filename)
3681 (let* ((v (tramp-dissect-file-name filename)) 3684 (let* ((o (tramp-dissect-file-name filename))
3682 (p (tramp-get-connection-process v)) 3685 (p (tramp-get-connection-process o))
3683 (c (and (process-live-p p) 3686 (c (and (process-live-p p)
3684 (tramp-get-connection-property p "connected" nil)))) 3687 (tramp-get-connection-property p "connected" nil))))
3685 ;; We expand the file name only, if there is already a connection. 3688 ;; We expand the file name only, if there is already a connection.
@@ -3693,7 +3696,8 @@ User is always nil."
3693 ((eq identification 'user) (tramp-file-name-user-domain v)) 3696 ((eq identification 'user) (tramp-file-name-user-domain v))
3694 ((eq identification 'host) (tramp-file-name-host-port v)) 3697 ((eq identification 'host) (tramp-file-name-host-port v))
3695 ((eq identification 'localname) localname) 3698 ((eq identification 'localname) localname)
3696 ((eq identification 'hop) hop) 3699 ;; Hop exists only in original dissected file name.
3700 ((eq identification 'hop) (tramp-file-name-hop o))
3697 (t (tramp-make-tramp-file-name v 'noloc))))))))) 3701 (t (tramp-make-tramp-file-name v 'noloc)))))))))
3698 3702
3699(defun tramp-handle-file-selinux-context (_filename) 3703(defun tramp-handle-file-selinux-context (_filename)
@@ -3744,8 +3748,7 @@ User is always nil."
3744 (expand-file-name 3748 (expand-file-name
3745 symlink-target 3749 symlink-target
3746 (file-name-directory v2-localname)))) 3750 (file-name-directory v2-localname))))
3747 v2-localname) 3751 v2-localname))))
3748 'nohop)))
3749 (when (>= numchase numchase-limit) 3752 (when (>= numchase numchase-limit)
3750 (tramp-error 3753 (tramp-error
3751 v1 'file-error 3754 v1 'file-error
@@ -3904,8 +3907,7 @@ User is always nil."
3904 (cond 3907 (cond
3905 ((stringp remote-copy) 3908 ((stringp remote-copy)
3906 (file-local-copy 3909 (file-local-copy
3907 (tramp-make-tramp-file-name 3910 (tramp-make-tramp-file-name v remote-copy)))
3908 v remote-copy 'nohop)))
3909 ((stringp tramp-temp-buffer-file-name) 3911 ((stringp tramp-temp-buffer-file-name)
3910 (copy-file 3912 (copy-file
3911 filename tramp-temp-buffer-file-name 'ok) 3913 filename tramp-temp-buffer-file-name 'ok)
@@ -3948,7 +3950,7 @@ User is always nil."
3948 (or remote-copy (null tramp-temp-buffer-file-name))) 3950 (or remote-copy (null tramp-temp-buffer-file-name)))
3949 (delete-file local-copy)) 3951 (delete-file local-copy))
3950 (when (stringp remote-copy) 3952 (when (stringp remote-copy)
3951 (delete-file (tramp-make-tramp-file-name v remote-copy 'nohop)))) 3953 (delete-file (tramp-make-tramp-file-name v remote-copy))))
3952 3954
3953 ;; Result. 3955 ;; Result.
3954 (cons filename (cdr result))))) 3956 (cons filename (cdr result)))))
@@ -4088,15 +4090,10 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
4088 (and (tramp-sh-file-name-handler-p vec) 4090 (and (tramp-sh-file-name-handler-p vec)
4089 (not (tramp-get-method-parameter vec 'tramp-copy-program)))) 4091 (not (tramp-get-method-parameter vec 'tramp-copy-program))))
4090 4092
4091(defun tramp-compute-multi-hops (vec) 4093(defun tramp-add-hops (vec)
4092 "Expands VEC according to `tramp-default-proxies-alist'." 4094 "Add ad-hoc proxy definitions to `tramp-default-proxies-alist'."
4093 (let ((saved-tdpa tramp-default-proxies-alist) 4095 (when-let ((hops (tramp-file-name-hop vec))
4094 (target-alist `(,vec)) 4096 (item vec))
4095 (hops (or (tramp-file-name-hop vec) ""))
4096 (item vec)
4097 choices proxy)
4098
4099 ;; Ad-hoc proxy definitions.
4100 (dolist (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit))) 4097 (dolist (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit)))
4101 (let* ((host-port (tramp-file-name-host-port item)) 4098 (let* ((host-port (tramp-file-name-host-port item))
4102 (user-domain (tramp-file-name-user-domain item)) 4099 (user-domain (tramp-file-name-user-domain item))
@@ -4113,9 +4110,19 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
4113 (add-to-list 'tramp-default-proxies-alist entry) 4110 (add-to-list 'tramp-default-proxies-alist entry)
4114 (setq item (tramp-dissect-file-name proxy)))) 4111 (setq item (tramp-dissect-file-name proxy))))
4115 ;; Save the new value. 4112 ;; Save the new value.
4116 (when (and hops tramp-save-ad-hoc-proxies) 4113 (when tramp-save-ad-hoc-proxies
4117 (customize-save-variable 4114 (customize-save-variable
4118 'tramp-default-proxies-alist tramp-default-proxies-alist)) 4115 'tramp-default-proxies-alist tramp-default-proxies-alist))))
4116
4117(defun tramp-compute-multi-hops (vec)
4118 "Expands VEC according to `tramp-default-proxies-alist'."
4119 (let ((saved-tdpa tramp-default-proxies-alist)
4120 (target-alist `(,vec))
4121 (item vec)
4122 choices proxy)
4123
4124 ;; Ad-hoc proxy definitions.
4125 (tramp-add-hops vec)
4119 4126
4120 ;; Look for proxy hosts to be passed. 4127 ;; Look for proxy hosts to be passed.
4121 (setq choices tramp-default-proxies-alist) 4128 (setq choices tramp-default-proxies-alist)
@@ -5462,8 +5469,7 @@ This handles also chrooted environments, which are not regarded as local."
5462 (null tramp-crypt-enabled) 5469 (null tramp-crypt-enabled)
5463 ;; The local temp directory must be writable for the other user. 5470 ;; The local temp directory must be writable for the other user.
5464 (file-writable-p 5471 (file-writable-p
5465 (tramp-make-tramp-file-name 5472 (tramp-make-tramp-file-name vec tramp-compat-temporary-file-directory))
5466 vec tramp-compat-temporary-file-directory 'nohop))
5467 ;; On some systems, chown runs only for root. 5473 ;; On some systems, chown runs only for root.
5468 (or (zerop (user-uid)) 5474 (or (zerop (user-uid))
5469 (zerop (tramp-get-remote-uid vec 'integer)))))) 5475 (zerop (tramp-get-remote-uid vec 'integer))))))
@@ -5712,7 +5718,7 @@ Invokes `password-read' if available, `read-passwd' else."
5712 ;; multi-hop. 5718 ;; multi-hop.
5713 (tramp-get-connection-property 5719 (tramp-get-connection-property
5714 proc "password-vector" (process-get proc 'vector)) 5720 proc "password-vector" (process-get proc 'vector))
5715 'noloc 'nohop)) 5721 'noloc))
5716 (pw-prompt 5722 (pw-prompt
5717 (or prompt 5723 (or prompt
5718 (with-current-buffer (process-buffer proc) 5724 (with-current-buffer (process-buffer proc)
@@ -5789,7 +5795,7 @@ Invokes `password-read' if available, `read-passwd' else."
5789 (auth-source-forget 5795 (auth-source-forget
5790 `(:max 1 ,(and user-domain :user) ,user-domain 5796 `(:max 1 ,(and user-domain :user) ,user-domain
5791 :host ,host-port :port ,method)) 5797 :host ,host-port :port ,method))
5792 (password-cache-remove (tramp-make-tramp-file-name vec 'noloc 'nohop)))) 5798 (password-cache-remove (tramp-make-tramp-file-name vec 'noloc))))
5793 5799
5794(put #'tramp-clear-passwd 'tramp-suppress-trace t) 5800(put #'tramp-clear-passwd 'tramp-suppress-trace t)
5795 5801