teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0041-tmpfiles-quietly-ignore-ACLs-on-unsupported-filesyst.patch

923a60
From 6ad61c838992d17f5faa94faa8f17967083a4226 Mon Sep 17 00:00:00 2001
923a60
From: Hans-Peter Deifel <hpd@hpdeifel.de>
923a60
Date: Tue, 3 Mar 2015 00:35:08 +0100
923a60
Subject: [PATCH] tmpfiles: quietly ignore ACLs on unsupported filesystems
923a60
923a60
A warning is printed if ACLs cannot be retrieved for any reason other
923a60
than -ENOSYS. For -ENOSYS, debug log is printed.
923a60
923a60
(cherry picked from commit d873e8778c92014c02a9122852758b436fa95c0e)
923a60
---
923a60
 src/tmpfiles/tmpfiles.c | 36 ++++++++++++++++++++----------------
923a60
 1 file changed, 20 insertions(+), 16 deletions(-)
923a60
923a60
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
923a60
index 88ba7e46a2..187997e1f4 100644
923a60
--- a/src/tmpfiles/tmpfiles.c
923a60
+++ b/src/tmpfiles/tmpfiles.c
923a60
@@ -704,6 +704,9 @@ static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modif
923a60
         int r;
923a60
         _cleanup_(acl_free_charpp) char *t = NULL;
923a60
 
923a60
+        /* Returns 0 for success, positive error if already warned,
923a60
+         * negative error otherwise. */
923a60
+
923a60
         if (modify) {
923a60
                 r = acls_for_file(path, type, acl, &dup;;
923a60
                 if (r < 0)
923a60
@@ -731,35 +734,36 @@ static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modif
923a60
 
923a60
         r = acl_set_file(path, type, dup);
923a60
         if (r < 0)
923a60
-                return log_error_errno(-errno,
923a60
-                                       "Setting %s ACL \"%s\" on %s failed: %m",
923a60
-                                       type == ACL_TYPE_ACCESS ? "access" : "default",
923a60
-                                       strna(t), path);
923a60
+                return -log_error_errno(errno,
923a60
+                                        "Setting %s ACL \"%s\" on %s failed: %m",
923a60
+                                        type == ACL_TYPE_ACCESS ? "access" : "default",
923a60
+                                        strna(t), path);
923a60
+
923a60
         return 0;
923a60
 }
923a60
 #endif
923a60
 
923a60
 static int path_set_acls(Item *item, const char *path) {
923a60
+        int r = 0;
923a60
 #ifdef HAVE_ACL
923a60
-        int r;
923a60
-
923a60
         assert(item);
923a60
         assert(path);
923a60
 
923a60
-        if (item->acl_access) {
923a60
+        if (item->acl_access)
923a60
                 r = path_set_acl(path, ACL_TYPE_ACCESS, item->acl_access, item->force);
923a60
-                if (r < 0)
923a60
-                        return r;
923a60
-        }
923a60
 
923a60
-        if (item->acl_default) {
923a60
+        if (r == 0 && item->acl_default)
923a60
                 r = path_set_acl(path, ACL_TYPE_DEFAULT, item->acl_default, item->force);
923a60
-                if (r < 0)
923a60
-                        return r;
923a60
-        }
923a60
-#endif
923a60
 
923a60
-        return 0;
923a60
+        if (r > 0)
923a60
+                return -r; /* already warned */
923a60
+        else if (r == -ENOTSUP) {
923a60
+                log_debug_errno(r, "ACLs not supported by file system at %s", path);
923a60
+                return 0;
923a60
+        } else if (r < 0)
923a60
+                log_error_errno(r, "ACL operation on \"%s\" failed: %m", path);
923a60
+#endif
923a60
+        return r;
923a60
 }
923a60
 
923a60
 static int write_one_file(Item *i, const char *path) {