Blame SOURCES/tar-1.26-xattrs-exclude-include-repair.patch

b77676
diff -urN tar-1.26/src/xattrs.c tar-1.26new/src/xattrs.c
b77676
--- tar-1.26/src/xattrs.c	2017-01-10 10:58:11.894958586 +0100
b77676
+++ tar-1.26new/src/xattrs.c	2017-01-10 11:54:23.418221159 +0100
b77676
@@ -436,8 +436,12 @@
b77676
   clear_mask_map (&xattrs_setup.excl);
b77676
 }
b77676
 
b77676
-/* get all xattrs from file given by FILE_NAME or FD (when non-zero).  This
b77676
-   includes all the user.*, security.*, system.*, etc. available domains */
b77676
+static bool xattrs_masked_out (const char *kw, bool archiving);
b77676
+
b77676
+/* get xattrs from file given by FILE_NAME or FD (when non-zero)
b77676
+   xattrs are checked against the user supplied include/exclude mask
b77676
+   if no mask is given this includes all the user.*, security.*, system.*,
b77676
+   etc. available domains */
b77676
 void
b77676
 xattrs_xattrs_get (int parentfd, char const *file_name,
b77676
                    struct tar_stat_info *st, int fd)
b77676
@@ -482,8 +486,6 @@
b77676
               size_t len = strlen (attr);
b77676
               ssize_t aret = 0;
b77676
 
b77676
-              /* Archive all xattrs during creation, decide at extraction time
b77676
-               * which ones are of interest/use for the target filesystem. */
b77676
               while (((fd == 0)
b77676
                       ? ((aret = lgetxattrat (parentfd, file_name, attr,
b77676
                                               val, asz)) == -1)
b77676
@@ -494,7 +496,10 @@
b77676
                 }
b77676
 
b77676
               if (aret != -1)
b77676
-                xheader_xattr_add (st, attr, val, aret);
b77676
+                {
b77676
+                  if (!xattrs_masked_out (attr, true))
b77676
+                    xheader_xattr_add (st, attr, val, aret);
b77676
+                }
b77676
               else if (errno != ENOATTR)
b77676
                 call_arg_warn ((fd == 0) ? "lgetxattrat"
b77676
                                : "fgetxattr", file_name);
b77676
diff -urN tar-1.26/tests/Makefile.am tar-1.26new/tests/Makefile.am
b77676
--- tar-1.26/tests/Makefile.am	2017-01-10 10:58:11.894958586 +0100
b77676
+++ tar-1.26new/tests/Makefile.am	2017-01-10 11:53:55.046987231 +0100
b77676
@@ -177,6 +177,7 @@
b77676
  xattr03.at\
b77676
  xattr04.at\
b77676
  xattr05.at\
b77676
+ xattr06.at\
b77676
  acls01.at\
b77676
  acls02.at\
b77676
  acls03.at\
b77676
diff -urN tar-1.26/tests/testsuite.at tar-1.26new/tests/testsuite.at
b77676
--- tar-1.26/tests/testsuite.at	2017-01-10 10:58:11.896958604 +0100
b77676
+++ tar-1.26new/tests/testsuite.at	2017-01-10 11:53:55.047987240 +0100
b77676
@@ -338,6 +338,7 @@
b77676
 m4_include([xattr03.at])
b77676
 m4_include([xattr04.at])
b77676
 m4_include([xattr05.at])
b77676
+m4_include([xattr06.at])
b77676
 
b77676
 m4_include([acls01.at])
b77676
 m4_include([acls02.at])
b77676
diff -urN tar-1.26/tests/xattr06.at tar-1.26new/tests/xattr06.at
b77676
--- tar-1.26/tests/xattr06.at	1970-01-01 01:00:00.000000000 +0100
b77676
+++ tar-1.26new/tests/xattr06.at	2017-01-10 11:54:23.418221159 +0100
b77676
@@ -0,0 +1,56 @@
b77676
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
b77676
+#
b77676
+# Test suite for GNU tar.
b77676
+# Copyright 2012-2014, 2016 Free Software Foundation, Inc.
b77676
+
b77676
+# This file is part of GNU tar.
b77676
+
b77676
+# GNU tar is free software; you can redistribute it and/or modify
b77676
+# it under the terms of the GNU General Public License as published by
b77676
+# the Free Software Foundation; either version 3 of the License, or
b77676
+# (at your option) any later version.
b77676
+
b77676
+# GNU tar is distributed in the hope that it will be useful,
b77676
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b77676
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b77676
+# GNU General Public License for more details.
b77676
+
b77676
+# You should have received a copy of the GNU General Public License
b77676
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
b77676
+#
b77676
+# Test description:  Test for exclude of xattr during archive creation
b77676
+#
b77676
+# Relevant mailing list thread:
b77676
+#
b77676
+# http://lists.gnu.org/archive/html/bug-tar/2016-05/msg00031.html
b77676
+
b77676
+AT_SETUP([xattrs: exclude xattrs on create ])
b77676
+AT_KEYWORDS([xattrs xattr06])
b77676
+
b77676
+AT_TAR_CHECK([
b77676
+AT_XATTRS_PREREQ
b77676
+
b77676
+mkdir dir
b77676
+mkdir output
b77676
+genfile --file dir/file
b77676
+
b77676
+for attr in excluded incla inclb inclc incl_excluded
b77676
+do
b77676
+  setfattr -n user.${attr} -v value dir/file || AT_SKIP_TEST
b77676
+done
b77676
+
b77676
+tar --xattrs-include=user.incl'*' --xattrs-exclude=user.incl_excluded -cf archive.tar -C dir .
b77676
+tar -xf archive.tar --xattrs-include=user.incl[[ab]] --xattrs-exclude=user.inclb -C output
b77676
+
b77676
+getfattr -d output/file | grep -v \
b77676
+    -e excluded \
b77676
+    -e inclb \
b77676
+    -e inclc > filtered
b77676
+getfattr -d output/file > full
b77676
+# if they differ then the attribute is still present
b77676
+diff filtered full
b77676
+],
b77676
+[0],
b77676
+[])
b77676
+
b77676
+AT_CLEANUP