valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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