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

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