]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix file-readable-p and file-executable-p in some Tramp backends
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 8 Apr 2019 11:34:54 +0000 (13:34 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 8 Apr 2019 11:34:54 +0000 (13:34 +0200)
* lisp/net/tramp-archive.el (tramp-archive-handle-file-readable-p):
Use tramp-gvfs.

* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-executable-p):
Check that FILENAME exists.
(tramp-gvfs-handle-file-readable-p): Check that FILENAME exists.
Use heuristic in case it cannot be determined correctly.

lisp/net/tramp-archive.el
lisp/net/tramp-gvfs.el

index 9e131b1a47ddb089536e81d6be5868fabcbcbc3d..ba4c26cdf2fdf3a773390907364e91d901f8bdfb 100644 (file)
@@ -584,9 +584,7 @@ offered."
 
 (defun tramp-archive-handle-file-readable-p (filename)
   "Like `file-readable-p' for file archives."
-  (with-parsed-tramp-file-name
-      (tramp-archive-gvfs-file-name filename) nil
-    (tramp-check-cached-permissions v ?r)))
+  (file-readable-p (tramp-archive-gvfs-file-name filename)))
 
 (defun tramp-archive-handle-file-system-info (filename)
   "Like `file-system-info' for file archives."
index 2d8f42004a800bbcf48ede5682afa25c63e810ca..8fea82d97c4408da2fbda54d8d593588153897df 100644 (file)
@@ -1136,7 +1136,8 @@ If FILE-SYSTEM is non-nil, return file system attributes."
   "Like `file-executable-p' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (with-tramp-file-property v localname "file-executable-p"
-      (tramp-check-cached-permissions v ?x))))
+      (and (file-exists-p filename)
+          (tramp-check-cached-permissions v ?x)))))
 
 (defun tramp-gvfs-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
@@ -1258,7 +1259,20 @@ file-notify events."
   "Like `file-readable-p' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (with-tramp-file-property v localname "file-readable-p"
-      (tramp-check-cached-permissions v ?r))))
+      (and (file-exists-p filename)
+          (or (tramp-check-cached-permissions v ?r)
+              ;; If the user is different from what we guess to be
+              ;; the user, we don't know.  Let's check, whether
+              ;; access is restricted explicitly.
+              (and (/= (tramp-gvfs-get-remote-uid v 'integer)
+                       (tramp-compat-file-attribute-user-id
+                        (file-attributes filename 'integer)))
+                   (not
+                    (string-equal
+                     "FALSE"
+                     (cdr (assoc
+                           "access::can-read"
+                           (tramp-gvfs-get-file-attributes filename)))))))))))
 
 (defun tramp-gvfs-handle-file-system-info (filename)
   "Like `file-system-info' for Tramp files."