mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
FreeBSD: added tests, only get default ACL from dirs
This commit is contained in:
parent
d3694271eb
commit
7df170c946
3 changed files with 19 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import stat
|
||||
|
||||
from libc cimport errno
|
||||
|
||||
|
@ -162,7 +163,8 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
|
|||
_get_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', flags, fd=fd)
|
||||
else:
|
||||
_get_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', flags, fd=fd)
|
||||
_get_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', flags, fd=fd)
|
||||
if stat.S_ISDIR(st.st_mode):
|
||||
_get_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', flags, fd=fd)
|
||||
|
||||
|
||||
cdef _set_acl(path, type, item, attribute, numeric_ids=False, fd=None):
|
||||
|
|
|
@ -35,16 +35,28 @@ def are_acls_working():
|
|||
if is_darwin:
|
||||
acl_key = "acl_extended"
|
||||
acl_value = b"!#acl 1\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n"
|
||||
else:
|
||||
elif is_linux:
|
||||
acl_key = "acl_access"
|
||||
acl_value = b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n"
|
||||
elif is_freebsd:
|
||||
acl_key = "acl_access"
|
||||
acl_value = b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-\ngroup:wheel:rw-\n"
|
||||
else:
|
||||
return False # ACLs unsupported on this platform.
|
||||
write_acl = {acl_key: acl_value}
|
||||
acl_set(filepath, write_acl)
|
||||
read_acl = {}
|
||||
acl_get(filepath, read_acl, os.stat(filepath))
|
||||
acl = read_acl.get(acl_key, None)
|
||||
if acl is not None:
|
||||
check_for = b"root:0:allow:read" if is_darwin else b"user::rw-"
|
||||
if is_darwin:
|
||||
check_for = b"root:0:allow:read"
|
||||
elif is_linux:
|
||||
check_for = b"user::rw-"
|
||||
elif is_freebsd:
|
||||
check_for = b"user::rw-"
|
||||
else:
|
||||
return False # ACLs unsupported on this platform.
|
||||
if check_for in acl:
|
||||
return True
|
||||
except PermissionError:
|
||||
|
|
|
@ -49,6 +49,7 @@ def set_acl(path, access=None, default=None, nfs4=None, numeric_ids=False):
|
|||
@skipif_acls_not_working
|
||||
def test_access_acl():
|
||||
file1 = tempfile.NamedTemporaryFile()
|
||||
assert get_acl(file1.name) == {}
|
||||
set_acl(
|
||||
file1.name,
|
||||
access=b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-\ngroup:wheel:rw-\n",
|
||||
|
@ -86,6 +87,7 @@ def test_access_acl():
|
|||
@skipif_acls_not_working
|
||||
def test_default_acl():
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
assert get_acl(tmpdir) == {}
|
||||
set_acl(tmpdir, access=ACCESS_ACL, default=DEFAULT_ACL)
|
||||
assert get_acl(tmpdir)["acl_access"] == ACCESS_ACL
|
||||
assert get_acl(tmpdir)["acl_default"] == DEFAULT_ACL
|
||||
|
|
Loading…
Reference in a new issue