]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix symlinks in tramp-sshfs.el (Bug#54130)
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 24 Feb 2022 15:11:01 +0000 (16:11 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 24 Feb 2022 15:11:01 +0000 (16:11 +0100)
* lisp/net/tramp-sshfs.el (tramp-methods) <sshfs>:
Add "-o transform_symlinks" to `tramp-mount-args'.
(tramp-sshfs-file-name-handler-alist):
Use `tramp-sshfs-handle-file-writable-p'.
(tramp-sshfs-handle-file-writable-p): New defun.  (Bug#54130)

* test/lisp/net/tramp-tests.el (tramp-test18-file-attributes)
(tramp-test20-file-modes): Adapt tests.

lisp/net/tramp-sshfs.el
test/lisp/net/tramp-tests.el

index d30c19436d586540112724700f8864b3550ccd36..90b3c2ba2c203abed00118e9a5917ebe82aba0d1 100644 (file)
  (add-to-list 'tramp-methods
              `(,tramp-sshfs-method
                (tramp-mount-args            (("-C") ("-p" "%p")
+                                             ("-o" "transform_symlinks")
                                              ("-o" "idmap=user,reconnect")))
                ;; These are for remote processes.
                 (tramp-login-program        "ssh")
-                (tramp-login-args           (("-q")("-l" "%u") ("-p" "%p")
+                (tramp-login-args           (("-q") ("-l" "%u") ("-p" "%p")
                                             ("-e" "none") ("-t" "-t")
                                             ("%h") ("%l")))
                 (tramp-direct-async         t)
     (file-symlink-p . tramp-handle-file-symlink-p)
     (file-system-info . tramp-sshfs-handle-file-system-info)
     (file-truename . tramp-handle-file-truename)
-    (file-writable-p . tramp-handle-file-writable-p)
+    (file-writable-p . tramp-sshfs-handle-file-writable-p)
     (find-backup-file-name . tramp-handle-find-backup-file-name)
     ;; `get-file-buffer' performed by default handler.
     (insert-directory . tramp-handle-insert-directory)
@@ -220,6 +221,10 @@ arguments to pass to the OPERATION."
   ;;`file-system-info' exists since Emacs 27.1.
   (tramp-compat-funcall 'file-system-info (tramp-fuse-local-file-name filename)))
 
+(defun tramp-sshfs-handle-file-writable-p (filename)
+  "Like `file-writable-p' for Tramp files."
+  (file-writable-p (tramp-fuse-local-file-name filename)))
+
 (defun tramp-sshfs-handle-insert-file-contents
   (filename &optional visit beg end replace)
   "Like `insert-file-contents' for Tramp files."
index 4e74f2aa73f2062bfc3942c6dd5636349e4f7800..c468c3501bf7639e0194dbd0cf8d2ac583e07311 100644 (file)
@@ -3437,8 +3437,10 @@ This tests also `access-file', `file-readable-p',
              (should
               (string-equal
                (file-attribute-type attr)
-               (tramp-file-name-localname
-                (tramp-dissect-file-name tmp-name3))))
+               (funcall
+                (if (tramp--test-sshfs-p) #'file-name-nondirectory #'identity)
+                (tramp-file-name-localname
+                 (tramp-dissect-file-name tmp-name3)))))
              (delete-file tmp-name2))
 
            (when test-file-ownership-preserved-p
@@ -3598,7 +3600,9 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
            (should (= (file-modes tmp-name1) #o444))
            (should-not (file-executable-p tmp-name1))
            ;; A file is always writable for user "root".
-           (unless (zerop (file-attribute-user-id (file-attributes tmp-name1)))
+           (unless
+               (or (zerop (file-attribute-user-id (file-attributes tmp-name1)))
+                   (tramp--test-sshfs-p))
              (should-not (file-writable-p tmp-name1)))
            ;; Check the NOFOLLOW arg.  It exists since Emacs 28.  For
            ;; regular files, there shouldn't be a difference.