mirror of
https://github.com/borgbackup/borg.git
synced 2026-07-16 05:22:49 -04:00
use skipif_acls_not_working decorator for freebsd also
use platform-specific ACLs to check. for unsupported platform, just return False.
This commit is contained in:
parent
9c1088c95c
commit
aa5168a21e
2 changed files with 14 additions and 3 deletions
|
|
@ -31,13 +31,22 @@ def are_acls_working():
|
|||
with unopened_tempfile() as filepath:
|
||||
open(filepath, "w").close()
|
||||
try:
|
||||
access = b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n"
|
||||
if is_freebsd:
|
||||
access = b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-\n"
|
||||
contained = b"user:root:rw-"
|
||||
elif is_linux:
|
||||
access = b"user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:0\n"
|
||||
contained = b"user:root:rw-:0"
|
||||
elif is_darwin:
|
||||
return True # improve?
|
||||
else:
|
||||
return False # unsupported platform
|
||||
acl = {"acl_access": access}
|
||||
acl_set(filepath, acl)
|
||||
read_acl = {}
|
||||
acl_get(filepath, read_acl, os.stat(filepath))
|
||||
read_acl_access = read_acl.get("acl_access", None)
|
||||
if read_acl_access and b"user::rw-" in read_acl_access:
|
||||
if read_acl_access and contained in read_acl_access:
|
||||
return True
|
||||
except PermissionError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import os
|
|||
import tempfile
|
||||
|
||||
from ..platform import acl_get, acl_set
|
||||
from .platform import skipif_not_freebsd
|
||||
from .platform import skipif_not_freebsd, skipif_acls_not_working
|
||||
|
||||
# set module-level skips
|
||||
pytestmark = [skipif_not_freebsd]
|
||||
|
|
@ -46,6 +46,7 @@ def set_acl(path, access=None, default=None, nfs4=None, numeric_ids=False):
|
|||
acl_set(path, item, numeric_ids=numeric_ids)
|
||||
|
||||
|
||||
@skipif_acls_not_working
|
||||
def test_access_acl():
|
||||
file1 = tempfile.NamedTemporaryFile()
|
||||
set_acl(
|
||||
|
|
@ -82,6 +83,7 @@ def test_access_acl():
|
|||
assert b"group:9999:rw-" in acl_access_ids
|
||||
|
||||
|
||||
@skipif_acls_not_working
|
||||
def test_default_acl():
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
set_acl(tmpdir, access=ACCESS_ACL, default=DEFAULT_ACL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue