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 &optional FORCE)
Documentation
Check file-attributes caches for VEC.
Return t if according to the cache access type ACCESS is known to be
granted, if tramp-use-file-attributes(var)/tramp-use-file-attributes(fun) mandates this. If FORCE is
non-nil, use connection property "file-attributes" mandatory.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-check-cached-permissions (vec access &optional force)
"Check `file-attributes' caches for VEC.
Return t if according to the cache access type ACCESS is known to be
granted, if `tramp-use-file-attributes' mandates this. If FORCE is
non-nil, use connection property \"file-attributes\" mandatory."
(when-let* ((offset (cond
((eq ?r access) 1)
((eq ?w access) 2)
((eq ?x access) 3)
((eq ?s access) 3)
((eq ?t access) 3)))
((or force (tramp-use-file-attributes vec)))
(file-attr (file-attributes (tramp-make-tramp-file-name vec)))
;; Not a symlink.
((not (stringp (file-attribute-type file-attr))))
(remote-uid (tramp-get-remote-uid vec 'integer))
(remote-gid (tramp-get-remote-gid vec 'integer)))
(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))))))