Function: tramp-check-cached-permissions
tramp-check-cached-permissions is a byte-compiled function defined in
tramp.el.gz.
Signature
(tramp-check-cached-permissions VEC ACCESS)
Documentation
Check file-attributes caches for VEC.
Return t if according to the cache access type ACCESS is known to be granted.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-check-cached-permissions (vec access)
"Check `file-attributes' caches for VEC.
Return t if according to the cache access type ACCESS is known to
be granted."
(when-let ((offset (cond
((eq ?r access) 1)
((eq ?w access) 2)
((eq ?x access) 3)
((eq ?s access) 3)))
(file-attr (file-attributes (tramp-make-tramp-file-name vec)))
(remote-uid (tramp-get-remote-uid vec 'integer))
(remote-gid (tramp-get-remote-gid vec 'integer)))
(or
;; Not a symlink.
(eq t (file-attribute-type file-attr))
(null (file-attribute-type file-attr)))
(or
;; World accessible.
(eq access (aref (file-attribute-modes file-attr) (+ offset 6)))
;; User accessible and owned by user.
(and
(eq access (aref (file-attribute-modes file-attr) offset))
(or (equal remote-uid tramp-root-id-integer)
(equal remote-uid tramp-unknown-id-integer)
(equal remote-uid (file-attribute-user-id file-attr))
(equal tramp-unknown-id-integer (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 tramp-root-id-integer)
(equal remote-gid tramp-unknown-id-integer)
(equal remote-gid (file-attribute-group-id file-attr))
(equal tramp-unknown-id-integer
(file-attribute-group-id file-attr))))
;; Group accessible and owned by user's secondary group.
(and
(eq access
(aref (file-attribute-modes file-attr) (+ offset 3)))
(member (file-attribute-group-id file-attr)
(tramp-get-remote-groups vec 'integer))))))