Blame SOURCES/tar-1.26-xattrs-skip-old-files-hangs.patch

94b232
diff --git a/THANKS b/THANKS
94b232
index e87381f..6fa0a9e 100644
94b232
--- a/THANKS
94b232
+++ b/THANKS
94b232
@@ -131,6 +131,7 @@ David Nugent		davidn@blaze.net.au
94b232
 David Shaw		david.shaw@alcatel.com.au
94b232
 David Steiner		dsteiner@ispa.uni-osnabrueck.de
94b232
 David Taylor		taylor@think.com
94b232
+Dawid			dpc@dpc.pw
94b232
 Dean Gaudet		dgaudet@watdragon.uwaterloo.ca
94b232
 Demizu Noritoshi	nori-d@is.aist-nara.ac.jp
94b232
 Denis Excoffier         denis.excoffier@free.fr
94b232
diff --git a/src/extract.c b/src/extract.c
94b232
index b622a2a..63e4d14 100644
94b232
--- a/src/extract.c
94b232
+++ b/src/extract.c
94b232
@@ -745,13 +745,13 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
94b232
    in advance dramatically improves the following  performance of reading and
94b232
    writing a file).  If not restoring permissions, invert the INVERT_PERMISSIONS
94b232
    bits from the file's current permissions.  TYPEFLAG specifies the type of the
94b232
-   file.  FILE_CREATED indicates set_xattr has created the file */
94b232
+   file.  Returns non-zero when error occurs (while un-available xattrs is not
94b232
+   an error, rather no-op).  Non-zero FILE_CREATED indicates set_xattr has
94b232
+   created the file. */
94b232
 static int
94b232
 set_xattr (char const *file_name, struct tar_stat_info const *st,
94b232
            mode_t invert_permissions, char typeflag, int *file_created)
94b232
 {
94b232
-  int status = 0;
94b232
-
94b232
 #ifdef HAVE_XATTRS
94b232
   bool interdir_made = false;
94b232
 
94b232
@@ -759,17 +759,32 @@ set_xattr (char const *file_name, struct tar_stat_info const *st,
94b232
     {
94b232
       mode_t mode = current_stat_info.stat.st_mode & MODE_RWX & ~ current_umask;
94b232
 
94b232
-      do
94b232
-        status = mknodat (chdir_fd, file_name, mode ^ invert_permissions, 0);
94b232
-      while (status && maybe_recoverable ((char *)file_name, false,
94b232
-                                          &interdir_made));
94b232
+      for (;;)
94b232
+        {
94b232
+          if (!mknodat (chdir_fd, file_name, mode ^ invert_permissions, 0))
94b232
+            {
94b232
+              /* Successfully created file */
94b232
+              xattrs_xattrs_set (st, file_name, typeflag, 0);
94b232
+              *file_created = 1;
94b232
+              return 0;
94b232
+            }
94b232
 
94b232
-      xattrs_xattrs_set (st, file_name, typeflag, 0);
94b232
-      *file_created = 1;
94b232
+          switch (maybe_recoverable ((char *)file_name, false, &interdir_made))
94b232
+            {
94b232
+              case RECOVER_OK:
94b232
+                continue;
94b232
+              case RECOVER_NO:
94b232
+                skip_member ();
94b232
+                open_error (file_name);
94b232
+                return 1;
94b232
+              case RECOVER_SKIP:
94b232
+                return 0;
94b232
+            }
94b232
+        }
94b232
     }
94b232
 #endif
94b232
 
94b232
-  return(status);
94b232
+  return 0;
94b232
 }
94b232
 
94b232
 /* Fix the statuses of all directories whose statuses need fixing, and
94b232
@@ -1089,11 +1104,7 @@ extract_file (char *file_name, int typeflag)
94b232
       int file_created = 0;
94b232
       if (set_xattr (file_name, &current_stat_info, invert_permissions,
94b232
                      typeflag, &file_created))
94b232
-        {
94b232
-          skip_member ();
94b232
-          open_error (file_name);
94b232
-          return 1;
94b232
-        }
94b232
+        return 1;
94b232
 
94b232
       while ((fd = open_output_file (file_name, typeflag, mode,
94b232
                                      file_created, &current_mode,
94b232
diff --git a/tests/Makefile.am b/tests/Makefile.am
94b232
index 2a70314..8e1ef8d 100644
94b232
--- a/tests/Makefile.am
94b232
+++ b/tests/Makefile.am
94b232
@@ -200,6 +200,7 @@ TESTSUITE_AT = \
94b232
  xattr04.at\
94b232
  xattr05.at\
94b232
  xattr06.at\
94b232
+ xattr07.at\
94b232
  acls01.at\
94b232
  acls02.at\
94b232
  acls03.at\
94b232
diff --git a/tests/testsuite.at b/tests/testsuite.at
94b232
index ebce9cc..3eb0eee 100644
94b232
--- a/tests/testsuite.at
94b232
+++ b/tests/testsuite.at
94b232
@@ -361,6 +361,7 @@ m4_include([xattr03.at])
94b232
 m4_include([xattr04.at])
94b232
 m4_include([xattr05.at])
94b232
 m4_include([xattr06.at])
94b232
+m4_include([xattr07.at])
94b232
 
94b232
 m4_include([acls01.at])
94b232
 m4_include([acls02.at])
94b232
diff --git a/tests/xattr07.at b/tests/xattr07.at
94b232
new file mode 100644
94b232
index 0000000..a834981
94b232
--- /dev/null
94b232
+++ b/tests/xattr07.at
94b232
@@ -0,0 +1,73 @@
94b232
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
94b232
+#
94b232
+# Test suite for GNU tar.
94b232
+# Copyright 2011, 2013-2014, 2016 Free Software Foundation, Inc.
94b232
+
94b232
+# This file is part of GNU tar.
94b232
+
94b232
+# GNU tar is free software; you can redistribute it and/or modify
94b232
+# it under the terms of the GNU General Public License as published by
94b232
+# the Free Software Foundation; either version 3 of the License, or
94b232
+# (at your option) any later version.
94b232
+
94b232
+# GNU tar is distributed in the hope that it will be useful,
94b232
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
94b232
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
94b232
+# GNU General Public License for more details.
94b232
+
94b232
+# You should have received a copy of the GNU General Public License
94b232
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
94b232
+#
94b232
+# Test description:
94b232
+# Test that --keep-old-files doesn't change xattrs of already existing file.
94b232
+# Per report:
94b232
+# https://lists.gnu.org/archive/html/bug-tar/2016-10/msg00001.html
94b232
+
94b232
+AT_SETUP([xattrs: xattrs and --skip-old-files])
94b232
+AT_KEYWORDS([xattrs xattr07])
94b232
+
94b232
+AT_TAR_CHECK([
94b232
+AT_XATTRS_PREREQ
94b232
+mkdir dir
94b232
+genfile --file dir/file
94b232
+genfile --file dir/file2
94b232
+
94b232
+setfattr -n user.test -v OurDirValue dir
94b232
+setfattr -n user.test -v OurFileValue dir/file
94b232
+setfattr -n user.test -v OurFileValue dir/file2
94b232
+
94b232
+tar --xattrs -cf archive.tar dir
94b232
+
94b232
+setfattr -n user.test -v OurDirValue2 dir
94b232
+setfattr -n user.test -v OurFileValue2 dir/file
94b232
+setfattr -n user.test -v OurFileValue2 dir/file2
94b232
+
94b232
+# Check that tar continues to file2 too!
94b232
+tar --xattrs -xvf archive.tar --skip-old-files
94b232
+tar --xattrs -xvf archive.tar --keep-old-files
94b232
+
94b232
+getfattr -h -d dir         | grep -v -e '^#' -e ^$
94b232
+getfattr -h -d dir/file    | grep -v -e '^#' -e ^$
94b232
+getfattr -h -d dir/file2   | grep -v -e '^#' -e ^$
94b232
+],
94b232
+[0],
94b232
+[dir/
94b232
+dir/file
94b232
+dir/file2
94b232
+dir/
94b232
+dir/file
94b232
+dir/file2
94b232
+user.test="OurDirValue2"
94b232
+user.test="OurFileValue2"
94b232
+user.test="OurFileValue2"
94b232
+], [tar: dir: skipping existing file
94b232
+tar: dir/file: skipping existing file
94b232
+tar: dir/file: skipping existing file
94b232
+tar: dir/file2: skipping existing file
94b232
+tar: dir/file2: skipping existing file
94b232
+tar: dir/file: Cannot open: File exists
94b232
+tar: dir/file2: Cannot open: File exists
94b232
+tar: Exiting with failure status due to previous errors
94b232
+])
94b232
+
94b232
+AT_CLEANUP
94b232
From f2a7560718946e0920b55419f0953953bf824077 Mon Sep 17 00:00:00 2001
94b232
From: Pavel Raiskup <praiskup@redhat.com>
94b232
Date: Mon, 28 Nov 2016 08:44:42 +0100
94b232
Subject: [PATCH] tests: more deterministic xattr07
94b232
94b232
* tests/xattr07.at: Define order of files within tested archive.
94b232
---
94b232
 tests/xattr07.at | 2 +-
94b232
 1 file changed, 1 insertion(+), 1 deletion(-)
94b232
94b232
diff --git a/tests/xattr07.at b/tests/xattr07.at
94b232
index a834981..47d54b8 100644
94b232
--- a/tests/xattr07.at
94b232
+++ b/tests/xattr07.at
94b232
@@ -36,7 +36,7 @@ setfattr -n user.test -v OurDirValue dir
94b232
 setfattr -n user.test -v OurFileValue dir/file
94b232
 setfattr -n user.test -v OurFileValue dir/file2
94b232
 
94b232
-tar --xattrs -cf archive.tar dir
94b232
+tar --xattrs --no-recursion -cf archive.tar dir dir/file dir/file2
94b232
 
94b232
 setfattr -n user.test -v OurDirValue2 dir
94b232
 setfattr -n user.test -v OurFileValue2 dir/file
94b232
-- 
94b232
2.13.5
94b232