]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
acl-util: fall back to fchmod() if libacl is not around, too 39637/head
authorMike Yuan <me@yhndnzj.com>
Sat, 8 Nov 2025 05:01:57 +0000 (06:01 +0100)
committerMike Yuan <me@yhndnzj.com>
Mon, 10 Nov 2025 22:06:14 +0000 (23:06 +0100)
src/shared/acl-util.c

index 58339829f3d9da3f65bd28b38d546602b318e694..1dff9646cc90e91366496924fa5314b599ac0a3e 100644 (file)
@@ -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