Fix some Tramp oddities

* lisp/net/tramp-container.el: Move connection-local settings
where they belong to.

* lisp/net/tramp-sshfs.el (tramp-connection-properties): Do not
set connection property "direct-async-process".
(tramp-direct-async-process): Set connection-local value.

* test/lisp/net/tramp-tests.el (comp-warn-primitives): Declare.
(tramp-test18-file-attributes): Use it.
This commit is contained in:
Michael Albinus 2024-05-21 18:13:40 +02:00
parent c8b34046d9
commit 9aeb4872d4
3 changed files with 45 additions and 38 deletions

View file

@ -554,7 +554,25 @@ see its function help for a description of the format."
(tramp-set-completion-function
tramp-kubernetes-method
`((tramp-kubernetes--completion-function ,tramp-kubernetes-method))))
`((tramp-kubernetes--completion-function ,tramp-kubernetes-method)))
(defconst tramp-kubernetes-connection-local-default-variables
'((tramp-config-check . tramp-kubernetes--current-context-data)
;; This variable will be eval'ed in `tramp-expand-args'.
(tramp-extra-expand-args
. (?a (tramp-kubernetes--container (car tramp-current-connection))
?h (tramp-kubernetes--pod (car tramp-current-connection))
?x (tramp-kubernetes--context-namespace
(car tramp-current-connection)))))
"Default connection-local variables for remote kubernetes connections.")
(connection-local-set-profile-variables
'tramp-kubernetes-connection-local-default-profile
tramp-kubernetes-connection-local-default-variables)
(connection-local-set-profiles
`(:application tramp :protocol ,tramp-kubernetes-method)
'tramp-kubernetes-connection-local-default-profile))
;;;###tramp-autoload
(defun tramp-enable-toolbox-method ()
@ -595,7 +613,19 @@ see its function help for a description of the format."
(tramp-set-completion-function
tramp-flatpak-method
`((tramp-flatpak--completion-function ,tramp-flatpak-method))))
`((tramp-flatpak--completion-function ,tramp-flatpak-method)))
(defconst tramp-flatpak-connection-local-default-variables
`((tramp-remote-path . ,(cons "/app/bin" tramp-remote-path)))
"Default connection-local variables for remote flatpak connections.")
(connection-local-set-profile-variables
'tramp-flatpak-connection-local-default-profile
tramp-flatpak-connection-local-default-variables)
(connection-local-set-profiles
`(:application tramp :protocol ,tramp-flatpak-method)
'tramp-flatpak-connection-local-default-profile))
;;;###tramp-autoload
(defun tramp-enable-apptainer-method ()
@ -638,38 +668,6 @@ see its function help for a description of the format."
tramp-nspawn-method
`((tramp-nspawn--completion-function ,tramp-nspawn-method))))
;; Default connection-local variables for Tramp.
(defconst tramp-kubernetes-connection-local-default-variables
'((tramp-config-check . tramp-kubernetes--current-context-data)
;; This variable will be eval'ed in `tramp-expand-args'.
(tramp-extra-expand-args
. (?a (tramp-kubernetes--container (car tramp-current-connection))
?h (tramp-kubernetes--pod (car tramp-current-connection))
?x (tramp-kubernetes--context-namespace
(car tramp-current-connection)))))
"Default connection-local variables for remote kubernetes connections.")
(connection-local-set-profile-variables
'tramp-kubernetes-connection-local-default-profile
tramp-kubernetes-connection-local-default-variables)
(connection-local-set-profiles
`(:application tramp :protocol ,tramp-kubernetes-method)
'tramp-kubernetes-connection-local-default-profile)
(defconst tramp-flatpak-connection-local-default-variables
`((tramp-remote-path . ,(cons "/app/bin" tramp-remote-path)))
"Default connection-local variables for remote flatpak connections.")
(connection-local-set-profile-variables
'tramp-flatpak-connection-local-default-profile
tramp-flatpak-connection-local-default-variables)
(connection-local-set-profiles
`(:application tramp :protocol ,tramp-flatpak-method)
'tramp-flatpak-connection-local-default-profile)
(add-hook 'tramp-unload-hook
(lambda ()
(unload-feature 'tramp-container 'force)))

View file

@ -67,9 +67,6 @@
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))))
(add-to-list 'tramp-connection-properties
`(,(format "/%s:" tramp-sshfs-method) "direct-async-process" t))
(tramp-set-completion-function
tramp-sshfs-method tramp-completion-function-alist-ssh))
@ -445,6 +442,16 @@ connection if a previous connection has died for some reason."
(with-tramp-connection-property
vec "gid-string" (tramp-get-local-gid 'string))))
;; Default connection-local variables for Tramp.
(connection-local-set-profile-variables
'tramp-sshfs-connection-local-default-profile
'((tramp-direct-async-process t)))
(connection-local-set-profiles
`(:application tramp :protocol ,tramp-sshfs-method)
'tramp-sshfs-connection-local-default-profile)
;; `shell-mode' tries to open remote files like "/sshfs:user@host:~/.history".
;; This fails, because the tilde cannot be expanded. Tell
;; `tramp-handle-expand-file-name' to tolerate this.

View file

@ -64,6 +64,7 @@
(declare-function tramp-method-out-of-band-p "tramp-sh")
(declare-function tramp-smb-get-localname "tramp-smb")
(defvar ange-ftp-make-backup-files)
(defvar comp-warn-primitives)
(defvar tramp-connection-properties)
(defvar tramp-copy-size-limit)
(defvar tramp-fuse-remove-hidden-files)
@ -3689,7 +3690,8 @@ This tests also `access-file', `file-readable-p',
;; `access-file' returns nil in case of success.
(should-not (access-file tmp-name1 "error"))
;; `access-file' could use a timeout.
(let ((remote-file-name-access-timeout 1))
(let ((remote-file-name-access-timeout 1)
comp-warn-primitives)
(cl-letf (((symbol-function #'file-exists-p)
(lambda (_filename) (sleep-for 5))))
(should-error