Skip to content

Commit

Permalink
macOS: improve acl_get / acl_set error handling, see #4049
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Feb 24, 2024
1 parent 92da66d commit 8ad150b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/borg/platform/darwin.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from libc.stdint cimport uint32_t
from libc.errno cimport errno

from .posix import user2uid, group2gid
from ..helpers import safe_decode, safe_encode
Expand Down Expand Up @@ -121,7 +122,7 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
else:
acl = acl_get_link_np(path, ACL_TYPE_EXTENDED)
if acl == NULL:
return
raise OSError(errno, os.strerror(errno), os.fsdecode(path))
text = acl_to_text(acl, NULL)
if text == NULL:
return
Expand All @@ -148,8 +149,10 @@ def acl_set(path, item, numeric_ids=False, fd=None):
if isinstance(path, str):
path = os.fsencode(path)
if fd is not None:
acl_set_fd_np(fd, acl, ACL_TYPE_EXTENDED)
if acl_set_fd_np(fd, acl, ACL_TYPE_EXTENDED) == -1:
raise OSError(errno, os.strerror(errno), os.fsdecode(path))
else:
acl_set_link_np(path, ACL_TYPE_EXTENDED, acl)
if acl_set_link_np(path, ACL_TYPE_EXTENDED, acl) == -1:
raise OSError(errno, os.strerror(errno), os.fsdecode(path))
finally:
acl_free(acl)

0 comments on commit 8ad150b

Please sign in to comment.