aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2019-06-04 12:51:45 +0200
committerMichael Albinus2019-06-04 12:51:45 +0200
commit7aaf500701be3b51c686b7d86c9b505ef5fa9b8f (patch)
tree14f8c65a362a3b9059d7dcbc127d96a4cf7e6df7 /lisp
parent512f036404b559ae1e3456c05301104f5c422676 (diff)
downloademacs-7aaf500701be3b51c686b7d86c9b505ef5fa9b8f.tar.gz
emacs-7aaf500701be3b51c686b7d86c9b505ef5fa9b8f.zip
Stronger check for Tramp method
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection): Use `tramp-get-connection-name'. * lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link): * lisp/net/tramp-smb.el (tramp-smb-handle-make-symbolic-link): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-make-symbolic-link): Don't check remote TARGET. * lisp/net/tramp.el (tramp-dissect-file-name): Check for proper method. (tramp-file-name-for-operation): Take only 2nd argument into account for file name handler. (tramp-file-name-handler): Suppress checks for `file-remote-p'. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test02-file-name-dissect): Suppress check for wrong method. * test/lisp/net/tramp-tests.el (tramp--test-instrument-test-case): Dump *all* Tramp buffers. (tramp-test02-file-name-dissect) (tramp-test02-file-name-dissect-simplified) (tramp-test02-file-name-dissect-separate): Check also wrong method. (tramp-test03-file-name-defaults): Check, that the respective Tramp package is loaded. (tramp-test04-substitute-in-file-name) (tramp-test05-expand-file-name) (tramp-test06-directory-file-name, tramp-test44-auto-load): Suppress check for wrong method. (tramp-test30-make-process): Remove instrumentation code. (tramp-test31-interrupt-process, tramp-test36-vc-registered): Guarantee that connection is established prior starting process.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-gvfs.el2
-rw-r--r--lisp/net/tramp-rclone.el2
-rw-r--r--lisp/net/tramp-sh.el12
-rw-r--r--lisp/net/tramp-smb.el12
-rw-r--r--lisp/net/tramp-sudoedit.el14
-rw-r--r--lisp/net/tramp.el22
6 files changed, 39 insertions, 25 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 38102318240..17c2e79833b 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1765,7 +1765,7 @@ connection if a previous connection has died for some reason."
1765 ;; better solution? 1765 ;; better solution?
1766 (unless (get-buffer-process (tramp-get-connection-buffer vec)) 1766 (unless (get-buffer-process (tramp-get-connection-buffer vec))
1767 (let ((p (make-network-process 1767 (let ((p (make-network-process
1768 :name (tramp-buffer-name vec) 1768 :name (tramp-get-connection-name vec)
1769 :buffer (tramp-get-connection-buffer vec) 1769 :buffer (tramp-get-connection-buffer vec)
1770 :server t :host 'local :service t :noquery t))) 1770 :server t :host 'local :service t :noquery t)))
1771 (process-put p 'vector vec) 1771 (process-put p 'vector vec)
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 0148116d739..9e99493cbf6 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -543,7 +543,7 @@ connection if a previous connection has died for some reason."
543 ;; we create a dummy process. Maybe there is a better solution? 543 ;; we create a dummy process. Maybe there is a better solution?
544 (unless (get-buffer-process (tramp-get-connection-buffer vec)) 544 (unless (get-buffer-process (tramp-get-connection-buffer vec))
545 (let ((p (make-network-process 545 (let ((p (make-network-process
546 :name (tramp-buffer-name vec) 546 :name (tramp-get-connection-name vec)
547 :buffer (tramp-get-connection-buffer vec) 547 :buffer (tramp-get-connection-buffer vec)
548 :server t :host 'local :service t :noquery t))) 548 :server t :host 'local :service t :noquery t)))
549 (process-put p 'vector vec) 549 (process-put p 'vector vec)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 2d27baf454a..34fda5af176 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1027,11 +1027,13 @@ component is used as the target of the symlink."
1027 1027
1028 (with-parsed-tramp-file-name linkname nil 1028 (with-parsed-tramp-file-name linkname nil
1029 ;; If TARGET is a Tramp name, use just the localname component. 1029 ;; If TARGET is a Tramp name, use just the localname component.
1030 (when (and (tramp-tramp-file-p target) 1030 ;; Don't check for a proper method.
1031 (tramp-file-name-equal-p v (tramp-dissect-file-name target))) 1031 (let ((non-essential t))
1032 (setq target 1032 (when (and (tramp-tramp-file-p target)
1033 (tramp-file-name-localname 1033 (tramp-file-name-equal-p v (tramp-dissect-file-name target)))
1034 (tramp-dissect-file-name (expand-file-name target))))) 1034 (setq target
1035 (tramp-file-name-localname
1036 (tramp-dissect-file-name (expand-file-name target))))))
1035 1037
1036 ;; If TARGET is still remote, quote it. 1038 ;; If TARGET is still remote, quote it.
1037 (if (tramp-tramp-file-p target) 1039 (if (tramp-tramp-file-p target)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 9d15c0562bf..84725db2168 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1161,11 +1161,13 @@ component is used as the target of the symlink."
1161 1161
1162 (with-parsed-tramp-file-name linkname nil 1162 (with-parsed-tramp-file-name linkname nil
1163 ;; If TARGET is a Tramp name, use just the localname component. 1163 ;; If TARGET is a Tramp name, use just the localname component.
1164 (when (and (tramp-tramp-file-p target) 1164 ;; Don't check for a proper method.
1165 (tramp-file-name-equal-p v (tramp-dissect-file-name target))) 1165 (let ((non-essential t))
1166 (setq target 1166 (when (and (tramp-tramp-file-p target)
1167 (tramp-file-name-localname 1167 (tramp-file-name-equal-p v (tramp-dissect-file-name target)))
1168 (tramp-dissect-file-name (expand-file-name target))))) 1168 (setq target
1169 (tramp-file-name-localname
1170 (tramp-dissect-file-name (expand-file-name target))))))
1169 1171
1170 ;; If TARGET is still remote, quote it. 1172 ;; If TARGET is still remote, quote it.
1171 (if (tramp-tramp-file-p target) 1173 (if (tramp-tramp-file-p target)
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index 0d9e04d0bd1..f056e73366e 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -607,11 +607,13 @@ component is used as the target of the symlink."
607 607
608 (with-parsed-tramp-file-name linkname nil 608 (with-parsed-tramp-file-name linkname nil
609 ;; If TARGET is a Tramp name, use just the localname component. 609 ;; If TARGET is a Tramp name, use just the localname component.
610 (when (and (tramp-tramp-file-p target) 610 ;; Don't check for a proper method.
611 (tramp-file-name-equal-p v (tramp-dissect-file-name target))) 611 (let ((non-essential t))
612 (setq target 612 (when (and (tramp-tramp-file-p target)
613 (tramp-file-name-localname 613 (tramp-file-name-equal-p v (tramp-dissect-file-name target)))
614 (tramp-dissect-file-name (expand-file-name target))))) 614 (setq target
615 (tramp-file-name-localname
616 (tramp-dissect-file-name (expand-file-name target))))))
615 617
616 ;; If TARGET is still remote, quote it. 618 ;; If TARGET is still remote, quote it.
617 (if (tramp-tramp-file-p target) 619 (if (tramp-tramp-file-p target)
@@ -780,7 +782,7 @@ connection if a previous connection has died for some reason."
780 (throw 'non-essential 'non-essential)) 782 (throw 'non-essential 'non-essential))
781 783
782 (let ((p (make-network-process 784 (let ((p (make-network-process
783 :name (tramp-buffer-name vec) 785 :name (tramp-get-connection-name vec)
784 :buffer (tramp-get-connection-buffer vec) 786 :buffer (tramp-get-connection-buffer vec)
785 :server t :host 'local :service t :noquery t))) 787 :server t :host 'local :service t :noquery t)))
786 (process-put p 'vector vec) 788 (process-put p 'vector vec)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a2558184fb4..f6dd6b5866d 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1435,6 +1435,12 @@ default values are used."
1435 (setq v (make-tramp-file-name 1435 (setq v (make-tramp-file-name
1436 :method method :user user :domain domain :host host 1436 :method method :user user :domain domain :host host
1437 :port port :localname localname :hop hop)) 1437 :port port :localname localname :hop hop))
1438 ;; The method must be known.
1439 (unless (or (tramp-completion-mode-p)
1440 (string-equal method tramp-default-method-marker)
1441 (assoc method tramp-methods))
1442 (tramp-user-error
1443 v "Method `%s' is not known." method))
1438 ;; Only some methods from tramp-sh.el do support multi-hops. 1444 ;; Only some methods from tramp-sh.el do support multi-hops.
1439 (when (and 1445 (when (and
1440 hop 1446 hop
@@ -2175,17 +2181,16 @@ Must be handled by the callers."
2175 (if (file-name-absolute-p (nth 0 args)) 2181 (if (file-name-absolute-p (nth 0 args))
2176 (nth 0 args) 2182 (nth 0 args)
2177 default-directory)) 2183 default-directory))
2184 ;; STRING FILE.
2185 ;; Starting with Emacs 26.1, just the 2nd argument of
2186 ;; `make-symbolic-link' matters.
2187 ((eq operation 'make-symbolic-link) (nth 1 args))
2178 ;; FILE DIRECTORY resp FILE1 FILE2. 2188 ;; FILE DIRECTORY resp FILE1 FILE2.
2179 ((member operation 2189 ((member operation
2180 '(add-name-to-file copy-directory copy-file 2190 '(add-name-to-file copy-directory copy-file
2181 file-equal-p file-in-directory-p 2191 file-equal-p file-in-directory-p
2182 file-name-all-completions file-name-completion 2192 file-name-all-completions file-name-completion
2183 ;; Starting with Emacs 26.1, just the 2nd argument of 2193 file-newer-than-file-p rename-file))
2184 ;; `make-symbolic-link' matters. For backward
2185 ;; compatibility, we still accept the first argument as
2186 ;; file name to be checked. Handled properly in
2187 ;; `tramp-handle-*-make-symbolic-link'.
2188 file-newer-than-file-p make-symbolic-link rename-file))
2189 (cond 2194 (cond
2190 ((tramp-tramp-file-p (nth 0 args)) (nth 0 args)) 2195 ((tramp-tramp-file-p (nth 0 args)) (nth 0 args))
2191 ((tramp-tramp-file-p (nth 1 args)) (nth 1 args)) 2196 ((tramp-tramp-file-p (nth 1 args)) (nth 1 args))
@@ -2280,7 +2285,10 @@ preventing reentrant calls of Tramp.")
2280(defun tramp-file-name-handler (operation &rest args) 2285(defun tramp-file-name-handler (operation &rest args)
2281 "Invoke Tramp file name handler. 2286 "Invoke Tramp file name handler.
2282Falls back to normal file name handler if no Tramp file name handler exists." 2287Falls back to normal file name handler if no Tramp file name handler exists."
2283 (let ((filename (apply #'tramp-file-name-for-operation operation args))) 2288 (let ((filename (apply #'tramp-file-name-for-operation operation args))
2289 ;; `file-remote-p' is called for everything, even for symbolic
2290 ;; links which look remote. We don't want to get an error.
2291 (non-essential (or non-essential (eq operation 'file-remote-p))))
2284 (if (tramp-tramp-file-p filename) 2292 (if (tramp-tramp-file-p filename)
2285 (save-match-data 2293 (save-match-data
2286 (setq filename (tramp-replace-environment-variables filename)) 2294 (setq filename (tramp-replace-environment-variables filename))