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