From 30f4518058a9a38e9ad051236dbaf27552e3306b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 2 Mar 2024 20:58:19 +0100 Subject: [PATCH] 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. --- src/borg/platform/freebsd.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/borg/platform/freebsd.pyx b/src/borg/platform/freebsd.pyx index 26dd2262..5f66c81c 100644 --- a/src/borg/platform/freebsd.pyx +++ b/src/borg/platform/freebsd.pyx @@ -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