(defun tramp-get-file-property (key file property default)
"Get the PROPERTY of FILE from the cache context of KEY.
Returns DEFAULT if not set."
- ;; Unify localname.
+ ;; Unify localname. Remove hop from vector.
(setq key (copy-sequence key))
(aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
+ (aset key 4 nil)
(let* ((hash (tramp-get-hash-table key))
(value (when (hash-table-p hash) (gethash property hash))))
(if
(defun tramp-set-file-property (key file property value)
"Set the PROPERTY of FILE to VALUE, in the cache context of KEY.
Returns VALUE."
- ;; Unify localname.
+ ;; Unify localname. Remove hop from vector.
(setq key (copy-sequence key))
(aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
+p (aset key 4 nil)
(let ((hash (tramp-get-hash-table key)))
;; We put the timestamp there.
(puthash property (cons (current-time) value) hash)
(when (and (stringp truename)
(not (string-equal file (directory-file-name truename))))
(tramp-flush-file-property key truename))
- ;; Unify localname.
+ ;; Unify localname. Remove hop from vector.
(setq key (copy-sequence key))
(aset key 3 file)
+ (aset key 4 nil)
(tramp-message key 8 "%s" file)
(remhash key tramp-cache-data)))
"Get the named PROPERTY for the connection.
KEY identifies the connection, it is either a process or a vector.
If the value is not set for the connection, returns DEFAULT."
- ;; Unify key by removing localname from vector. Work with a copy in
- ;; order to avoid side effects.
+ ;; Unify key by removing localname and hop from vector. Work with a
+ ;; copy in order to avoid side effects.
(when (vectorp key)
(setq key (copy-sequence key))
- (aset key 3 nil))
+ (aset key 3 nil)
+ (aset key 4 nil))
(let* ((hash (tramp-get-hash-table key))
(value (if (hash-table-p hash)
(gethash property hash default)
"Set the named PROPERTY of a connection to VALUE.
KEY identifies the connection, it is either a process or a vector.
PROPERTY is set persistent when KEY is a vector."
- ;; Unify key by removing localname from vector. Work with a copy in
- ;; order to avoid side effects.
+ ;; Unify key by removing localname and hop from vector. Work with a
+ ;; copy in order to avoid side effects.
(when (vectorp key)
(setq key (copy-sequence key))
- (aset key 3 nil))
+ (aset key 3 nil)
+ (aset key 4 nil))
(let ((hash (tramp-get-hash-table key)))
(puthash property value hash)
(setq tramp-cache-data-changed t)
(defun tramp-flush-connection-property (key)
"Remove all properties identified by KEY.
KEY identifies the connection, it is either a process or a vector."
- ;; Unify key by removing localname from vector. Work with a copy in
- ;; order to avoid side effects.
+ ;; Unify key by removing localname and hop from vector. Work with a
+ ;; copy in order to avoid side effects.
(when (vectorp key)
(setq key (copy-sequence key))
- (aset key 3 nil))
+ (aset key 3 nil)
+ (aset key 4 nil))
(tramp-message
key 7 "%s %s" key
(let ((hash (gethash key tramp-cache-data))
;; We use "-p" as required for newer busyboxes. For older
;; busybox/nc versions, the value must be (("-l") ("%r")). This
;; can be achieved by tweaking `tramp-connection-properties'.
- (tramp-remote-copy-args (("-l") ("-p" "%r")))
+ (tramp-remote-copy-args (("-l") ("-p" "%r") ("2>/dev/null")))
(tramp-default-port 23)))
;;;###tramp-autoload
(add-to-list 'tramp-methods
" "))
(tramp-send-command v remote-copy-program)
(with-timeout
- (1 (tramp-error
- v 'file-error
- "Listener process not running on remote host: `%s'"
- remote-copy-program))
+ (60 (tramp-error
+ v 'file-error
+ "Listener process not running on remote host: `%s'"
+ remote-copy-program))
(tramp-send-command v (format "netstat -l | grep -q :%s" listener))
(while (not (tramp-send-command-and-check v nil))
(tramp-send-command
(setq i (+ i 250))))
(cdr args)))
;; Use a human-friendly prompt, for example for `shell'.
- (prompt (format "PS1=%s"
- (format "%s %s"
- (file-remote-p default-directory)
- tramp-initial-end-of-output)))
+ ;; We discard hops, if existing, that's why we cannot use
+ ;; `file-remote-p'.
+ (prompt (format "PS1=%s %s"
+ (tramp-make-tramp-file-name
+ (tramp-file-name-method v)
+ (tramp-file-name-user v)
+ (tramp-file-name-host v)
+ (tramp-file-name-localname v))
+ tramp-initial-end-of-output))
;; We use as environment the difference to toplevel
;; `process-environment'.
env
(should (string-equal (file-remote-p "/method::" 'user) "default-user"))
(should (string-equal (file-remote-p "/method::" 'host) "default-host"))
(should (string-equal (file-remote-p "/method::" 'localname) ""))
+ (should (string-equal (file-remote-p "/method::" 'hop) nil))
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(should (string-equal (file-remote-p "/host:" 'user) "default-user"))
(should (string-equal (file-remote-p "/host:" 'host) "host"))
(should (string-equal (file-remote-p "/host:" 'localname) ""))
+ (should (string-equal (file-remote-p "/host:" 'hop) nil))
;; Expand `tramp-default-method' and `tramp-default-host'.
(should (string-equal
(should (string-equal (file-remote-p "/user@:" 'user) "user"))
(should (string-equal (file-remote-p "/user@:" 'host) "default-host"))
(should (string-equal (file-remote-p "/user@:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@:" 'hop) nil))
;; Expand `tramp-default-method'.
(should (string-equal
(should (string-equal (file-remote-p "/user@host:" 'user) "user"))
(should (string-equal (file-remote-p "/user@host:" 'host) "host"))
(should (string-equal (file-remote-p "/user@host:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@host:" 'hop) nil))
;; Expand `tramp-default-user'.
(should (string-equal
(should (string-equal (file-remote-p "/method:host:" 'user) "default-user"))
(should (string-equal (file-remote-p "/method:host:" 'host) "host"))
(should (string-equal (file-remote-p "/method:host:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:host:" 'hop) nil))
;; Expand `tramp-default-host'.
(should (string-equal
(should (string-equal (file-remote-p "/method:user@:" 'host)
"default-host"))
(should (string-equal (file-remote-p "/method:user@:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:user@:" 'hop) nil))
;; No expansion.
(should (string-equal
(should (string-equal (file-remote-p "/method:user@host:" 'user) "user"))
(should (string-equal (file-remote-p "/method:user@host:" 'host) "host"))
(should (string-equal (file-remote-p "/method:user@host:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:user@host:" 'hop) nil))
;; No expansion.
(should (string-equal
(file-remote-p "/method:user@email@host:" 'host) "host"))
(should (string-equal
(file-remote-p "/method:user@email@host:" 'localname) ""))
+ (should (string-equal
+ (file-remote-p "/method:user@email@host:" 'hop) nil))
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(should (string-equal (file-remote-p "/host#1234:" 'user) "default-user"))
(should (string-equal (file-remote-p "/host#1234:" 'host) "host#1234"))
(should (string-equal (file-remote-p "/host#1234:" 'localname) ""))
+ (should (string-equal (file-remote-p "/host#1234:" 'hop) nil))
;; Expand `tramp-default-method'.
(should (string-equal
(should (string-equal (file-remote-p "/user@host#1234:" 'user) "user"))
(should (string-equal (file-remote-p "/user@host#1234:" 'host) "host#1234"))
(should (string-equal (file-remote-p "/user@host#1234:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil))
;; Expand `tramp-default-user'.
(should (string-equal
(should (string-equal
(file-remote-p "/method:host#1234:" 'host) "host#1234"))
(should (string-equal (file-remote-p "/method:host#1234:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:host#1234:" 'hop) nil))
;; No expansion.
(should (string-equal
(file-remote-p "/method:user@host#1234:" 'host) "host#1234"))
(should (string-equal
(file-remote-p "/method:user@host#1234:" 'localname) ""))
+ (should (string-equal
+ (file-remote-p "/method:user@host#1234:" 'hop) nil))
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(should (string-equal (file-remote-p "/1.2.3.4:" 'user) "default-user"))
(should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4"))
(should (string-equal (file-remote-p "/1.2.3.4:" 'localname) ""))
+ (should (string-equal (file-remote-p "/1.2.3.4:" 'hop) nil))
;; Expand `tramp-default-method'.
(should (string-equal
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user"))
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4"))
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@1.2.3.4:" 'hop) nil))
;; Expand `tramp-default-user'.
(should (string-equal
(file-remote-p "/method:1.2.3.4:" 'user) "default-user"))
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4"))
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:1.2.3.4:" 'hop) nil))
;; No expansion.
(should (string-equal
(file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4"))
(should (string-equal
(file-remote-p "/method:user@1.2.3.4:" 'localname) ""))
+ (should (string-equal
+ (file-remote-p "/method:user@1.2.3.4:" 'hop) nil))
;; Expand `tramp-default-method', `tramp-default-user' and
;; `tramp-default-host'.
(should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
(should (string-equal (file-remote-p "/[]:" 'host) "default-host"))
(should (string-equal (file-remote-p "/[]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/[]:" 'hop) nil))
;; Expand `tramp-default-method' and `tramp-default-user'.
(let ((tramp-default-host "::1"))
(should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
(should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
(should (string-equal (file-remote-p "/[]:" 'host) "::1"))
- (should (string-equal (file-remote-p "/[]:" 'localname) "")))
+ (should (string-equal (file-remote-p "/[]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/[]:" 'hop) nil)))
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(should (string-equal (file-remote-p "/[::1]:" 'user) "default-user"))
(should (string-equal (file-remote-p "/[::1]:" 'host) "::1"))
(should (string-equal (file-remote-p "/[::1]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/[::1]:" 'hop) nil))
;; Expand `tramp-default-method'.
(should (string-equal
(should (string-equal (file-remote-p "/user@[::1]:" 'user) "user"))
(should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1"))
(should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
;; Expand `tramp-default-user'.
(should (string-equal
(file-remote-p "/method:[::1]:" 'user) "default-user"))
(should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1"))
(should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
;; No expansion.
(should (string-equal
(should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
(should (string-equal
(file-remote-p "/method:user@[::1]:" 'localname) ""))
+ (should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil))
;; Local file name part.
(should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
(should
(string-equal
(file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file")
- (format "/%s:%s@%s:" "method2" "user2" "host2")))
+ (format "/%s:%s@%s|%s:%s@%s:"
+ "method1" "user1" "host1" "method2" "user2" "host2")))
(should
(string-equal
(file-remote-p
(file-remote-p
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname)
"/path/to/file"))
+ (should
+ (string-equal
+ (file-remote-p
+ "/method1:user1@host1|method2:user2@host2:/path/to/file" 'hop)
+ (format "%s:%s@%s|"
+ "method1" "user1" "host1")))
(should
(string-equal
(file-remote-p
"/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file")
- (format "/%s:%s@%s:" "method3" "user3" "host3")))
+ (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
+ "method1" "user1" "host1"
+ "method2" "user2" "host2"
+ "method3" "user3" "host3")))
(should
(string-equal
(file-remote-p
(file-remote-p
"/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
'localname)
- "/path/to/file"))))
+ "/path/to/file"))
+ (should
+ (string-equal
+ (file-remote-p
+ "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
+ 'hop)
+ (format "%s:%s@%s|%s:%s@%s|"
+ "method1" "user1" "host1" "method2" "user2" "host2")))))
(ert-deftest tramp-test03-file-name-defaults ()
"Check default values for some methods."
;; * Work on skipped tests. Make a comment, when it is impossible.
;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe
;; doesn't work well when an interactive password must be provided.
-;; * Fix `tramp-test27-start-file-process' for `nc' and on MS
-;; Windows (`process-send-eof'?).
-;; * Fix `tramp-test31-special-characters' for `nc'.
-;; * Fix `tramp-test32-utf8' for `nc'/`telnet' (when target is a dumb
-;; busybox). Seems to be in `directory-files'.
+;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?).
;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'.
;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set
;; expected error.