]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
acl-util: add new inode_type_can_acl() helper 39003/head
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Aug 2025 09:04:41 +0000 (11:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Sep 2025 19:58:44 +0000 (21:58 +0200)
src/shared/acl-util.c
src/shared/acl-util.h
src/shared/shift-uid.c
src/tmpfiles/tmpfiles.c

index a057e8028ce0e3e2ce0a58c1d24e423abf28017b..03bfcca9b648e3f6a04b5d5706f4d2089872d1c6 100644 (file)
@@ -648,3 +648,7 @@ int fd_acl_make_writable_fallback(int fd) {
 
         return 1;
 }
+
+int inode_type_can_acl(mode_t mode) {
+        return IN_SET(mode & S_IFMT, S_IFSOCK, S_IFREG, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO);
+}
index 2164017de3c6c979c20f20220cfb649e897e4397..5e28f7167f995f1d7d1cd51a1596ece96bd51526 100644 (file)
@@ -53,3 +53,5 @@ static inline int fd_acl_make_writable(int fd) {
 }
 
 #endif
+
+int inode_type_can_acl(mode_t mode);
index 9c7e875dffdfe5cf1028ca576388619e657ddf6d..2f34908fff577a0c1762ba461eb80ea5097ed907 100644 (file)
@@ -161,7 +161,7 @@ static int patch_acls(int fd, const char *name, const struct stat *st, uid_t shi
         assert(st);
 
         /* ACLs are not supported on symlinks, there's no point in trying */
-        if (S_ISLNK(st->st_mode))
+        if (!inode_type_can_acl(st->st_mode))
                 return 0;
 
         r = get_acl(fd, name, ACL_TYPE_ACCESS, &acl);
index 4342ed70abd51c4bd49e4f6817aa4bff99cd3cb8..42d67deebf654ca49b4b2823999ce8ba5d19517e 100644 (file)
@@ -1459,8 +1459,8 @@ static int fd_set_acls(
                                        "Refusing to set ACLs on hardlinked file %s while the fs.protected_hardlinks sysctl is turned off.",
                                        path);
 
-        if (S_ISLNK(st->st_mode)) {
-                log_debug("Skipping ACL fix for symlink %s.", path);
+        if (!inode_type_can_acl(st->st_mode)) {
+                log_debug("Skipping ACL fix for '%s' (inode type does not support ACLs).", path);
                 return 0;
         }