diff --git a/bsc1200657.patch b/bsc1200657.patch new file mode 100644 index 0000000..146fde7 --- /dev/null +++ b/bsc1200657.patch @@ -0,0 +1,149 @@ +From 49b9f54ff66d126c4c0d58ccfbc2b85f96f845fc Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Thu, 31 Mar 2022 18:26:03 -0700 +Subject: [PATCH] Retry file creation more aggressively +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* src/extract.c (maybe_recoverable): When deciding whether to +retry file creation, don’t insist on our making intermediate +subdirectories; it’s OK if some other process made them. +Problem reported by James Abbatiello in: +https://lists.gnu.org/r/bug-tar/2022-03/msg00000.html +--- + src/extract.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: tar-1.34/src/extract.c +=================================================================== +--- tar-1.34.orig/src/extract.c ++++ tar-1.34/src/extract.c +@@ -645,9 +645,9 @@ fixup_delayed_set_stat (char const *src, + it's because some required directory was not present, and if so, + create all required directories. Return zero if all the required + directories were created, nonzero (issuing a diagnostic) otherwise. +- Set *INTERDIR_MADE if at least one directory was created. */ ++ */ + static int +-make_directories (char *file_name, bool *interdir_made) ++make_directories (char *file_name) + { + char *cursor0 = file_name + FILE_SYSTEM_PREFIX_LEN (file_name); + char *cursor; /* points into the file name */ +@@ -689,7 +689,6 @@ make_directories (char *file_name, bool + desired_mode, AT_SYMLINK_NOFOLLOW); + + print_for_mkdir (file_name, cursor - file_name, desired_mode); +- *interdir_made = true; + } + else if (errno == EEXIST) + status = 0; +@@ -829,8 +828,11 @@ maybe_recoverable (char *file_name, bool + + case ENOENT: + /* Attempt creating missing intermediate directories. */ +- if (make_directories (file_name, interdir_made) == 0 && *interdir_made) +- return RECOVER_OK; ++ if (make_directories (file_name) == 0) ++ { ++ *interdir_made = true; ++ return RECOVER_OK; ++ } + break; + + default: +@@ -1329,7 +1331,7 @@ extract_file (char *file_name, int typef + first. If it doesn't exist, there is no matching entry in the list. + Otherwise, look for the entry in list which has the matching dev + and ino numbers. +- ++ + This approach avoids scanning the singly-linked list in obvious cases + and does not rely on comparing file names, which may differ for + various reasons (e.g. relative vs. absolute file names). +@@ -1342,14 +1344,14 @@ find_delayed_link_source (char const *na + + if (!delayed_link_head) + return NULL; +- ++ + if (fstatat (chdir_fd, name, &st, AT_SYMLINK_NOFOLLOW)) + { + if (errno != ENOENT) + stat_error (name); + return NULL; + } +- ++ + for (dl = delayed_link_head; dl; dl = dl->next) + { + if (dl->dev == st.st_dev && dl->ino == st.st_ino) +@@ -1357,7 +1359,7 @@ find_delayed_link_source (char const *na + } + return dl; + } +- ++ + /* Create a placeholder file with name FILE_NAME, which will be + replaced after other extraction is done by a symbolic link if + IS_SYMLINK is true, and by a hard link otherwise. Set +@@ -1385,7 +1387,7 @@ create_placeholder_file (char *file_name + */ + return 0; + } +- ++ + switch (maybe_recoverable (file_name, false, interdir_made)) + { + case RECOVER_OK: +@@ -1467,7 +1469,7 @@ extract_link (char *file_name, int typef + char const *link_name; + int rc; + struct delayed_link *dl; +- ++ + link_name = current_stat_info.link_name; + + if (! absolute_names_option && contains_dot_dot (link_name)) +@@ -1475,7 +1477,7 @@ extract_link (char *file_name, int typef + dl = find_delayed_link_source (link_name); + if (dl) + return create_placeholder_file (file_name, false, &interdir_made, dl); +- ++ + do + { + struct stat st1, st2; +@@ -1697,7 +1699,7 @@ prepare_to_extract (char const *file_nam + + case GNUTYPE_VOLHDR: + return false; +- ++ + case GNUTYPE_MULTIVOL: + ERROR ((0, 0, + _("%s: Cannot extract -- file is continued from another volume"), +@@ -1753,7 +1755,7 @@ prepare_to_extract (char const *file_nam + } + } + *fun = extractor; +- ++ + return true; + } + +@@ -1934,12 +1936,11 @@ rename_directory (char *src, char *dst) + else + { + int e = errno; +- bool interdir_made; + + switch (e) + { + case ENOENT: +- if (make_directories (dst, &interdir_made) == 0) ++ if (make_directories (dst) == 0) + { + if (renameat (chdir_fd, src, chdir_fd, dst) == 0) + return true; diff --git a/tar-recursive--files-from.patch b/tar-recursive--files-from.patch deleted file mode 100644 index e6c740c..0000000 --- a/tar-recursive--files-from.patch +++ /dev/null @@ -1,297 +0,0 @@ -From http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00009.html - -* src/common.h (name_add_file): Change signature. -* src/names.c (name_elt_alloc_matflags): New function. -(name_add_name): Use name_elt_alloc_matflags. -(name_add_file): Take matching flags as third argument. -(read_next_name): Remove trailing slashes. -* src/tar.c (parse_opt): Pass matching_flags to name_add_file. - -* tests/T-dir00.at: New file. -* tests/T-dir01.at: New file. -* tests/Makefile.am: Add new testcases. -* tests/testsuite.at: Likewise. ---- - src/common.h | 2 +- - src/names.c | 56 ++++++++++++++++++++++++++++++++++-------------------- - src/tar.c | 2 +- - tests/Makefile.am | 2 ++ - tests/T-dir00.at | 45 +++++++++++++++++++++++++++++++++++++++++++ - tests/T-dir01.at | 45 +++++++++++++++++++++++++++++++++++++++++++ - tests/testsuite.at | 2 ++ - 7 files changed, 131 insertions(+), 23 deletions(-) - create mode 100644 tests/T-dir00.at - create mode 100644 tests/T-dir01.at - -Index: tar-1.28/src/common.h -=================================================================== ---- tar-1.28.orig/src/common.h 2015-02-09 15:05:47.642772569 +0100 -+++ tar-1.28/src/common.h 2015-02-09 15:05:50.076794925 +0100 -@@ -725,7 +725,7 @@ int uname_to_uid (char const *uname, uid - void name_init (void); - void name_add_name (const char *name, int matching_flags); - void name_add_dir (const char *name); --void name_add_file (const char *name, int term); -+void name_add_file (const char *name, int term, int matching_flags); - void name_term (void); - const char *name_next (int change_dirs); - void name_gather (void); -Index: tar-1.28/src/names.c -=================================================================== ---- tar-1.28.orig/src/names.c 2015-02-09 15:05:47.642772569 +0100 -+++ tar-1.28/src/names.c 2015-02-09 15:05:50.076794925 +0100 -@@ -258,6 +258,21 @@ name_elt_alloc (void) - return elt; - } - -+static struct name_elt * -+name_elt_alloc_matflags (int matflags) -+{ -+ static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */ -+ struct name_elt *ep = name_elt_alloc (); -+ if (prev_flags != matflags) -+ { -+ ep->type = NELT_FMASK; -+ ep->v.matching_flags = matflags; -+ prev_flags = matflags; -+ ep = name_elt_alloc (); -+ } -+ return ep; -+} -+ - static void - name_list_adjust (void) - { -@@ -276,20 +291,13 @@ name_list_advance (void) - free (elt); - } - --/* Add to name_array the file NAME with fnmatch options MATCHING_FLAGS */ -+ -+/* Add to name_array the file NAME with fnmatch options MATFLAGS */ - void --name_add_name (const char *name, int matching_flags) -+name_add_name (const char *name, int matflags) - { -- static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */ -- struct name_elt *ep = name_elt_alloc (); -+ struct name_elt *ep = name_elt_alloc_matflags (matflags); - -- if (prev_flags != matching_flags) -- { -- ep->type = NELT_FMASK; -- ep->v.matching_flags = matching_flags; -- prev_flags = matching_flags; -- ep = name_elt_alloc (); -- } - ep->type = NELT_NAME; - ep->v.name = name; - name_count++; -@@ -305,9 +313,10 @@ name_add_dir (const char *name) - } - - void --name_add_file (const char *name, int term) -+name_add_file (const char *name, int term, int matflags) - { -- struct name_elt *ep = name_elt_alloc (); -+ struct name_elt *ep = name_elt_alloc_matflags (matflags); -+ - ep->type = NELT_FILE; - ep->v.file.name = name; - ep->v.file.term = term; -@@ -389,6 +398,15 @@ add_file_id (const char *filename) - file_id_list = p; - return 0; - } -+ -+/* Chop trailing slashes. */ -+static void -+chopslash (char *str) -+{ -+ char *p = str + strlen (str) - 1; -+ while (p > str && ISSLASH (*p)) -+ *p-- = '\0'; -+} - - enum read_file_list_state /* Result of reading file name from the list file */ - { -@@ -428,7 +446,7 @@ read_name_from_file (struct name_elt *en - if (counter == name_buffer_length) - name_buffer = x2realloc (name_buffer, &name_buffer_length); - name_buffer[counter] = 0; -- -+ chopslash (name_buffer); - return (counter == 0 && c == EOF) ? file_list_end : file_list_success; - } - -@@ -518,7 +536,6 @@ copy_name (struct name_elt *ep) - { - const char *source; - size_t source_len; -- char *cursor; - - source = ep->v.name; - source_len = strlen (source); -@@ -536,11 +553,7 @@ copy_name (struct name_elt *ep) - name_buffer = xmalloc(name_buffer_length + 2); - } - strcpy (name_buffer, source); -- -- /* Zap trailing slashes. */ -- cursor = name_buffer + strlen (name_buffer) - 1; -- while (cursor > name_buffer && ISSLASH (*cursor)) -- *cursor-- = '\0'; -+ chopslash (name_buffer); - } - - -@@ -553,7 +566,8 @@ static int matching_flags; /* exclude_fn - the request to change to the given directory. - - Entries of type NELT_FMASK cause updates of the matching_flags -- value. */ -+ value. -+*/ - static struct name_elt * - name_next_elt (int change_dirs) - { -Index: tar-1.28/src/tar.c -=================================================================== ---- tar-1.28.orig/src/tar.c 2015-02-09 15:05:47.642772569 +0100 -+++ tar-1.28/src/tar.c 2015-02-09 15:05:50.077794935 +0100 -@@ -1641,7 +1641,7 @@ parse_opt (int key, char *arg, struct ar - break; - - case 'T': -- name_add_file (arg, filename_terminator); -+ name_add_file (arg, filename_terminator, MAKE_INCL_OPTIONS (args)); - /* Indicate we've been given -T option. This is for backward - compatibility only, so that `tar cfT archive /dev/null will - succeed */ -Index: tar-1.28/tests/Makefile.am -=================================================================== ---- tar-1.28.orig/tests/Makefile.am 2015-02-09 15:05:47.642772569 +0100 -+++ tar-1.28/tests/Makefile.am 2015-02-09 15:05:50.077794935 +0100 -@@ -43,6 +43,8 @@ $(srcdir)/package.m4: $(top_srcdir)/conf - - TESTSUITE_AT = \ - T-cd.at\ -+ T-dir00.at\ -+ T-dir01.at\ - T-empty.at\ - T-null.at\ - T-rec.at\ -Index: tar-1.28/tests/T-dir00.at -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ tar-1.28/tests/T-dir00.at 2015-02-09 15:05:50.077794935 +0100 -@@ -0,0 +1,45 @@ -+# Process this file with autom4te to create testsuite. -*- Autotest -*- -+# -+# Test suite for GNU tar. -+# Copyright 2014 Free Software Foundation, Inc. -+ -+# This file is part of GNU tar. -+ -+# GNU tar is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+ -+# GNU tar is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+# Tar 1.27 and 1.28 did not extract files under directory memberes listed -+# in the file read by --file-from. -+# -+# Reported-by: Jean-Louis Martineau -+# References: , -+# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html -+ -+AT_SETUP([recursive extraction from --files-from]) -+AT_KEYWORDS([files-from extract T-dir T-dir00]) -+AT_TAR_CHECK([ -+mkdir dir -+genfile -f dir/file1 -+genfile -f dir/file2 -+tar cf archive dir -+rm -rf dir -+echo dir > list -+tar xfTv archive list | sort -+], -+[0], -+[dir/ -+dir/file1 -+dir/file2 -+]) -+AT_CLEANUP -+ -Index: tar-1.28/tests/T-dir01.at -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ tar-1.28/tests/T-dir01.at 2015-02-09 15:45:52.309679130 +0100 -@@ -0,0 +1,45 @@ -+# Process this file with autom4te to create testsuite. -*- Autotest -*- -+# -+# Test suite for GNU tar. -+# Copyright 2014 Free Software Foundation, Inc. -+ -+# This file is part of GNU tar. -+ -+# GNU tar is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+ -+# GNU tar is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+# Tar 1.27 and 1.28 did not remove trailing slashes from file names -+# obtained with the --file-from option. -+# -+# Reported-by: Jean-Louis Martineau -+# References: , -+# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html -+ -+AT_SETUP([trailing slash in --files-from]) -+AT_KEYWORDS([files-from extract T-dir T-dir01]) -+AT_TAR_CHECK([ -+mkdir dir -+genfile -f dir/file1 -+genfile -f dir/file2 -+tar cf archive dir -+rm -rf dir -+echo dir/ > list -+tar xfTv archive list | sort -+], -+[0], -+[dir/ -+dir/file1 -+dir/file2 -+]) -+AT_CLEANUP -+ -Index: tar-1.28/tests/testsuite.at -=================================================================== ---- tar-1.28.orig/tests/testsuite.at 2015-02-09 15:05:47.642772569 +0100 -+++ tar-1.28/tests/testsuite.at 2015-02-09 15:05:50.116795293 +0100 -@@ -205,6 +205,8 @@ m4_include([T-empty.at]) - m4_include([T-null.at]) - m4_include([T-zfile.at]) - m4_include([T-nonl.at]) -+m4_include([T-dir00.at]) -+m4_include([T-dir01.at]) - - AT_BANNER([Various options]) - m4_include([indexfile.at]) diff --git a/tar.changes b/tar.changes index d5876b1..9f21239 100644 --- a/tar.changes +++ b/tar.changes @@ -1,3 +1,22 @@ +------------------------------------------------------------------- +Sat Aug 20 06:23:22 UTC 2022 - Dirk Müller + +- drop tar-recursive--files-from.patch (causes bsc#918487) + +------------------------------------------------------------------- +Wed Aug 17 05:09:11 UTC 2022 - Simon Lees + +- bsc1200657.patch was previously incomplete leading to deadlocks + * bsc#1202436 + * bsc1200657.patch updated + +------------------------------------------------------------------- +Mon Jun 20 09:19:23 UTC 2022 - Danilo Spinella + +- Fix race condition while creating intermediate subdirectories, + bsc#1200657 + * bsc1200657.patch + ------------------------------------------------------------------- Wed Apr 13 02:38:42 UTC 2022 - William Brown diff --git a/tar.spec b/tar.spec index 030112d..c315231 100644 --- a/tar.spec +++ b/tar.spec @@ -36,12 +36,12 @@ Patch2: paxutils-rtapelib_mtget.patch # the patch is used in Fedora and Debian # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=235820 Patch3: %{name}-ignore_lone_zero_blocks.patch -# The next patch is disabled because it causes a regression: -#https://bugzilla.opensuse.org/show_bug.cgi?id=918487 -Patch4: %{name}-recursive--files-from.patch Patch5: add_readme-tests.patch Patch6: tar-PIE.patch Patch7: tests-skip-time01-on-32bit-time_t.patch +# PATCH-FIX-OPENSUSE danilo.spinella@suse.com bsc#1200657 +# fix race condition while creating intermediate subdirectories +Patch8: bsc1200657.patch BuildRequires: automake >= 1.15 BuildRequires: libacl-devel BuildRequires: libselinux-devel @@ -109,10 +109,10 @@ it may as well access remote devices or files. %patch1 -p1 %patch2 -p1 %patch3 -p1 -#%patch4 -p1 %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 %build %define my_cflags -W -Wall -Wpointer-arith -Wstrict-prototypes -Wformat-security -Wno-unused-parameter -fPIE