]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve handling of file modes in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 10 Feb 2022 13:14:06 +0000 (14:14 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 10 Feb 2022 13:14:06 +0000 (14:14 +0100)
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-get-remote-uid)
(tramp-gvfs-handle-get-remote-gid): Do not assume that the default
location is owned be the remote uid/gid.
(tramp-gvfs-handle-file-executable-p):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-executable-p):
Check also for setuid/setgid bit.

* lisp/net/tramp.el (tramp-check-cached-permissions): Check also
for ?s access type.  Check whether remote uid/gid are unknown.

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

index d3af9f4769ad8fd2a55a87db2c30839089ed316a..d3634b0cc254e5b6df80394fb43f0cbfb4213bd5 100644 (file)
@@ -1385,7 +1385,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))))
+      (or (tramp-check-cached-permissions v ?x)
+         (tramp-check-cached-permissions v ?s)))))
 
 (defun tramp-gvfs-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
@@ -1603,8 +1604,7 @@ ID-FORMAT valid values are `string' and `integer'."
       (tramp-file-name-user vec)
     (when-let ((localname
                (tramp-get-connection-property
-                (tramp-get-process vec) "share"
-                (tramp-get-connection-property vec "default-location" nil))))
+                (tramp-get-process vec) "share" nil)))
       (file-attribute-user-id
        (file-attributes (tramp-make-tramp-file-name vec localname) id-format)))))
 
@@ -1613,8 +1613,7 @@ ID-FORMAT valid values are `string' and `integer'."
 ID-FORMAT valid values are `string' and `integer'."
   (when-let ((localname
              (tramp-get-connection-property
-              (tramp-get-process vec) "share"
-              (tramp-get-connection-property vec "default-location" nil))))
+              (tramp-get-process vec) "share" nil)))
     (file-attribute-group-id
      (file-attributes (tramp-make-tramp-file-name vec localname) id-format))))
 
index 98192bd96d590636781e5241d8fd7a0f43b8d131..ea089224aefe965c1632b490ee56bf5215c95a0e 100644 (file)
@@ -1585,6 +1585,7 @@ ID-FORMAT valid values are `string' and `integer'."
       ;; Examine `file-attributes' cache to see if request can be
       ;; satisfied without remote operation.
       (or (tramp-check-cached-permissions v ?x)
+         (tramp-check-cached-permissions v ?s)
          (tramp-run-test "-x" filename)))))
 
 (defun tramp-sh-handle-file-readable-p (filename)
index 1b5de46016028c0dad8732a23e8dd5b9e6dfcca6..f93ca7601aa10aed83d6ab244eeb528ccb882c28 100644 (file)
@@ -5402,7 +5402,8 @@ be granted."
         (offset (cond
                  ((eq ?r access) 1)
                  ((eq ?w access) 2)
-                 ((eq ?x access) 3))))
+                 ((eq ?x access) 3)
+                 ((eq ?s access) 3))))
     (dolist (suffix '("string" "integer") result)
       (setq
        result
@@ -5432,13 +5433,15 @@ be granted."
             ;; User accessible and owned by user.
             (and
              (eq access (aref (file-attribute-modes file-attr) offset))
-            (or (equal remote-uid (file-attribute-user-id file-attr))
+            (or (equal remote-uid unknown-id)
+                (equal remote-uid (file-attribute-user-id file-attr))
                 (equal unknown-id (file-attribute-user-id file-attr))))
             ;; Group accessible and owned by user's principal group.
             (and
              (eq access
                 (aref (file-attribute-modes file-attr) (+ offset 3)))
-             (or (equal remote-gid (file-attribute-group-id file-attr))
+             (or (equal remote-gid unknown-id)
+                (equal remote-gid (file-attribute-group-id file-attr))
                 (equal unknown-id (file-attribute-group-id file-attr))))))))))))
 
 (defun tramp-get-remote-uid (vec id-format)