anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

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

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