|
@@ -261,12 +261,14 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
|
|
|
raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
if access_acl:
|
|
|
access_text = acl_to_text(access_acl, NULL)
|
|
|
- if access_text:
|
|
|
- item['acl_access'] = converter(access_text)
|
|
|
+ if access_text == NULL:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ item['acl_access'] = converter(access_text)
|
|
|
if default_acl:
|
|
|
default_text = acl_to_text(default_acl, NULL)
|
|
|
- if default_text:
|
|
|
- item['acl_default'] = converter(default_text)
|
|
|
+ if default_text == NULL:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ item['acl_default'] = converter(default_text)
|
|
|
finally:
|
|
|
acl_free(access_text)
|
|
|
acl_free(access_acl)
|
|
@@ -291,24 +293,26 @@ def acl_set(path, item, numeric_ids=False, fd=None):
|
|
|
access_text = item.get('acl_access')
|
|
|
if access_text is not None:
|
|
|
try:
|
|
|
- access_acl = acl_from_text(<bytes> converter(access_text))
|
|
|
- if access_acl is not NULL:
|
|
|
- if fd is not None:
|
|
|
- if acl_set_fd(fd, access_acl) == -1:
|
|
|
- raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
- else:
|
|
|
- if acl_set_file(path, ACL_TYPE_ACCESS, access_acl) == -1:
|
|
|
- raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ access_acl = acl_from_text(<bytes>converter(access_text))
|
|
|
+ if access_acl == NULL:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ if fd is not None:
|
|
|
+ if acl_set_fd(fd, access_acl) == -1:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ else:
|
|
|
+ if acl_set_file(path, ACL_TYPE_ACCESS, access_acl) == -1:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
finally:
|
|
|
acl_free(access_acl)
|
|
|
default_text = item.get('acl_default')
|
|
|
if default_text is not None:
|
|
|
try:
|
|
|
- default_acl = acl_from_text(<bytes> converter(default_text))
|
|
|
- if default_acl is not NULL:
|
|
|
- # only directories can get a default ACL. there is no fd-based api to set it.
|
|
|
- if acl_set_file(path, ACL_TYPE_DEFAULT, default_acl) == -1:
|
|
|
- raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ default_acl = acl_from_text(<bytes>converter(default_text))
|
|
|
+ if default_acl == NULL:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
+ # only directories can get a default ACL. there is no fd-based api to set it.
|
|
|
+ if acl_set_file(path, ACL_TYPE_DEFAULT, default_acl) == -1:
|
|
|
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
|
|
finally:
|
|
|
acl_free(default_acl)
|
|
|
|