Skip to content

Commit

Permalink
freebsd: acl_get: raise OSError if lpathconf fails
Browse files Browse the repository at this point in the history
Previously:
- acl_get just returned for lpathconf returning EINVAL
- acl_get silently ignored all other lpathconf errors and
  implied it is not a NFS4 acl

Now:
- not sure why the EINVAL silent return was done, but it seems
  wrong. guess it could be the system not implementing a check
  for nfs4. but in that case guess we still would like to get
  the default and access ACL!? Thus, I removed the silent return.
- raise OSError for all lpathconf errors

Cosmetic: add a nfs4_acl boolean, so the code reads better.
  • Loading branch information
ThomasWaldmann committed Mar 3, 2024
1 parent eca84a3 commit 49539a4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/borg/platform/freebsd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
If `numeric_ids` is True the user/group field is not preserved only uid/gid
"""
cdef int flags = ACL_TEXT_APPEND_ID
flags |= ACL_TEXT_NUMERIC_IDS if numeric_ids else 0
if isinstance(path, str):
path = os.fsencode(path)
ret = acl_extended_link_np(path)
Expand All @@ -154,10 +155,10 @@ def acl_get(path, item, st, numeric_ids=False, fd=None):
if ret < 0:
raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
ret = lpathconf(path, _PC_ACL_NFS4)
if ret < 0 and errno.errno == errno.EINVAL:
return
flags |= ACL_TEXT_NUMERIC_IDS if numeric_ids else 0
if ret > 0:
if ret < 0:
raise OSError(errno.errno, os.strerror(errno.errno), os.fsdecode(path))
nfs4_acl = ret == 1
if nfs4_acl:
_get_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', flags, fd=fd)
else:
_get_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', flags, fd=fd)
Expand Down

0 comments on commit 49539a4

Please sign in to comment.