FreeBSD: acl_get: add an acl_extended_* call

... to implement same semantics as on linux (only store ACL
if it defines permissions other than those defined by the
traditional file permissions).

Looks like there is no call working with an fd on FreeBSD.
This commit is contained in:
Thomas Waldmann 2024-03-02 20:58:19 +01:00
parent 4cc4516c59
commit 30f4518058
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
1 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,7 @@ cdef extern from "sys/acl.h":
char *acl_to_text_np(acl_t acl, ssize_t *len, int flags)
int ACL_TEXT_NUMERIC_IDS
int ACL_TEXT_APPEND_ID
int acl_extended_link_np(const char * path) # check also: acl_is_trivial_np
cdef extern from "unistd.h":
long lpathconf(const char *path, int name)
@ -146,6 +147,12 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
cdef int flags = ACL_TEXT_APPEND_ID
if isinstance(path, str):
path = os.fsencode(path)
ret = acl_extended_link_np(path)
if ret < 0:
raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
if ret == 0:
# there is no ACL defining permissions other than those defined by the traditional file permission bits.
return
ret = lpathconf(path, _PC_ACL_NFS4)
if ret < 0 and errno.errno == errno.EINVAL:
return