summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2024-03-10 13:20:37 +0100
committerThomas Waldmann <tw@waldmann-edv.de>2024-04-02 01:38:30 +0200
commit64b7b5fdd4b9cf690d6c420e17fd8c65897a9219 (patch)
treef25c8a6ad3328ba643ec75f1b6a129aa0666d0ea
parent4ebb5cdf3caf6c443910cc2349ce359154006b1d (diff)
FreeBSD: check first if kind of ACL can be set on a file
-rw-r--r--src/borg/platform/freebsd.pyx15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/borg/platform/freebsd.pyx b/src/borg/platform/freebsd.pyx
index ac522dfbe..c38f03588 100644
--- a/src/borg/platform/freebsd.pyx
+++ b/src/borg/platform/freebsd.pyx
@@ -48,6 +48,7 @@ cdef extern from "sys/acl.h":
cdef extern from "unistd.h":
long lpathconf(const char *path, int name)
int _PC_ACL_NFS4
+ int _PC_ACL_EXTENDED
# On FreeBSD, borg currently only deals with the USER namespace as it is unclear
@@ -213,6 +214,14 @@ def acl_set(path, item, numeric_ids=False, fd=None):
"""
if isinstance(path, str):
path = os.fsencode(path)
- _set_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', numeric_ids, fd=fd)
- _set_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', numeric_ids, fd=fd)
- _set_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', numeric_ids, fd=fd)
+ ret = lpathconf(path, _PC_ACL_NFS4)
+ if ret < 0:
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
+ if ret == 1:
+ _set_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', numeric_ids, fd=fd)
+ ret = lpathconf(path, _PC_ACL_EXTENDED)
+ if ret < 0:
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
+ if ret == 1:
+ _set_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', numeric_ids, fd=fd)
+ _set_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', numeric_ids, fd=fd)