Blame SOURCES/coreutils-8.30-cp-preserve-xattr-NFSv4-ACL.patch

d3767b
From ce137aaf4b0d62b3e4c88816485a3ab0f5c4b3f3 Mon Sep 17 00:00:00 2001
d3767b
From: Kamil Dudka <kdudka@redhat.com>
d3767b
Date: Thu, 6 Dec 2018 13:14:00 +0100
d3767b
Subject: [PATCH] cp --preserve=xattr: preserve NFSv4 ACL extended attributes
d3767b
d3767b
... that cannot be preserved by other means
d3767b
---
d3767b
 src/copy.c | 22 +++++++++++++++++-----
d3767b
 1 file changed, 17 insertions(+), 5 deletions(-)
d3767b
d3767b
diff --git a/src/copy.c b/src/copy.c
d3767b
index 1a9cdd1..d227e3e 100644
d3767b
--- a/src/copy.c
d3767b
+++ b/src/copy.c
d3767b
@@ -640,6 +640,17 @@ copy_attr_free (struct error_context *ctx _GL_UNUSED,
d3767b
 {
d3767b
 }
d3767b
 
d3767b
+/* Include NFSv4 ACL extended attributes that cannot be preserved by
d3767b
+   other means.  Otherwise honor attributes configured for exclusion
d3767b
+   in /etc/xattr.conf.  Return zero to skip.  */
d3767b
+static int
d3767b
+check_not_nfs4_acl (const char *name, struct error_context *ctx)
d3767b
+{
d3767b
+  return attr_copy_check_permissions(name, ctx)
d3767b
+         || !STRNCMP_LIT (name, "system.nfs4_acl")
d3767b
+         || !STRNCMP_LIT (name, "system.nfs4acl");
d3767b
+}
d3767b
+
d3767b
 /* Exclude SELinux extended attributes that are otherwise handled,
d3767b
    and are problematic to copy again.  Also honor attributes
d3767b
    configured for exclusion in /etc/xattr.conf.
d3767b
@@ -649,7 +660,7 @@ static int
d3767b
 check_selinux_attr (const char *name, struct error_context *ctx)
d3767b
 {
d3767b
   return STRNCMP_LIT (name, "security.selinux")
d3767b
-         && attr_copy_check_permissions (name, ctx);
d3767b
+         && check_not_nfs4_acl (name, ctx);
d3767b
 }
d3767b
 
d3767b
 /* If positive SRC_FD and DST_FD descriptors are passed,
d3767b
@@ -663,6 +674,9 @@ copy_attr (char const *src_path, int src_fd,
d3767b
   bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
d3767b
   bool some_errors = (!all_errors && !x->reduce_diagnostics);
d3767b
   bool selinux_done = (x->preserve_security_context || x->set_security_context);
d3767b
+  int (*check) (const char *, struct error_context *) = (selinux_done)
d3767b
+    ? check_selinux_attr
d3767b
+    : check_not_nfs4_acl;
d3767b
   struct error_context ctx =
d3767b
   {
d3767b
     .error = all_errors ? copy_attr_allerror : copy_attr_error,
d3767b
@@ -670,12 +684,10 @@ copy_attr (char const *src_path, int src_fd,
d3767b
     .quote_free = copy_attr_free
d3767b
   };
d3767b
   if (0 <= src_fd && 0 <= dst_fd)
d3767b
-    ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
d3767b
-                        selinux_done ? check_selinux_attr : NULL,
d3767b
+    ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd, check,
d3767b
                         (all_errors || some_errors ? &ctx : NULL));
d3767b
   else
d3767b
-    ret = attr_copy_file (src_path, dst_path,
d3767b
-                          selinux_done ? check_selinux_attr : NULL,
d3767b
+    ret = attr_copy_file (src_path, dst_path, check,
d3767b
                           (all_errors || some_errors ? &ctx : NULL));
d3767b
 
d3767b
   return ret == 0;
d3767b
-- 
d3767b
2.17.2
d3767b