summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2024-03-02 19:59:04 +0100
committerThomas Waldmann <tw@waldmann-edv.de>2024-03-17 18:50:49 +0100
commit519e3ebce82ef3223b607f9cf7489377ae1c3f24 (patch)
tree9cc7eb001e96dd2709b1ece8c00255900cc6cacf
parent33f1ba699e2db9fbae50c31270821d2b89f094f0 (diff)
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.
-rw-r--r--src/borg/platform/linux.pyx12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/borg/platform/linux.pyx b/src/borg/platform/linux.pyx
index cb7244826..dbb07fd89 100644
--- a/src/borg/platform/linux.pyx
+++ b/src/borg/platform/linux.pyx
@@ -232,16 +232,22 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
cdef acl_t access_acl = NULL
cdef char *default_text = NULL
cdef char *access_text = NULL
+ cdef int ret = 0
if stat.S_ISLNK(st.st_mode):
# symlinks can not have ACLs
return
if isinstance(path, str):
path = os.fsencode(path)
- if (fd is not None and acl_extended_fd(fd) <= 0
- or
- fd is None and acl_extended_file(path) <= 0):
+ if fd is not None:
+ ret = acl_extended_fd(fd)
+ 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
+ if ret < 0:
+ raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
if numeric_ids:
converter = acl_numeric_ids
else: