mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-19 14:02:55 +00:00
Linux: acl_get: raise OSError for errors in acl_extended_* call
Previously, these conditions were handled the same (just return): - no extended acl here - some error happened (e.g. ACLs unsupported, bad file descriptor, file not found, permission error, ...) Now there will be OSErrors for the error cases.
This commit is contained in:
parent
1269c852bf
commit
beac2fa9ae
1 changed files with 9 additions and 3 deletions
|
@ -233,16 +233,22 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
|
||||||
cdef acl_t access_acl = NULL
|
cdef acl_t access_acl = NULL
|
||||||
cdef char *default_text = NULL
|
cdef char *default_text = NULL
|
||||||
cdef char *access_text = NULL
|
cdef char *access_text = NULL
|
||||||
|
cdef int ret = 0
|
||||||
|
|
||||||
if stat.S_ISLNK(st.st_mode):
|
if stat.S_ISLNK(st.st_mode):
|
||||||
# symlinks can not have ACLs
|
# symlinks can not have ACLs
|
||||||
return
|
return
|
||||||
if isinstance(path, str):
|
if isinstance(path, str):
|
||||||
path = os.fsencode(path)
|
path = os.fsencode(path)
|
||||||
if (fd is not None and acl_extended_fd(fd) <= 0
|
if fd is not None:
|
||||||
or
|
ret = acl_extended_fd(fd)
|
||||||
fd is None and acl_extended_file(path) <= 0):
|
else:
|
||||||
|
ret = acl_extended_file(path)
|
||||||
|
if ret == 0:
|
||||||
|
# there is no ACL defining permissions other than those defined by the traditional file permission bits.
|
||||||
return
|
return
|
||||||
|
if ret < 0:
|
||||||
|
raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
|
||||||
if numeric_ids:
|
if numeric_ids:
|
||||||
converter = acl_numeric_ids
|
converter = acl_numeric_ids
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue