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

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