mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
FreeBSD: check first if kind of ACL can be set on a file
This commit is contained in:
parent
4ebb5cdf3c
commit
64b7b5fdd4
1 changed files with 12 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue