From: Mike Yuan Date: Sat, 8 Nov 2025 05:01:57 +0000 (+0100) Subject: acl-util: fall back to fchmod() if libacl is not around, too X-Git-Tag: v259-rc1~92^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F39637%2Fhead;p=thirdparty%2Fsystemd.git acl-util: fall back to fchmod() if libacl is not around, too --- diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c index 58339829f3d..1dff9646cc9 100644 --- a/src/shared/acl-util.c +++ b/src/shared/acl-util.c @@ -682,16 +682,12 @@ int fd_acl_make_read_only(int fd) { r = dlopen_libacl(); if (r < 0) - return r; + goto maybe_fallback; acl = sym_acl_get_fd(fd); if (!acl) { - - if (!ERRNO_IS_NOT_SUPPORTED(errno)) - return -errno; - - /* No ACLs? Then just update the regular mode_t */ - return fd_acl_make_read_only_fallback(fd); + r = -errno; + goto maybe_fallback; } for (r = sym_acl_get_entry(acl, ACL_FIRST_ENTRY, &i); @@ -729,13 +725,18 @@ int fd_acl_make_read_only(int fd) { return 0; if (sym_acl_set_fd(fd, acl) < 0) { - if (!ERRNO_IS_NOT_SUPPORTED(errno)) - return -errno; - - return fd_acl_make_read_only_fallback(fd); + r = -errno; + goto maybe_fallback; } return 1; + +maybe_fallback: + if (!ERRNO_IS_NEG_NOT_SUPPORTED(r)) + return r; + + /* No ACLs? Then just update the regular mode_t */ + return fd_acl_make_read_only_fallback(fd); } #endif