diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2021-10-18 19:54:13 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2021-10-18 19:54:13 +0200 |
commit | f5b8f626e3d7233a935e67ffc5ffee0de9069ae5 (patch) | |
tree | fc25835e800c0e26b4663983f4780a3c53a2f780 /lisp/net/tramp.el | |
parent | fc988a71136b6f875823e0dc03a7c1cba102dc59 (diff) | |
download | emacs-f5b8f626e3d7233a935e67ffc5ffee0de9069ae5.tar.gz emacs-f5b8f626e3d7233a935e67ffc5ffee0de9069ae5.tar.bz2 emacs-f5b8f626e3d7233a935e67ffc5ffee0de9069ae5.zip |
Fix some Tramp problems
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Use `tramp-adb-handle-file-executable-p' and
`tramp-adb-handle-file-readable-p'.
(tramp-adb-handle-file-executable-p)
(tramp-adb-handle-file-readable-p): New defuns.
(tramp-adb-handle-file-writable-p): Simplify.
(tramp-adb-handle-make-process): Handle :filter being t.
(tramp-adb-find-test-command): Remove.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-readable-p):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-file-readable-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
(tramp-gvfs-handle-file-executable-p): Do not check whether file
exists, this is done in `tramp-check-cached-permissions'.
(tramp-gvfs-handle-file-readable-p): Remove.
* lisp/net/tramp.el (tramp-error): Move binding of `inhibit-message' ...
(tramp-signal-hook-function): ... here.
(tramp-handle-access-file): Rewrite.
(tramp-handle-file-readable-p): New defun.
(tramp-handle-make-process): Setting :filter to t works since
Emacs 29.1 only.
* test/lisp/net/tramp-tests.el (tramp-test17-insert-directory)
(tramp-test18-file-attributes): Extend tests.
Diffstat (limited to 'lisp/net/tramp.el')
-rw-r--r-- | lisp/net/tramp.el | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 318b4e454da..372e0a2cb73 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2087,8 +2087,7 @@ VEC-OR-PROC identifies the connection to use, SIGNAL is the signal identifier to be raised, remaining arguments passed to `tramp-message'. Finally, signal SIGNAL is raised with FMT-STRING and ARGUMENTS." - (let ((inhibit-message t) - signal-hook-function) + (let (signal-hook-function) (tramp-backtrace vec-or-proc) (unless arguments ;; FMT-STRING could be just a file name, as in @@ -2198,9 +2197,10 @@ the resulting error message." ;; `custom-initialize-*' functions provoke `void-variable' errors. ;; We don't want to see them in the backtrace. (unless (eq error-symbol 'void-variable) - (tramp-error - (car tramp-current-connection) error-symbol - (mapconcat (lambda (x) (format "%s" x)) data " ")))) + (let ((inhibit-message t)) + (tramp-error + (car tramp-current-connection) error-symbol + (mapconcat (lambda (x) (format "%s" x)) data " "))))) (put #'tramp-signal-hook-function 'tramp-suppress-trace t) @@ -3275,10 +3275,18 @@ User is always nil." (defun tramp-handle-access-file (filename string) "Like `access-file' for Tramp files." - (unless (file-readable-p (file-truename filename)) - (tramp-compat-file-missing - (tramp-dissect-file-name filename) - (format "%s: %s" string filename)))) + (setq filename (file-truename filename)) + (with-parsed-tramp-file-name filename v + (if (file-exists-p filename) + (unless + (funcall + (if (file-directory-p filename) + #'file-accessible-directory-p #'file-readable-p) + filename) + (tramp-error + v 'file-error (format "%s: Permission denied, %s" string filename))) + (tramp-compat-file-missing + v (format "%s: No such file or directory, %s" string filename))))) (defun tramp-handle-add-name-to-file (filename newname &optional ok-if-already-exists) @@ -3568,6 +3576,17 @@ User is always nil." (tramp-compat-file-attribute-modification-time (file-attributes file1)))))) +(defun tramp-handle-file-readable-p (filename) + "Like `file-readable-p' for Tramp files." + (with-parsed-tramp-file-name filename nil + (with-tramp-file-property v localname "file-readable-p" + (or (tramp-check-cached-permissions v ?r) + ;; `tramp-check-cached-permissions' doesn't handle symbolic + ;; links. + (when-let ((symlink (file-symlink-p filename))) + (and (stringp symlink) + (file-readable-p (concat (file-remote-p filename) symlink)))))))) + (defun tramp-handle-file-regular-p (filename) "Like `file-regular-p' for Tramp files." (and (file-exists-p filename) @@ -4220,7 +4239,12 @@ substitution. SPEC-LIST is a list of char/value pairs used for :name name :buffer buffer :command (append `(,login-program) login-args command) :coding coding :noquery noquery :connection-type connection-type - :filter filter :sentinel sentinel :stderr stderr)) + :sentinel sentinel :stderr stderr)) + ;; Set filter. Prior Emacs 29.1, it doesn't work reliable + ;; to provide it as `make-process' argument when filter is + ;; t. See Bug#51177. + (when filter + (set-process-filter p filter)) (tramp-message v 6 "%s" (string-join (process-command p) " ")) p)))))) |