aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-12-09 13:22:52 +0100
committerMichael Albinus2017-12-09 13:22:52 +0100
commit34bedf5d0b00713a2ba9baca5e025033477a0394 (patch)
treee3b7b865f43b76aa88e35768087272d3d158fed2
parentb067fa1f7d2b24b8fdb7f178924eb4e296559738 (diff)
downloademacs-34bedf5d0b00713a2ba9baca5e025033477a0394.tar.gz
emacs-34bedf5d0b00713a2ba9baca5e025033477a0394.zip
Sync with Tramp 2.4.0-pre
* doc/misc/trampver.texi: * lisp/net/trampver.el: Change version to "2.4.0-pre". * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): Use `tramp-handle-file-directory-p'. (tramp-adb-parse-device-names) (tramp-adb-handle-expand-file-name) (tramp-adb-handle-file-truename, tramp-adb-handle-process-file): Adapt `tramp-make-tramp-file-name' call. (tramp-adb-handle-file-directory-p): Remove. (tramp-adb-maybe-open-connection): Do not set tramp-current-*. * lisp/net/tramp-cache.el (tramp-get-hash-table): Adapt `tramp-make-tramp-file-name' call. * lisp/net/tramp-cmds.el (tramp-cleanup-connection): Do not set tramp-current-*. * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Use `tramp-handle-file-directory-p'. (tramp-gvfs-dbus-event-error): Trace with verbosity 6. (tramp-gvfs-do-copy-or-rename-file): Use `file-truename'. (tramp-gvfs-handle-file-directory-p): Remove. (tramp-gvfs-handler-askpassword): Do not set tramp-current-*. * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-start-file-process) (tramp-maybe-open-connection, tramp-get-remote-path): Do not set tramp-current-*. (tramp-maybe-open-connection): Set "password-vector" property. * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use `tramp-handle-file-accessible-directory-p' and `tramp-handle-file-directory-p'. (tramp-smb-handle-copy-directory, tramp-smb-handle-file-acl) (tramp-smb-handle-set-file-acl) (tramp-smb-maybe-open-connection): Do not set tramp-current-*. (tramp-smb-handle-file-directory-p): Remove. (tramp-smb-handle-make-symbolic-link): Use `tramp-get-connection-buffer' rather than `buffer-name'. * lisp/net/tramp.el (tramp-current-method, tramp-current-user) (tramp-current-domain, tramp-current-host) (tramp-current-port): Remove. (tramp-dissect-file-name): No special handling of localname anymore. (tramp-make-tramp-file-name): Reimplemnt with new signature. (tramp-completion-make-tramp-file-name): Fix docstring. (tramp-get-buffer, tramp-handle-file-name-as-directory) (tramp-handle-file-name-directory) (tramp-check-cached-permissions, tramp-local-host-p) (tramp-get-remote-tmpdir, tramp-clear-passwd): Adapt `tramp-make-tramp-file-name' call. (tramp-completion-handle-file-name-all-completions) (tramp-action-login, tramp-read-passwd): Do not set tramp-current-*. (tramp-handle-file-directory-p): New defun. (tramp-handle-verify-visited-file-modtime): Remove superfluous `with-parsed-tramp-file-name'. (tramp-process-actions, tramp-read-passwd): Use "password-vector" property. (tramp-call-process, tramp-call-process-region): No special setting of vec. (tramp-read-passwd): Handle "login-as" property. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Special code for "smb".
-rw-r--r--doc/misc/trampver.texi2
-rw-r--r--lisp/net/tramp-adb.el44
-rw-r--r--lisp/net/tramp-cache.el5
-rw-r--r--lisp/net/tramp-cmds.el11
-rw-r--r--lisp/net/tramp-gvfs.el19
-rw-r--r--lisp/net/tramp-sh.el44
-rw-r--r--lisp/net/tramp-smb.el143
-rw-r--r--lisp/net/tramp.el316
-rw-r--r--lisp/net/trampver.el6
-rw-r--r--test/lisp/net/tramp-tests.el12
10 files changed, 244 insertions, 358 deletions
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index 5d9dcc5635d..3122facc5e8 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -8,7 +8,7 @@
8@c In the Tramp GIT, the version number is auto-frobbed from 8@c In the Tramp GIT, the version number is auto-frobbed from
9@c configure.ac, so you should edit that file and run 9@c configure.ac, so you should edit that file and run
10@c "autoconf && ./configure" to change the version number. 10@c "autoconf && ./configure" to change the version number.
11@set trampver 2.3.3-pre 11@set trampver 2.4.0-pre
12 12
13@c Other flags from configuration 13@c Other flags from configuration
14@set instprefix /usr/local 14@set instprefix /usr/local
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 8399c02923d..f1753cec53e 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -114,7 +114,7 @@ It is used for TCP/IP devices."
114 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) 114 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
115 (file-acl . ignore) 115 (file-acl . ignore)
116 (file-attributes . tramp-adb-handle-file-attributes) 116 (file-attributes . tramp-adb-handle-file-attributes)
117 (file-directory-p . tramp-adb-handle-file-directory-p) 117 (file-directory-p . tramp-handle-file-directory-p)
118 (file-equal-p . tramp-handle-file-equal-p) 118 (file-equal-p . tramp-handle-file-equal-p)
119 ;; FIXME: This is too sloppy. 119 ;; FIXME: This is too sloppy.
120 (file-executable-p . tramp-handle-file-exists-p) 120 (file-executable-p . tramp-handle-file-exists-p)
@@ -199,11 +199,13 @@ pass to the OPERATION."
199 (with-temp-buffer 199 (with-temp-buffer
200 ;; `call-process' does not react on timer under MS Windows. 200 ;; `call-process' does not react on timer under MS Windows.
201 ;; That's why we use `start-process'. 201 ;; That's why we use `start-process'.
202 ;; We don't know yet whether we need a user or host name for the
203 ;; connection vector. We assume we don't, it will be OK in most
204 ;; of the cases. Otherwise, there might be an additional trace
205 ;; buffer, which doesn't hurt.
202 (let ((p (start-process 206 (let ((p (start-process
203 tramp-adb-program (current-buffer) tramp-adb-program "devices")) 207 tramp-adb-program (current-buffer) tramp-adb-program "devices"))
204 (v (make-tramp-file-name 208 (v (make-tramp-file-name :method tramp-adb-method))
205 :method tramp-adb-method :user tramp-current-user
206 :host tramp-current-host))
207 result) 209 result)
208 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " ")) 210 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
209 (process-put p 'adjust-window-size-function 'ignore) 211 (process-put p 'adjust-window-size-function 'ignore)
@@ -245,16 +247,8 @@ pass to the OPERATION."
245 ;; be problems with UNC shares or Cygwin mounts. 247 ;; be problems with UNC shares or Cygwin mounts.
246 (let ((default-directory (tramp-compat-temporary-file-directory))) 248 (let ((default-directory (tramp-compat-temporary-file-directory)))
247 (tramp-make-tramp-file-name 249 (tramp-make-tramp-file-name
248 method user domain host port 250 v (tramp-drop-volume-letter
249 (tramp-drop-volume-letter 251 (tramp-run-real-handler 'expand-file-name (list localname))))))))
250 (tramp-run-real-handler
251 'expand-file-name (list localname))))))))
252
253(defun tramp-adb-handle-file-directory-p (filename)
254 "Like `file-directory-p' for Tramp files."
255 (eq (tramp-compat-file-attribute-type
256 (file-attributes (file-truename filename)))
257 t))
258 252
259(defun tramp-adb-handle-file-system-info (filename) 253(defun tramp-adb-handle-file-system-info (filename)
260 "Like `file-system-info' for Tramp files." 254 "Like `file-system-info' for Tramp files."
@@ -288,7 +282,7 @@ pass to the OPERATION."
288 "%s%s" 282 "%s%s"
289 (with-parsed-tramp-file-name (expand-file-name filename) nil 283 (with-parsed-tramp-file-name (expand-file-name filename) nil
290 (tramp-make-tramp-file-name 284 (tramp-make-tramp-file-name
291 method user domain host port 285 v
292 (with-tramp-file-property v localname "file-truename" 286 (with-tramp-file-property v localname "file-truename"
293 (let ((result nil)) ; result steps in reverse order 287 (let ((result nil)) ; result steps in reverse order
294 (tramp-message v 4 "Finding true name for `%s'" filename) 288 (tramp-message v 4 "Finding true name for `%s'" filename)
@@ -316,12 +310,10 @@ pass to the OPERATION."
316 (tramp-compat-file-attribute-type 310 (tramp-compat-file-attribute-type
317 (file-attributes 311 (file-attributes
318 (tramp-make-tramp-file-name 312 (tramp-make-tramp-file-name
319 method user domain host port 313 v (mapconcat 'identity
320 (mapconcat 'identity 314 (append
321 (append '("") 315 '("") (reverse result) (list thisstep))
322 (reverse result) 316 "/")))))
323 (list thisstep))
324 "/")))))
325 (cond ((string= "." thisstep) 317 (cond ((string= "." thisstep)
326 (tramp-message v 5 "Ignoring step `.'")) 318 (tramp-message v 5 "Ignoring step `.'"))
327 ((string= ".." thisstep) 319 ((string= ".." thisstep)
@@ -861,8 +853,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
861 (setq input (with-parsed-tramp-file-name infile nil localname)) 853 (setq input (with-parsed-tramp-file-name infile nil localname))
862 ;; INFILE must be copied to remote host. 854 ;; INFILE must be copied to remote host.
863 (setq input (tramp-make-tramp-temp-file v) 855 (setq input (tramp-make-tramp-temp-file v)
864 tmpinput (tramp-make-tramp-file-name 856 tmpinput (tramp-make-tramp-file-name v input))
865 method user domain host port input))
866 (copy-file infile tmpinput t))) 857 (copy-file infile tmpinput t)))
867 (when input (setq command (format "%s <%s" command input))) 858 (when input (setq command (format "%s <%s" command input)))
868 859
@@ -895,8 +886,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
895 ;; stderr must be copied to remote host. The temporary 886 ;; stderr must be copied to remote host. The temporary
896 ;; file must be deleted after execution. 887 ;; file must be deleted after execution.
897 (setq stderr (tramp-make-tramp-temp-file v) 888 (setq stderr (tramp-make-tramp-temp-file v)
898 tmpstderr (tramp-make-tramp-file-name 889 tmpstderr (tramp-make-tramp-file-name v stderr))))
899 method user domain host port stderr))))
900 ;; stderr to be discarded. 890 ;; stderr to be discarded.
901 ((null (cadr destination)) 891 ((null (cadr destination))
902 (setq stderr "/dev/null")))) 892 (setq stderr "/dev/null"))))
@@ -1252,10 +1242,6 @@ connection if a previous connection has died for some reason."
1252 (user (tramp-file-name-user vec)) 1242 (user (tramp-file-name-user vec))
1253 (device (tramp-adb-get-device vec))) 1243 (device (tramp-adb-get-device vec)))
1254 1244
1255 ;; Set variables for proper tracing in `tramp-adb-parse-device-names'.
1256 (setq tramp-current-user (tramp-file-name-user vec)
1257 tramp-current-host (tramp-file-name-host vec))
1258
1259 ;; Maybe we know already that "su" is not supported. We cannot 1245 ;; Maybe we know already that "su" is not supported. We cannot
1260 ;; use a connection property, because we have not checked yet 1246 ;; use a connection property, because we have not checked yet
1261 ;; whether it is still the same device. 1247 ;; whether it is still the same device.
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index dc97501be3d..87ec3c2a130 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -98,10 +98,7 @@ matching entries of `tramp-connection-properties'."
98 (dolist (elt tramp-connection-properties) 98 (dolist (elt tramp-connection-properties)
99 (when (string-match 99 (when (string-match
100 (or (nth 0 elt) "") 100 (or (nth 0 elt) "")
101 (tramp-make-tramp-file-name 101 (tramp-make-tramp-file-name key 'noloc 'nohop))
102 (tramp-file-name-method key) (tramp-file-name-user key)
103 (tramp-file-name-domain key) (tramp-file-name-host key)
104 (tramp-file-name-port key) nil))
105 (tramp-set-connection-property key (nth 1 elt) (nth 2 elt))))) 102 (tramp-set-connection-property key (nth 1 elt) (nth 2 elt)))))
106 hash))) 103 hash)))
107 104
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 37a6521680b..35c00a01558 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -80,16 +80,7 @@ When called interactively, a Tramp connection has to be selected."
80 ;; Return nil when there is no Tramp connection. 80 ;; Return nil when there is no Tramp connection.
81 (list 81 (list
82 (let ((connections 82 (let ((connections
83 (mapcar 83 (mapcar 'tramp-make-tramp-file-name (tramp-list-connections)))
84 (lambda (x)
85 (tramp-make-tramp-file-name
86 (tramp-file-name-method x)
87 (tramp-file-name-user x)
88 (tramp-file-name-domain x)
89 (tramp-file-name-host x)
90 (tramp-file-name-port x)
91 (tramp-file-name-localname x)))
92 (tramp-list-connections)))
93 name) 84 name)
94 85
95 (when connections 86 (when connections
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 1d1b04b44f8..d862e957ce8 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -429,6 +429,7 @@ Every entry is a list (NAME ADDRESS).")
429 ("gvfs-trash" . "trash")) 429 ("gvfs-trash" . "trash"))
430 "List of cons cells, mapping \"gvfs-<command>\" to \"gio <command>\".") 430 "List of cons cells, mapping \"gvfs-<command>\" to \"gio <command>\".")
431 431
432;; <http://www.pygtk.org/docs/pygobject/gio-constants.html>
432(defconst tramp-gvfs-file-attributes 433(defconst tramp-gvfs-file-attributes
433 '("name" 434 '("name"
434 "type" 435 "type"
@@ -495,7 +496,7 @@ Every entry is a list (NAME ADDRESS).")
495 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) 496 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
496 (file-acl . ignore) 497 (file-acl . ignore)
497 (file-attributes . tramp-gvfs-handle-file-attributes) 498 (file-attributes . tramp-gvfs-handle-file-attributes)
498 (file-directory-p . tramp-gvfs-handle-file-directory-p) 499 (file-directory-p . tramp-handle-file-directory-p)
499 (file-equal-p . tramp-handle-file-equal-p) 500 (file-equal-p . tramp-handle-file-equal-p)
500 (file-executable-p . tramp-gvfs-handle-file-executable-p) 501 (file-executable-p . tramp-gvfs-handle-file-executable-p)
501 (file-exists-p . tramp-handle-file-exists-p) 502 (file-exists-p . tramp-handle-file-exists-p)
@@ -642,7 +643,7 @@ is no information where to trace the message.")
642(defun tramp-gvfs-dbus-event-error (event err) 643(defun tramp-gvfs-dbus-event-error (event err)
643 "Called when a D-Bus error message arrives, see `dbus-event-error-functions'." 644 "Called when a D-Bus error message arrives, see `dbus-event-error-functions'."
644 (when tramp-gvfs-dbus-event-vector 645 (when tramp-gvfs-dbus-event-vector
645 (tramp-message tramp-gvfs-dbus-event-vector 10 "%S" event) 646 (tramp-message tramp-gvfs-dbus-event-vector 6 "%S" event)
646 (tramp-error tramp-gvfs-dbus-event-vector 'file-error "%s" (cadr err)))) 647 (tramp-error tramp-gvfs-dbus-event-vector 'file-error "%s" (cadr err))))
647 648
648;; `dbus-event-error-hooks' has been renamed to 649;; `dbus-event-error-hooks' has been renamed to
@@ -675,6 +676,7 @@ file names."
675 (unless (memq op '(copy rename)) 676 (unless (memq op '(copy rename))
676 (error "Unknown operation `%s', must be `copy' or `rename'" op)) 677 (error "Unknown operation `%s', must be `copy' or `rename'" op))
677 678
679 (setq filename (file-truename filename))
678 (if (file-directory-p filename) 680 (if (file-directory-p filename)
679 (progn 681 (progn
680 (copy-directory filename newname keep-date t) 682 (copy-directory filename newname keep-date t)
@@ -1043,11 +1045,6 @@ If FILE-SYSTEM is non-nil, return file system attributes."
1043 res-device 1045 res-device
1044 ))))) 1046 )))))
1045 1047
1046(defun tramp-gvfs-handle-file-directory-p (filename)
1047 "Like `file-directory-p' for Tramp files."
1048 (eq t (tramp-compat-file-attribute-type
1049 (file-attributes (file-truename filename)))))
1050
1051(defun tramp-gvfs-handle-file-executable-p (filename) 1048(defun tramp-gvfs-handle-file-executable-p (filename)
1052 "Like `file-executable-p' for Tramp files." 1049 "Like `file-executable-p' for Tramp files."
1053 (with-parsed-tramp-file-name filename nil 1050 (with-parsed-tramp-file-name filename nil
@@ -1363,13 +1360,7 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
1363 (unless (tramp-get-connection-property l "first-password-request" nil) 1360 (unless (tramp-get-connection-property l "first-password-request" nil)
1364 (tramp-clear-passwd l)) 1361 (tramp-clear-passwd l))
1365 1362
1366 ;; Set variables for computing the prompt for reading password. 1363 (setq password (tramp-read-passwd
1367 (setq tramp-current-method l-method
1368 tramp-current-user user
1369 tramp-current-domain l-domain
1370 tramp-current-host l-host
1371 tramp-current-port l-port
1372 password (tramp-read-passwd
1373 (tramp-get-connection-process l) pw-prompt)) 1364 (tramp-get-connection-process l) pw-prompt))
1374 1365
1375 ;; Return result. 1366 ;; Return result.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 14c1a4049aa..1ca19e05f20 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2362,15 +2362,6 @@ The method used must be an out-of-band method."
2362 (expand-file-name ".." tmpfile) 'recursive) 2362 (expand-file-name ".." tmpfile) 'recursive)
2363 (delete-file tmpfile))))) 2363 (delete-file tmpfile)))))
2364 2364
2365 ;; Set variables for computing the prompt for reading password.
2366 (setq tramp-current-method (tramp-file-name-method v)
2367 tramp-current-user (or (tramp-file-name-user v)
2368 (tramp-get-connection-property
2369 v "login-as" nil))
2370 tramp-current-domain (tramp-file-name-domain v)
2371 tramp-current-host (tramp-file-name-host v)
2372 tramp-current-port (tramp-file-name-port v))
2373
2374 ;; Check which ones of source and target are Tramp files. 2365 ;; Check which ones of source and target are Tramp files.
2375 (setq source (funcall 2366 (setq source (funcall
2376 (if (and (file-directory-p filename) 2367 (if (and (file-directory-p filename)
@@ -2866,13 +2857,7 @@ the result will be a local, non-Tramp, file name."
2866 ;; We discard hops, if existing, that's why we cannot use 2857 ;; We discard hops, if existing, that's why we cannot use
2867 ;; `file-remote-p'. 2858 ;; `file-remote-p'.
2868 (prompt (format "PS1=%s %s" 2859 (prompt (format "PS1=%s %s"
2869 (tramp-make-tramp-file-name 2860 (tramp-make-tramp-file-name v nil 'nohop)
2870 (tramp-file-name-method v)
2871 (tramp-file-name-user v)
2872 (tramp-file-name-domain v)
2873 (tramp-file-name-host v)
2874 (tramp-file-name-port v)
2875 (tramp-file-name-localname v))
2876 tramp-initial-end-of-output)) 2861 tramp-initial-end-of-output))
2877 ;; We use as environment the difference to toplevel 2862 ;; We use as environment the difference to toplevel
2878 ;; `process-environment'. 2863 ;; `process-environment'.
@@ -4755,8 +4740,7 @@ connection if a previous connection has died for some reason."
4755 (set-process-sentinel p 'tramp-process-sentinel) 4740 (set-process-sentinel p 'tramp-process-sentinel)
4756 (process-put p 'adjust-window-size-function 'ignore) 4741 (process-put p 'adjust-window-size-function 'ignore)
4757 (set-process-query-on-exit-flag p nil) 4742 (set-process-query-on-exit-flag p nil)
4758 (setq tramp-current-connection (cons vec (current-time)) 4743 (setq tramp-current-connection (cons vec (current-time)))
4759 tramp-current-host (system-name))
4760 4744
4761 (tramp-message 4745 (tramp-message
4762 vec 6 "%s" (mapconcat 'identity (process-command p) " ")) 4746 vec 6 "%s" (mapconcat 'identity (process-command p) " "))
@@ -4810,16 +4794,15 @@ connection if a previous connection has died for some reason."
4810 4794
4811 ;; Check, whether there is a restricted shell. 4795 ;; Check, whether there is a restricted shell.
4812 (dolist (elt tramp-restricted-shell-hosts-alist) 4796 (dolist (elt tramp-restricted-shell-hosts-alist)
4813 (when (string-match elt tramp-current-host) 4797 (when (string-match elt l-host)
4814 (setq r-shell t))) 4798 (setq r-shell t)))
4815 4799
4816 ;; Set variables for computing the prompt for 4800 ;; Set password prompt vector.
4817 ;; reading password. 4801 (tramp-set-connection-property
4818 (setq tramp-current-method l-method 4802 p "password-vector"
4819 tramp-current-user l-user 4803 (make-tramp-file-name
4820 tramp-current-domain l-domain 4804 :method l-method :user l-user :domain l-domain
4821 tramp-current-host l-host 4805 :host l-host :port l-port))
4822 tramp-current-port l-port)
4823 4806
4824 ;; Add login environment. 4807 ;; Add login environment.
4825 (when login-env 4808 (when login-env
@@ -5244,14 +5227,7 @@ Nonexistent directories are removed from spec."
5244 (lambda (x) 5227 (lambda (x)
5245 (and 5228 (and
5246 (stringp x) 5229 (stringp x)
5247 (file-directory-p 5230 (file-directory-p (tramp-make-tramp-file-name vec x))
5248 (tramp-make-tramp-file-name
5249 (tramp-file-name-method vec)
5250 (tramp-file-name-user vec)
5251 (tramp-file-name-domain vec)
5252 (tramp-file-name-host vec)
5253 (tramp-file-name-port vec)
5254 x))
5255 x)) 5231 x))
5256 remote-path))))) 5232 remote-path)))))
5257 5233
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index a4d4b4e0bcf..5a8299b1da1 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -228,10 +228,10 @@ See `tramp-actions-before-shell' for more info.")
228 (dired-compress-file . ignore) 228 (dired-compress-file . ignore)
229 (dired-uncache . tramp-handle-dired-uncache) 229 (dired-uncache . tramp-handle-dired-uncache)
230 (expand-file-name . tramp-smb-handle-expand-file-name) 230 (expand-file-name . tramp-smb-handle-expand-file-name)
231 (file-accessible-directory-p . tramp-smb-handle-file-directory-p) 231 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
232 (file-acl . tramp-smb-handle-file-acl) 232 (file-acl . tramp-smb-handle-file-acl)
233 (file-attributes . tramp-smb-handle-file-attributes) 233 (file-attributes . tramp-smb-handle-file-attributes)
234 (file-directory-p . tramp-smb-handle-file-directory-p) 234 (file-directory-p . tramp-handle-file-directory-p)
235 (file-file-equal-p . tramp-handle-file-equal-p) 235 (file-file-equal-p . tramp-handle-file-equal-p)
236 (file-executable-p . tramp-handle-file-exists-p) 236 (file-executable-p . tramp-handle-file-exists-p)
237 (file-exists-p . tramp-handle-file-exists-p) 237 (file-exists-p . tramp-handle-file-exists-p)
@@ -449,13 +449,6 @@ pass to the OPERATION."
449 (if (not (file-directory-p newname)) 449 (if (not (file-directory-p newname))
450 (make-directory newname parents)) 450 (make-directory newname parents))
451 451
452 ;; Set variables for computing the prompt for reading password.
453 (setq tramp-current-method method
454 tramp-current-user user
455 tramp-current-domain domain
456 tramp-current-host host
457 tramp-current-port port)
458
459 (let* ((share (tramp-smb-get-share v)) 452 (let* ((share (tramp-smb-get-share v))
460 (localname (file-name-as-directory 453 (localname (file-name-as-directory
461 (replace-regexp-in-string 454 (replace-regexp-in-string
@@ -739,62 +732,56 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
739 732
740(defun tramp-smb-handle-file-acl (filename) 733(defun tramp-smb-handle-file-acl (filename)
741 "Like `file-acl' for Tramp files." 734 "Like `file-acl' for Tramp files."
742 (with-parsed-tramp-file-name filename nil 735 (ignore-errors
743 (with-tramp-file-property v localname "file-acl" 736 (with-parsed-tramp-file-name filename nil
744 (when (executable-find tramp-smb-acl-program) 737 (with-tramp-file-property v localname "file-acl"
745 ;; Set variables for computing the prompt for reading password. 738 (when (executable-find tramp-smb-acl-program)
746 (setq tramp-current-method method 739 (let* ((share (tramp-smb-get-share v))
747 tramp-current-user user 740 (localname (replace-regexp-in-string
748 tramp-current-domain domain 741 "\\\\" "/" (tramp-smb-get-localname v)))
749 tramp-current-host host 742 (args (list (concat "//" host "/" share) "-E")))
750 tramp-current-port port) 743
751 744 (if (not (zerop (length user)))
752 (let* ((share (tramp-smb-get-share v)) 745 (setq args (append args (list "-U" user)))
753 (localname (replace-regexp-in-string 746 (setq args (append args (list "-N"))))
754 "\\\\" "/" (tramp-smb-get-localname v))) 747
755 (args (list (concat "//" host "/" share) "-E"))) 748 (when domain (setq args (append args (list "-W" domain))))
756 749 (when port (setq args (append args (list "-p" port))))
757 (if (not (zerop (length user))) 750 (when tramp-smb-conf
758 (setq args (append args (list "-U" user))) 751 (setq args (append args (list "-s" tramp-smb-conf))))
759 (setq args (append args (list "-N")))) 752 (setq
760 753 args
761 (when domain (setq args (append args (list "-W" domain)))) 754 (append args (list (tramp-unquote-shell-quote-argument localname)
762 (when port (setq args (append args (list "-p" port)))) 755 "2>/dev/null")))
763 (when tramp-smb-conf 756
764 (setq args (append args (list "-s" tramp-smb-conf)))) 757 (unwind-protect
765 (setq 758 (with-temp-buffer
766 args 759 ;; Set the transfer process properties.
767 (append args (list (tramp-unquote-shell-quote-argument localname) 760 (tramp-set-connection-property
768 "2>/dev/null"))) 761 v "process-name" (buffer-name (current-buffer)))
769 762 (tramp-set-connection-property
770 (unwind-protect 763 v "process-buffer" (current-buffer))
771 (with-temp-buffer 764
772 ;; Set the transfer process properties. 765 ;; Use an asynchronous process. By this, password can
773 (tramp-set-connection-property 766 ;; be handled.
774 v "process-name" (buffer-name (current-buffer))) 767 (let ((p (apply
775 (tramp-set-connection-property 768 'start-process
776 v "process-buffer" (current-buffer)) 769 (tramp-get-connection-name v)
777 770 (tramp-get-connection-buffer v)
778 ;; Use an asynchronous processes. By this, password 771 tramp-smb-acl-program args)))
779 ;; can be handled. 772
780 (let ((p (apply 773 (tramp-message
781 'start-process 774 v 6 "%s" (mapconcat 'identity (process-command p) " "))
782 (tramp-get-connection-name v) 775 (tramp-set-connection-property p "vector" v)
783 (tramp-get-connection-buffer v) 776 (process-put p 'adjust-window-size-function 'ignore)
784 tramp-smb-acl-program args))) 777 (set-process-query-on-exit-flag p nil)
785 778 (tramp-process-actions p v nil tramp-smb-actions-get-acl)
786 (tramp-message 779 (when (> (point-max) (point-min))
787 v 6 "%s" (mapconcat 'identity (process-command p) " ")) 780 (substring-no-properties (buffer-string)))))
788 (tramp-set-connection-property p "vector" v) 781
789 (process-put p 'adjust-window-size-function 'ignore) 782 ;; Reset the transfer process properties.
790 (set-process-query-on-exit-flag p nil) 783 (tramp-set-connection-property v "process-name" nil)
791 (tramp-process-actions p v nil tramp-smb-actions-get-acl) 784 (tramp-set-connection-property v "process-buffer" nil))))))))
792 (when (> (point-max) (point-min))
793 (substring-no-properties (buffer-string)))))
794
795 ;; Reset the transfer process properties.
796 (tramp-set-connection-property v "process-name" nil)
797 (tramp-set-connection-property v "process-buffer" nil)))))))
798 785
799(defun tramp-smb-handle-file-attributes (filename &optional id-format) 786(defun tramp-smb-handle-file-attributes (filename &optional id-format)
800 "Like `file-attributes' for Tramp files." 787 "Like `file-attributes' for Tramp files."
@@ -911,13 +898,6 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
911 (list id link uid gid atime mtime ctime size mode nil inode 898 (list id link uid gid atime mtime ctime size mode nil inode
912 (tramp-get-device vec)))))))) 899 (tramp-get-device vec))))))))
913 900
914(defun tramp-smb-handle-file-directory-p (filename)
915 "Like `file-directory-p' for Tramp files."
916 (and (file-exists-p filename)
917 (eq ?d
918 (aref (tramp-compat-file-attribute-modes (file-attributes filename))
919 0))))
920
921(defun tramp-smb-handle-file-local-copy (filename) 901(defun tramp-smb-handle-file-local-copy (filename)
922 "Like `file-local-copy' for Tramp files." 902 "Like `file-local-copy' for Tramp files."
923 (with-parsed-tramp-file-name (file-truename filename) nil 903 (with-parsed-tramp-file-name (file-truename filename) nil
@@ -1222,7 +1202,7 @@ component is used as the target of the symlink."
1222 (tramp-error 1202 (tramp-error
1223 v 'file-error 1203 v 'file-error
1224 "error with make-symbolic-link, see buffer `%s' for details" 1204 "error with make-symbolic-link, see buffer `%s' for details"
1225 (buffer-name))))))) 1205 (tramp-get-connection-buffer v)))))))
1226 1206
1227(defun tramp-smb-handle-process-file 1207(defun tramp-smb-handle-process-file
1228 (program &optional infile destination display &rest args) 1208 (program &optional infile destination display &rest args)
@@ -1403,15 +1383,9 @@ component is used as the target of the symlink."
1403 "Like `set-file-acl' for Tramp files." 1383 "Like `set-file-acl' for Tramp files."
1404 (ignore-errors 1384 (ignore-errors
1405 (with-parsed-tramp-file-name filename nil 1385 (with-parsed-tramp-file-name filename nil
1406 (when (and (stringp acl-string) (executable-find tramp-smb-acl-program)) 1386 (tramp-set-file-property v localname "file-acl" 'undef)
1407 ;; Set variables for computing the prompt for reading password.
1408 (setq tramp-current-method method
1409 tramp-current-user user
1410 tramp-current-domain domain
1411 tramp-current-host host
1412 tramp-current-port port)
1413 (tramp-set-file-property v localname "file-acl" 'undef)
1414 1387
1388 (when (and (stringp acl-string) (executable-find tramp-smb-acl-program))
1415 (let* ((share (tramp-smb-get-share v)) 1389 (let* ((share (tramp-smb-get-share v))
1416 (localname (replace-regexp-in-string 1390 (localname (replace-regexp-in-string
1417 "\\\\" "/" (tramp-smb-get-localname v))) 1391 "\\\\" "/" (tramp-smb-get-localname v)))
@@ -1971,13 +1945,6 @@ If ARGUMENT is non-nil, use it as argument for
1971 (process-put p 'adjust-window-size-function 'ignore) 1945 (process-put p 'adjust-window-size-function 'ignore)
1972 (set-process-query-on-exit-flag p nil) 1946 (set-process-query-on-exit-flag p nil)
1973 1947
1974 ;; Set variables for computing the prompt for reading password.
1975 (setq tramp-current-method tramp-smb-method
1976 tramp-current-user user
1977 tramp-current-domain domain
1978 tramp-current-host host
1979 tramp-current-port port)
1980
1981 (condition-case err 1948 (condition-case err
1982 (let (tramp-message-show-message) 1949 (let (tramp-message-show-message)
1983 ;; Play login scenario. 1950 ;; Play login scenario.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 2fdc651a372..b933778447c 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1182,21 +1182,6 @@ means to use always cached values for the directory contents."
1182 1182
1183;;; Internal Variables: 1183;;; Internal Variables:
1184 1184
1185(defvar tramp-current-method nil
1186 "Connection method for this *tramp* buffer.")
1187
1188(defvar tramp-current-user nil
1189 "Remote login name for this *tramp* buffer.")
1190
1191(defvar tramp-current-domain nil
1192 "Remote domain name for this *tramp* buffer.")
1193
1194(defvar tramp-current-host nil
1195 "Remote host for this *tramp* buffer.")
1196
1197(defvar tramp-current-port nil
1198 "Remote port for this *tramp* buffer.")
1199
1200(defvar tramp-current-connection nil 1185(defvar tramp-current-connection nil
1201 "Last connection timestamp.") 1186 "Last connection timestamp.")
1202 1187
@@ -1390,7 +1375,7 @@ values."
1390 1375
1391 (make-tramp-file-name 1376 (make-tramp-file-name
1392 :method method :user user :domain domain :host host :port port 1377 :method method :user user :domain domain :host host :port port
1393 :localname (or localname "") :hop hop))))) 1378 :localname localname :hop hop)))))
1394 1379
1395(defun tramp-buffer-name (vec) 1380(defun tramp-buffer-name (vec)
1396 "A name for the connection buffer VEC." 1381 "A name for the connection buffer VEC."
@@ -1401,30 +1386,64 @@ values."
1401 (format "*tramp/%s %s@%s*" method user-domain host-port) 1386 (format "*tramp/%s %s@%s*" method user-domain host-port)
1402 (format "*tramp/%s %s*" method host-port)))) 1387 (format "*tramp/%s %s*" method host-port))))
1403 1388
1404(defun tramp-make-tramp-file-name 1389(defun tramp-make-tramp-file-name (&rest args)
1405 (method user domain host port localname &optional hop) 1390 "Construct a Tramp file name from ARGS.
1406 "Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME. 1391
1407When not nil, optional DOMAIN, PORT and HOP are used." 1392ARGS could have two different signatures. The first one is of
1408 (concat tramp-prefix-format hop 1393type (VEC &optional LOCALNAME HOP).
1409 (unless (or (zerop (length method)) 1394If LOCALNAME is nil, the value in VEC is used. If it is a
1410 (zerop (length tramp-postfix-method-format))) 1395symbol, a null localname will be used. Otherwise, LOCALNAME is
1411 (concat method tramp-postfix-method-format)) 1396expected to be a string, which will be used.
1412 user 1397If HOP is nil, the value in VEC is used. If it is a symbol, a
1413 (unless (zerop (length domain)) 1398null hop will be used. Otherwise, HOP is expected to be a
1414 (concat tramp-prefix-domain-format domain)) 1399string, which will be used.
1415 (unless (zerop (length user)) 1400
1416 tramp-postfix-user-format) 1401The other signature exists for backward compatibility. It has
1417 (when host 1402the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
1418 (if (string-match tramp-ipv6-regexp host) 1403 (let (method user domain host port localname hop)
1419 (concat tramp-prefix-ipv6-format host tramp-postfix-ipv6-format) 1404 (cond
1420 host)) 1405 ((tramp-file-name-p (car args))
1421 (unless (zerop (length port)) 1406 (setq method (tramp-file-name-method (car args))
1422 (concat tramp-prefix-port-format port)) 1407 user (tramp-file-name-user (car args))
1423 tramp-postfix-host-format 1408 domain (tramp-file-name-domain (car args))
1424 (when localname localname))) 1409 host (tramp-file-name-host (car args))
1410 port (tramp-file-name-port (car args))
1411 localname (tramp-file-name-localname (car args))
1412 hop (tramp-file-name-hop (car args)))
1413 (when (cadr args)
1414 (setq localname (and (stringp (cadr args)) (cadr args))))
1415 (when (cl-caddr args)
1416 (setq hop (and (stringp (cl-caddr args)) (cl-caddr args)))))
1417
1418 (t (setq method (nth 0 args)
1419 user (nth 1 args)
1420 domain (nth 2 args)
1421 host (nth 3 args)
1422 port (nth 4 args)
1423 localname (nth 5 args)
1424 hop (nth 6 args))))
1425
1426 (concat tramp-prefix-format hop
1427 (unless (or (zerop (length method))
1428 (zerop (length tramp-postfix-method-format)))
1429 (concat method tramp-postfix-method-format))
1430 user
1431 (unless (zerop (length domain))
1432 (concat tramp-prefix-domain-format domain))
1433 (unless (zerop (length user))
1434 tramp-postfix-user-format)
1435 (when host
1436 (if (string-match tramp-ipv6-regexp host)
1437 (concat
1438 tramp-prefix-ipv6-format host tramp-postfix-ipv6-format)
1439 host))
1440 (unless (zerop (length port))
1441 (concat tramp-prefix-port-format port))
1442 tramp-postfix-host-format
1443 localname)))
1425 1444
1426(defun tramp-completion-make-tramp-file-name (method user host localname) 1445(defun tramp-completion-make-tramp-file-name (method user host localname)
1427 "Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME. 1446 "Construct a Tramp file name from METHOD, USER, HOST and LOCALNAME.
1428It must not be a complete Tramp file name, but as long as there are 1447It must not be a complete Tramp file name, but as long as there are
1429necessary only. This function will be used in file name completion." 1448necessary only. This function will be used in file name completion."
1430 (concat tramp-prefix-format 1449 (concat tramp-prefix-format
@@ -1451,15 +1470,8 @@ necessary only. This function will be used in file name completion."
1451 (tramp-set-connection-property 1470 (tramp-set-connection-property
1452 vec "process-buffer" 1471 vec "process-buffer"
1453 (tramp-get-connection-property vec "process-buffer" nil)) 1472 (tramp-get-connection-property vec "process-buffer" nil))
1454 (setq buffer-undo-list t) 1473 (setq buffer-undo-list t
1455 (setq default-directory 1474 default-directory (tramp-make-tramp-file-name vec "/" 'nohop))
1456 (tramp-make-tramp-file-name
1457 (tramp-file-name-method vec)
1458 (tramp-file-name-user vec)
1459 (tramp-file-name-domain vec)
1460 (tramp-file-name-host vec)
1461 (tramp-file-name-port vec)
1462 "/"))
1463 (current-buffer)))) 1475 (current-buffer))))
1464 1476
1465(defun tramp-get-connection-buffer (vec) 1477(defun tramp-get-connection-buffer (vec)
@@ -2352,7 +2364,9 @@ remote file names."
2352(defun tramp-register-file-name-handlers () 2364(defun tramp-register-file-name-handlers ()
2353 "Add Tramp file name handlers to `file-name-handler-alist'." 2365 "Add Tramp file name handlers to `file-name-handler-alist'."
2354 ;; Remove autoloaded handlers from file name handler alist. Useful, 2366 ;; Remove autoloaded handlers from file name handler alist. Useful,
2355 ;; if `tramp-syntax' has been changed. 2367 ;; if `tramp-syntax' has been changed. We cannot call
2368 ;; `tramp-unload-file-name-handlers', this would result in recursive
2369 ;; loading of Tramp.
2356 (dolist (fnh '(tramp-file-name-handler 2370 (dolist (fnh '(tramp-file-name-handler
2357 tramp-completion-file-name-handler 2371 tramp-completion-file-name-handler
2358 tramp-autoload-file-name-handler)) 2372 tramp-autoload-file-name-handler))
@@ -2488,7 +2502,6 @@ not in completion mode."
2488 (host (tramp-file-name-host elt)) 2502 (host (tramp-file-name-host elt))
2489 (localname (tramp-file-name-localname elt)) 2503 (localname (tramp-file-name-localname elt))
2490 (m (tramp-find-method method user host)) 2504 (m (tramp-find-method method user host))
2491 (tramp-current-user user) ; see `tramp-parse-passwd'
2492 all-user-hosts) 2505 all-user-hosts)
2493 2506
2494 (unless localname ;; Nothing to complete. 2507 (unless localname ;; Nothing to complete.
@@ -2978,6 +2991,12 @@ User is always nil."
2978 (and (file-directory-p filename) 2991 (and (file-directory-p filename)
2979 (file-readable-p filename))) 2992 (file-readable-p filename)))
2980 2993
2994(defun tramp-handle-file-directory-p (filename)
2995 "Like `file-directory-p' for Tramp files."
2996 (eq (tramp-compat-file-attribute-type
2997 (file-attributes (file-truename filename)))
2998 t))
2999
2981(defun tramp-handle-file-equal-p (filename1 filename2) 3000(defun tramp-handle-file-equal-p (filename1 filename2)
2982 "Like `file-equalp-p' for Tramp files." 3001 "Like `file-equalp-p' for Tramp files."
2983 ;; Native `file-equalp-p' calls `file-truename', which requires a 3002 ;; Native `file-equalp-p' calls `file-truename', which requires a
@@ -3018,17 +3037,11 @@ User is always nil."
3018 ;; Run the command on the localname portion only unless we are in 3037 ;; Run the command on the localname portion only unless we are in
3019 ;; completion mode. 3038 ;; completion mode.
3020 (tramp-make-tramp-file-name 3039 (tramp-make-tramp-file-name
3021 (tramp-file-name-method v) 3040 v (unless (and (zerop (length (tramp-file-name-localname v)))
3022 (tramp-file-name-user v) 3041 (not (tramp-connectable-p file)))
3023 (tramp-file-name-domain v) 3042 (tramp-run-real-handler
3024 (tramp-file-name-host v) 3043 'file-name-as-directory
3025 (tramp-file-name-port v) 3044 (list (or (tramp-file-name-localname v) "")))))))
3026 (if (and (zerop (length (tramp-file-name-localname v)))
3027 (not (tramp-connectable-p file)))
3028 ""
3029 (tramp-run-real-handler
3030 'file-name-as-directory (list (or (tramp-file-name-localname v) ""))))
3031 (tramp-file-name-hop v))))
3032 3045
3033(defun tramp-handle-file-name-case-insensitive-p (filename) 3046(defun tramp-handle-file-name-case-insensitive-p (filename)
3034 "Like `file-name-case-insensitive-p' for Tramp files." 3047 "Like `file-name-case-insensitive-p' for Tramp files."
@@ -3116,14 +3129,8 @@ User is always nil."
3116 (let ((v (tramp-dissect-file-name file t))) 3129 (let ((v (tramp-dissect-file-name file t)))
3117 ;; Run the command on the localname portion only. 3130 ;; Run the command on the localname portion only.
3118 (tramp-make-tramp-file-name 3131 (tramp-make-tramp-file-name
3119 (tramp-file-name-method v) 3132 v (tramp-run-real-handler
3120 (tramp-file-name-user v) 3133 'file-name-directory (list (or (tramp-file-name-localname v) ""))))))
3121 (tramp-file-name-domain v)
3122 (tramp-file-name-host v)
3123 (tramp-file-name-port v)
3124 (tramp-run-real-handler
3125 'file-name-directory (list (or (tramp-file-name-localname v) "")))
3126 (tramp-file-name-hop v))))
3127 3134
3128(defun tramp-handle-file-name-nondirectory (file) 3135(defun tramp-handle-file-name-nondirectory (file)
3129 "Like `file-name-nondirectory' but aware of Tramp files." 3136 "Like `file-name-nondirectory' but aware of Tramp files."
@@ -3162,7 +3169,8 @@ User is always nil."
3162 (and (or (not connected) c) 3169 (and (or (not connected) c)
3163 (cond 3170 (cond
3164 ((eq identification 'method) method) 3171 ((eq identification 'method) method)
3165 ;; Domain and port are appended. 3172 ;; Domain and port are appended to user and host,
3173 ;; respectively.
3166 ((eq identification 'user) (tramp-file-name-user-domain v)) 3174 ((eq identification 'user) (tramp-file-name-user-domain v))
3167 ((eq identification 'host) (tramp-file-name-host-port v)) 3175 ((eq identification 'host) (tramp-file-name-host-port v))
3168 ((eq identification 'localname) localname) 3176 ((eq identification 'localname) localname)
@@ -3574,29 +3582,28 @@ of."
3574 (eq (visited-file-modtime) 0) 3582 (eq (visited-file-modtime) 0)
3575 (not (file-remote-p f nil 'connected))) 3583 (not (file-remote-p f nil 'connected)))
3576 t 3584 t
3577 (with-parsed-tramp-file-name f nil 3585 (let* ((remote-file-name-inhibit-cache t)
3578 (let* ((remote-file-name-inhibit-cache t) 3586 (attr (file-attributes f))
3579 (attr (file-attributes f)) 3587 (modtime (tramp-compat-file-attribute-modification-time attr))
3580 (modtime (tramp-compat-file-attribute-modification-time attr)) 3588 (mt (visited-file-modtime)))
3581 (mt (visited-file-modtime))) 3589
3582 3590 (cond
3583 (cond 3591 ;; File exists, and has a known modtime.
3584 ;; File exists, and has a known modtime. 3592 ((and attr (not (equal modtime '(0 0))))
3585 ((and attr (not (equal modtime '(0 0)))) 3593 (< (abs (tramp-time-diff
3586 (< (abs (tramp-time-diff 3594 modtime
3587 modtime 3595 ;; For compatibility, deal with both the old
3588 ;; For compatibility, deal with both the old 3596 ;; (HIGH . LOW) and the new (HIGH LOW) return
3589 ;; (HIGH . LOW) and the new (HIGH LOW) return 3597 ;; values of `visited-file-modtime'.
3590 ;; values of `visited-file-modtime'. 3598 (if (atom (cdr mt))
3591 (if (atom (cdr mt)) 3599 (list (car mt) (cdr mt))
3592 (list (car mt) (cdr mt)) 3600 mt)))
3593 mt))) 3601 2))
3594 2)) 3602 ;; Modtime has the don't know value.
3595 ;; Modtime has the don't know value. 3603 (attr t)
3596 (attr t) 3604 ;; If file does not exist, say it is not modified if and
3597 ;; If file does not exist, say it is not modified if and 3605 ;; only if that agrees with the buffer's record.
3598 ;; only if that agrees with the buffer's record. 3606 (t (equal mt '(-1 65535)))))))))
3599 (t (equal mt '(-1 65535))))))))))
3600 3607
3601(defun tramp-handle-file-notify-add-watch (filename _flags _callback) 3608(defun tramp-handle-file-notify-add-watch (filename _flags _callback)
3602 "Like `file-notify-add-watch' for Tramp files." 3609 "Like `file-notify-add-watch' for Tramp files."
@@ -3633,17 +3640,16 @@ of."
3633 3640
3634(defun tramp-action-login (_proc vec) 3641(defun tramp-action-login (_proc vec)
3635 "Send the login name." 3642 "Send the login name."
3636 (when (not (stringp tramp-current-user)) 3643 (let ((user (or (tramp-file-name-user vec)
3637 (setq tramp-current-user 3644 (with-tramp-connection-property vec "login-as"
3638 (with-tramp-connection-property vec "login-as" 3645 (save-window-excursion
3639 (save-window-excursion 3646 (let ((enable-recursive-minibuffers t))
3640 (let ((enable-recursive-minibuffers t)) 3647 (pop-to-buffer (tramp-get-connection-buffer vec))
3641 (pop-to-buffer (tramp-get-connection-buffer vec)) 3648 (read-string (match-string 0))))))))
3642 (read-string (match-string 0))))))) 3649 (with-current-buffer (tramp-get-connection-buffer vec)
3643 (with-current-buffer (tramp-get-connection-buffer vec) 3650 (tramp-message vec 6 "\n%s" (buffer-string)))
3644 (tramp-message vec 6 "\n%s" (buffer-string))) 3651 (tramp-message vec 3 "Sending login name `%s'" user)
3645 (tramp-message vec 3 "Sending login name `%s'" tramp-current-user) 3652 (tramp-send-string vec (concat user tramp-local-end-of-line))))
3646 (tramp-send-string vec (concat tramp-current-user tramp-local-end-of-line)))
3647 3653
3648(defun tramp-action-password (proc vec) 3654(defun tramp-action-password (proc vec)
3649 "Query the user for a password." 3655 "Query the user for a password."
@@ -3767,12 +3773,11 @@ PROC and VEC indicate the remote connection to be used. POS, if
3767set, is the starting point of the region to be deleted in the 3773set, is the starting point of the region to be deleted in the
3768connection buffer." 3774connection buffer."
3769 ;; Enable `auth-source', unless "emacs -Q" has been called. We must 3775 ;; Enable `auth-source', unless "emacs -Q" has been called. We must
3770 ;; use `tramp-current-*' variables in case we have several hops. 3776 ;; use the "password-vector" property in case we have several hops.
3771 (tramp-set-connection-property 3777 (tramp-set-connection-property
3772 (make-tramp-file-name 3778 (tramp-get-connection-property
3773 :method tramp-current-method :user tramp-current-user 3779 proc "password-vector"
3774 :domain tramp-current-domain :host tramp-current-host 3780 (tramp-get-connection-property proc "vector" nil))
3775 :port tramp-current-port)
3776 "first-password-request" tramp-cache-read-persistent-data) 3781 "first-password-request" tramp-cache-read-persistent-data)
3777 (save-restriction 3782 (save-restriction
3778 (with-tramp-progress-reporter 3783 (with-tramp-progress-reporter
@@ -4140,15 +4145,7 @@ be granted."
4140 vec (tramp-file-name-localname vec) 4145 vec (tramp-file-name-localname vec)
4141 (concat "file-attributes-" suffix) nil) 4146 (concat "file-attributes-" suffix) nil)
4142 (file-attributes 4147 (file-attributes
4143 (tramp-make-tramp-file-name 4148 (tramp-make-tramp-file-name vec) (intern suffix))))
4144 (tramp-file-name-method vec)
4145 (tramp-file-name-user vec)
4146 (tramp-file-name-domain vec)
4147 (tramp-file-name-host vec)
4148 (tramp-file-name-port vec)
4149 (tramp-file-name-localname vec)
4150 (tramp-file-name-hop vec))
4151 (intern suffix))))
4152 (remote-uid 4149 (remote-uid
4153 (tramp-get-connection-property 4150 (tramp-get-connection-property
4154 vec (concat "uid-" suffix) nil)) 4151 vec (concat "uid-" suffix) nil))
@@ -4205,11 +4202,7 @@ be granted."
4205 ;; The local temp directory must be writable for the other user. 4202 ;; The local temp directory must be writable for the other user.
4206 (file-writable-p 4203 (file-writable-p
4207 (tramp-make-tramp-file-name 4204 (tramp-make-tramp-file-name
4208 (tramp-file-name-method vec) 4205 vec (tramp-compat-temporary-file-directory) 'nohop))
4209 (tramp-file-name-user vec)
4210 (tramp-file-name-domain vec)
4211 host port
4212 (tramp-compat-temporary-file-directory)))
4213 ;; On some systems, chown runs only for root. 4206 ;; On some systems, chown runs only for root.
4214 (or (zerop (user-uid)) 4207 (or (zerop (user-uid))
4215 ;; This is defined in tramp-sh.el. Let's assume this is 4208 ;; This is defined in tramp-sh.el. Let's assume this is
@@ -4219,14 +4212,9 @@ be granted."
4219(defun tramp-get-remote-tmpdir (vec) 4212(defun tramp-get-remote-tmpdir (vec)
4220 "Return directory for temporary files on the remote host identified by VEC." 4213 "Return directory for temporary files on the remote host identified by VEC."
4221 (with-tramp-connection-property vec "tmpdir" 4214 (with-tramp-connection-property vec "tmpdir"
4222 (let ((dir (tramp-make-tramp-file-name 4215 (let ((dir
4223 (tramp-file-name-method vec) 4216 (tramp-make-tramp-file-name
4224 (tramp-file-name-user vec) 4217 vec (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp"))))
4225 (tramp-file-name-domain vec)
4226 (tramp-file-name-host vec)
4227 (tramp-file-name-port vec)
4228 (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp")
4229 (tramp-file-name-hop vec))))
4230 (or (and (file-directory-p dir) (file-writable-p dir) 4218 (or (and (file-directory-p dir) (file-writable-p dir)
4231 (file-remote-p dir 'localname)) 4219 (file-remote-p dir 'localname))
4232 (tramp-error vec 'file-error "Directory %s not accessible" dir)) 4220 (tramp-error vec 'file-error "Directory %s not accessible" dir))
@@ -4339,15 +4327,10 @@ It always returns a return code. The Lisp error raised when
4339PROGRAM is nil is trapped also, returning 1. Furthermore, traces 4327PROGRAM is nil is trapped also, returning 1. Furthermore, traces
4340are written with verbosity of 6." 4328are written with verbosity of 6."
4341 (let ((default-directory (tramp-compat-temporary-file-directory)) 4329 (let ((default-directory (tramp-compat-temporary-file-directory))
4342 (v (or vec
4343 (make-tramp-file-name
4344 :method tramp-current-method :user tramp-current-user
4345 :domain tramp-current-domain :host tramp-current-host
4346 :port tramp-current-port)))
4347 (destination (if (eq destination t) (current-buffer) destination)) 4330 (destination (if (eq destination t) (current-buffer) destination))
4348 output error result) 4331 output error result)
4349 (tramp-message 4332 (tramp-message
4350 v 6 "`%s %s' %s %s" 4333 vec 6 "`%s %s' %s %s"
4351 program (mapconcat 'identity args " ") infile destination) 4334 program (mapconcat 'identity args " ") infile destination)
4352 (condition-case err 4335 (condition-case err
4353 (with-temp-buffer 4336 (with-temp-buffer
@@ -4365,8 +4348,8 @@ are written with verbosity of 6."
4365 (setq error (error-message-string err) 4348 (setq error (error-message-string err)
4366 result 1))) 4349 result 1)))
4367 (if (zerop (length error)) 4350 (if (zerop (length error))
4368 (tramp-message v 6 "%d\n%s" result output) 4351 (tramp-message vec 6 "%d\n%s" result output)
4369 (tramp-message v 6 "%d\n%s\n%s" result output error)) 4352 (tramp-message vec 6 "%d\n%s\n%s" result output error))
4370 result)) 4353 result))
4371 4354
4372(defun tramp-call-process-region 4355(defun tramp-call-process-region
@@ -4376,15 +4359,10 @@ It always returns a return code. The Lisp error raised when
4376PROGRAM is nil is trapped also, returning 1. Furthermore, traces 4359PROGRAM is nil is trapped also, returning 1. Furthermore, traces
4377are written with verbosity of 6." 4360are written with verbosity of 6."
4378 (let ((default-directory (tramp-compat-temporary-file-directory)) 4361 (let ((default-directory (tramp-compat-temporary-file-directory))
4379 (v (or vec
4380 (make-tramp-file-name
4381 :method tramp-current-method :user tramp-current-user
4382 :domain tramp-current-domain :host tramp-current-host
4383 :port tramp-current-port)))
4384 (buffer (if (eq buffer t) (current-buffer) buffer)) 4362 (buffer (if (eq buffer t) (current-buffer) buffer))
4385 result) 4363 result)
4386 (tramp-message 4364 (tramp-message
4387 v 6 "`%s %s' %s %s %s %s" 4365 vec 6 "`%s %s' %s %s %s %s"
4388 program (mapconcat 'identity args " ") start end delete buffer) 4366 program (mapconcat 'identity args " ") start end delete buffer)
4389 (condition-case err 4367 (condition-case err
4390 (progn 4368 (progn
@@ -4397,11 +4375,11 @@ are written with verbosity of 6."
4397 (signal 'file-error (list result))) 4375 (signal 'file-error (list result)))
4398 (with-current-buffer (if (bufferp buffer) buffer (current-buffer)) 4376 (with-current-buffer (if (bufferp buffer) buffer (current-buffer))
4399 (if (zerop result) 4377 (if (zerop result)
4400 (tramp-message v 6 "%d" result) 4378 (tramp-message vec 6 "%d" result)
4401 (tramp-message v 6 "%d\n%s" result (buffer-string))))) 4379 (tramp-message vec 6 "%d\n%s" result (buffer-string)))))
4402 (error 4380 (error
4403 (setq result 1) 4381 (setq result 1)
4404 (tramp-message v 6 "%d\n%s" result (error-message-string err)))) 4382 (tramp-message vec 6 "%d\n%s" result (error-message-string err))))
4405 result)) 4383 result))
4406 4384
4407;;;###tramp-autoload 4385;;;###tramp-autoload
@@ -4411,8 +4389,13 @@ Consults the auth-source package.
4411Invokes `password-read' if available, `read-passwd' else." 4389Invokes `password-read' if available, `read-passwd' else."
4412 (let* ((case-fold-search t) 4390 (let* ((case-fold-search t)
4413 (key (tramp-make-tramp-file-name 4391 (key (tramp-make-tramp-file-name
4414 tramp-current-method tramp-current-user tramp-current-domain 4392 ;; In tramp-sh.el, we must use "password-vector" due to
4415 tramp-current-host tramp-current-port "")) 4393 ;; multi-hop.
4394 (tramp-get-connection-property
4395 proc "password-vector"
4396 ;; All other backends simply use "vector".
4397 (tramp-get-connection-property proc "vector" nil))
4398 'noloc 'nohop))
4416 (pw-prompt 4399 (pw-prompt
4417 (or prompt 4400 (or prompt
4418 (with-current-buffer (process-buffer proc) 4401 (with-current-buffer (process-buffer proc)
@@ -4424,6 +4407,8 @@ Invokes `password-read' if available, `read-passwd' else."
4424 4407
4425 (unwind-protect 4408 (unwind-protect
4426 (with-parsed-tramp-file-name key nil 4409 (with-parsed-tramp-file-name key nil
4410 (setq user
4411 (or user (tramp-get-connection-property key "login-as" nil)))
4427 (prog1 4412 (prog1
4428 (or 4413 (or
4429 ;; See if auth-sources contains something useful. 4414 ;; See if auth-sources contains something useful.
@@ -4434,24 +4419,16 @@ Invokes `password-read' if available, `read-passwd' else."
4434 (setq auth-info 4419 (setq auth-info
4435 (auth-source-search 4420 (auth-source-search
4436 :max 1 4421 :max 1
4437 (and tramp-current-user :user) 4422 (and user :user)
4438 (if tramp-current-domain 4423 (if domain
4439 (format 4424 (concat user tramp-prefix-domain-format domain)
4440 "%s%s%s" 4425 user)
4441 tramp-current-user tramp-prefix-domain-format
4442 tramp-current-domain)
4443 tramp-current-user)
4444 :host 4426 :host
4445 (if tramp-current-port 4427 (if port
4446 (format 4428 (concat host tramp-prefix-port-format port)
4447 "%s%s%s" 4429 host)
4448 tramp-current-host tramp-prefix-port-format 4430 :port method
4449 tramp-current-port) 4431 :require (cons :secret (and user '(:user))))
4450 tramp-current-host)
4451 :port tramp-current-method
4452 :require
4453 (cons
4454 :secret (and tramp-current-user '(:user))))
4455 auth-passwd (plist-get 4432 auth-passwd (plist-get
4456 (nth 0 auth-info) :secret) 4433 (nth 0 auth-info) :secret)
4457 auth-passwd (if (functionp auth-passwd) 4434 auth-passwd (if (functionp auth-passwd)
@@ -4471,11 +4448,7 @@ Invokes `password-read' if available, `read-passwd' else."
4471(defun tramp-clear-passwd (vec) 4448(defun tramp-clear-passwd (vec)
4472 "Clear password cache for connection related to VEC." 4449 "Clear password cache for connection related to VEC."
4473 (let ((method (tramp-file-name-method vec)) 4450 (let ((method (tramp-file-name-method vec))
4474 (user (tramp-file-name-user vec))
4475 (domain (tramp-file-name-domain vec))
4476 (user-domain (tramp-file-name-user-domain vec)) 4451 (user-domain (tramp-file-name-user-domain vec))
4477 (host (tramp-file-name-host vec))
4478 (port (tramp-file-name-port vec))
4479 (host-port (tramp-file-name-host-port vec)) 4452 (host-port (tramp-file-name-host-port vec))
4480 (hop (tramp-file-name-hop vec))) 4453 (hop (tramp-file-name-hop vec)))
4481 (when hop 4454 (when hop
@@ -4490,8 +4463,7 @@ Invokes `password-read' if available, `read-passwd' else."
4490 (auth-source-forget 4463 (auth-source-forget
4491 `(:max 1 ,(and user-domain :user) ,user-domain 4464 `(:max 1 ,(and user-domain :user) ,user-domain
4492 :host ,host-port :port ,method)) 4465 :host ,host-port :port ,method))
4493 (password-cache-remove 4466 (password-cache-remove (tramp-make-tramp-file-name vec 'noloc 'nohop))))
4494 (tramp-make-tramp-file-name method user domain host port ""))))
4495 4467
4496;; Snarfed code from time-date.el. 4468;; Snarfed code from time-date.el.
4497 4469
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 51af455e635..4506698c368 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -7,7 +7,7 @@
7;; Maintainer: Michael Albinus <michael.albinus@gmx.de> 7;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
8;; Keywords: comm, processes 8;; Keywords: comm, processes
9;; Package: tramp 9;; Package: tramp
10;; Version: 2.3.3-pre 10;; Version: 2.4.0-pre
11 11
12;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
13 13
@@ -33,7 +33,7 @@
33;; should be changed only there. 33;; should be changed only there.
34 34
35;;;###tramp-autoload 35;;;###tramp-autoload
36(defconst tramp-version "2.3.3-pre" 36(defconst tramp-version "2.4.0-pre"
37 "This version of Tramp.") 37 "This version of Tramp.")
38 38
39;;;###tramp-autoload 39;;;###tramp-autoload
@@ -55,7 +55,7 @@
55;; Check for Emacs version. 55;; Check for Emacs version.
56(let ((x (if (>= emacs-major-version 24) 56(let ((x (if (>= emacs-major-version 24)
57 "ok" 57 "ok"
58 (format "Tramp 2.3.3-pre is not fit for %s" 58 (format "Tramp 2.4.0-pre is not fit for %s"
59 (when (string-match "^.*$" (emacs-version)) 59 (when (string-match "^.*$" (emacs-version))
60 (match-string 0 (emacs-version))))))) 60 (match-string 0 (emacs-version)))))))
61 (unless (string-match "\\`ok\\'" x) (error "%s" x))) 61 (unless (string-match "\\`ok\\'" x) (error "%s" x)))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index a9d6e74ce26..5fb3162769b 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2877,9 +2877,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2877 (tramp--test-ignore-make-symbolic-link-error 2877 (tramp--test-ignore-make-symbolic-link-error
2878 (make-symbolic-link tmp-name2 tmp-name1) 2878 (make-symbolic-link tmp-name2 tmp-name1)
2879 (should (file-symlink-p tmp-name1)) 2879 (should (file-symlink-p tmp-name1))
2880 (make-symbolic-link tmp-name1 tmp-name2) 2880 (if (tramp-smb-file-name-p tramp-test-temporary-file-directory)
2881 (should (file-symlink-p tmp-name2)) 2881 ;; The symlink command of `smbclient' detects the
2882 (should-error (file-truename tmp-name1) :type 'file-error)) 2882 ;; cycle already.
2883 (should-error
2884 (make-symbolic-link tmp-name1 tmp-name2)
2885 :type 'file-error)
2886 (make-symbolic-link tmp-name1 tmp-name2)
2887 (should (file-symlink-p tmp-name2))
2888 (should-error (file-truename tmp-name1) :type 'file-error)))
2883 2889
2884 ;; Cleanup. 2890 ;; Cleanup.
2885 (ignore-errors 2891 (ignore-errors