|
@@ -1,3 +1,4 @@
|
|
|
|
+import errno
|
|
import functools
|
|
import functools
|
|
import os
|
|
import os
|
|
import random
|
|
import random
|
|
@@ -58,16 +59,26 @@ def are_acls_working():
|
|
with unopened_tempfile() as filepath:
|
|
with unopened_tempfile() as filepath:
|
|
open(filepath, 'w').close()
|
|
open(filepath, 'w').close()
|
|
try:
|
|
try:
|
|
- access = b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n'
|
|
|
|
- acl = {'acl_access': access}
|
|
|
|
- acl_set(filepath, acl)
|
|
|
|
|
|
+ if is_darwin:
|
|
|
|
+ acl_key = 'acl_extended'
|
|
|
|
+ acl_value = b'!#acl 1\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n'
|
|
|
|
+ else:
|
|
|
|
+ acl_key = 'acl_access'
|
|
|
|
+ acl_value = b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n'
|
|
|
|
+ write_acl = {acl_key: acl_value}
|
|
|
|
+ acl_set(filepath, write_acl)
|
|
read_acl = {}
|
|
read_acl = {}
|
|
acl_get(filepath, read_acl, os.stat(filepath))
|
|
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:
|
|
|
|
- return True
|
|
|
|
|
|
+ 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 check_for in acl:
|
|
|
|
+ return True
|
|
except PermissionError:
|
|
except PermissionError:
|
|
pass
|
|
pass
|
|
|
|
+ except OSError as e:
|
|
|
|
+ if e.errno not in (errno.ENOTSUP, ):
|
|
|
|
+ raise
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
|