|
@@ -1,15 +1,13 @@
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
+from libc cimport errno
|
|
|
|
+
|
|
from .posix import posix_acl_use_stored_uid_gid
|
|
from .posix import posix_acl_use_stored_uid_gid
|
|
from ..helpers import safe_encode, safe_decode
|
|
from ..helpers import safe_encode, safe_decode
|
|
from .xattr import _listxattr_inner, _getxattr_inner, _setxattr_inner, split_lstring
|
|
from .xattr import _listxattr_inner, _getxattr_inner, _setxattr_inner, split_lstring
|
|
|
|
|
|
API_VERSION = '1.2_05'
|
|
API_VERSION = '1.2_05'
|
|
|
|
|
|
-cdef extern from "errno.h":
|
|
|
|
- int errno
|
|
|
|
- int EINVAL
|
|
|
|
-
|
|
|
|
cdef extern from "sys/extattr.h":
|
|
cdef extern from "sys/extattr.h":
|
|
ssize_t c_extattr_list_file "extattr_list_file" (const char *path, int attrnamespace, void *data, size_t nbytes)
|
|
ssize_t c_extattr_list_file "extattr_list_file" (const char *path, int attrnamespace, void *data, size_t nbytes)
|
|
ssize_t c_extattr_list_link "extattr_list_link" (const char *path, int attrnamespace, void *data, size_t nbytes)
|
|
ssize_t c_extattr_list_link "extattr_list_link" (const char *path, int attrnamespace, void *data, size_t nbytes)
|
|
@@ -138,6 +136,8 @@ cdef _get_acl(p, type, item, attribute, flags, fd=None):
|
|
finally:
|
|
finally:
|
|
acl_free(text)
|
|
acl_free(text)
|
|
acl_free(acl)
|
|
acl_free(acl)
|
|
|
|
+ else:
|
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(p))
|
|
|
|
|
|
|
|
|
|
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
|
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
|
@@ -149,7 +149,7 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
|
|
if isinstance(path, str):
|
|
if isinstance(path, str):
|
|
path = os.fsencode(path)
|
|
path = os.fsencode(path)
|
|
ret = lpathconf(path, _PC_ACL_NFS4)
|
|
ret = lpathconf(path, _PC_ACL_NFS4)
|
|
- if ret < 0 and errno == EINVAL:
|
|
|
|
|
|
+ if ret < 0 and errno.errno == errno.EINVAL:
|
|
return
|
|
return
|
|
flags |= ACL_TEXT_NUMERIC_IDS if numeric_ids else 0
|
|
flags |= ACL_TEXT_NUMERIC_IDS if numeric_ids else 0
|
|
if ret > 0:
|
|
if ret > 0:
|
|
@@ -167,15 +167,17 @@ cdef _set_acl(path, type, item, attribute, numeric_ids=False, fd=None):
|
|
text = _nfs4_use_stored_uid_gid(text)
|
|
text = _nfs4_use_stored_uid_gid(text)
|
|
elif numeric_ids and type in (ACL_TYPE_ACCESS, ACL_TYPE_DEFAULT):
|
|
elif numeric_ids and type in (ACL_TYPE_ACCESS, ACL_TYPE_DEFAULT):
|
|
text = posix_acl_use_stored_uid_gid(text)
|
|
text = posix_acl_use_stored_uid_gid(text)
|
|
- try:
|
|
|
|
- acl = acl_from_text(<bytes> text)
|
|
|
|
- if acl is not NULL:
|
|
|
|
|
|
+ acl = acl_from_text(<bytes>text)
|
|
|
|
+ if acl:
|
|
|
|
+ try:
|
|
if fd is not None:
|
|
if fd is not None:
|
|
- acl_set_fd_np(fd, acl, type)
|
|
|
|
|
|
+ if acl_set_fd_np(fd, acl, type) == -1:
|
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
else:
|
|
else:
|
|
- acl_set_link_np(path, type, acl)
|
|
|
|
- finally:
|
|
|
|
- acl_free(acl)
|
|
|
|
|
|
+ if acl_set_link_np(path, type, acl) == -1:
|
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
|
+ finally:
|
|
|
|
+ acl_free(acl)
|
|
|
|
|
|
|
|
|
|
cdef _nfs4_use_stored_uid_gid(acl):
|
|
cdef _nfs4_use_stored_uid_gid(acl):
|