diff --git a/tar-1.23-stripcomponents.patch b/tar-1.23-stripcomponents.patch new file mode 100644 index 0000000..4a247bb --- /dev/null +++ b/tar-1.23-stripcomponents.patch @@ -0,0 +1,179 @@ +From: Kamil Dudka +Date: Fri, 24 Sep 2010 14:16:04 +0200 +Subject: [PATCH] tar: match non-stripped file names + +* src/common.h: Declare of transform_name_from_header(). +* src/list.c (read_and): Match non-stripped file names. +(transform_name_from_header): Detached part of code of decode_header(). +(print_volume_label): Avoid any change in behavior here. +(test_archive_label): Avoid any change in behavior here. +* src/update.c (update_archive): Avoid any change in behavior here. +* tests/exclude07.at: New test case. +* tests/testsuite.at: Include exclude07.at. +* tests/Makefile.am (TESTSUITE_AT): Add exclude07.at. +--- + src/common.h | 1 + + src/list.c | 14 ++++++++++++-- + src/update.c | 1 + + tests/Makefile.am | 1 + + tests/exclude07.at | 42 ++++++++++++++++++++++++++++++++++++++++++ + tests/testsuite.at | 1 + + 6 files changed, 58 insertions(+), 2 deletions(-) + +diff --git a/src/common.h b/src/common.h +index 4cadab9..3a36b9b 100644 +--- a/src/common.h ++++ b/src/common.h +@@ -575,6 +575,7 @@ extern size_t recent_long_link_blocks; + + void decode_header (union block *header, struct tar_stat_info *stat_info, + enum archive_format *format_pointer, int do_user_group); ++void transform_name_from_header(union block *header, struct tar_stat_info *); + char const *tartime (struct timespec t, bool full_time); + + #define GID_FROM_HEADER(where) gid_from_header (where, sizeof (where)) +diff --git a/src/list.c b/src/list.c +index 1edd504..4e0e1a0 100644 +--- a/src/list.c ++++ b/src/list.c +@@ -75,6 +75,7 @@ read_and (void (*do_something) (void)) + open_archive (ACCESS_READ); + do + { ++ bool skip; + prev_status = status; + tar_stat_destroy (¤t_stat_info); + +@@ -92,7 +93,7 @@ read_and (void (*do_something) (void)) + Ensure incoming names are null terminated. */ + decode_header (current_header, ¤t_stat_info, + ¤t_format, 1); +- if (! name_match (current_stat_info.file_name) ++ skip = (! name_match (current_stat_info.file_name) + || (NEWER_OPTION_INITIALIZED (newer_mtime_option) + /* FIXME: We get mtime now, and again later; this causes + duplicate diagnostics if header.mtime is bogus. */ +@@ -103,7 +104,10 @@ read_and (void (*do_something) (void)) + mtime.tv_nsec = 0, + current_stat_info.mtime = mtime, + OLDER_TAR_STAT_TIME (current_stat_info, m))) +- || excluded_name (current_stat_info.file_name)) ++ || excluded_name (current_stat_info.file_name)); ++ ++ transform_name_from_header (current_header, ¤t_stat_info); ++ if (skip) + { + switch (current_header->header.typeflag) + { +@@ -659,7 +663,11 @@ decode_header (union block *header, struct tar_stat_info *stat_info, + || stat_info->dumpdir) + stat_info->is_dumpdir = true; + } ++} + ++void ++transform_name_from_header(union block *header, struct tar_stat_info *stat_info) ++{ + transform_member_name (&stat_info->file_name, XFORM_REGFILE); + switch (header->header.typeflag) + { +@@ -1322,6 +1330,7 @@ print_volume_label () + tar_stat_init (&vstat); + assign_string (&vstat.file_name, "."); + decode_header (&vblk, &vstat, &dummy, 0); ++ transform_name_from_header (&vblk, &vstat); + assign_string (&vstat.file_name, volume_label); + simple_print_header (&vstat, &vblk, 0); + tar_stat_destroy (&vstat); +@@ -1431,6 +1440,7 @@ test_archive_label () + + decode_header (current_header, + ¤t_stat_info, ¤t_format, 0); ++ transform_name_from_header (current_header, ¤t_stat_info); + if (current_header->header.typeflag == GNUTYPE_VOLHDR) + assign_string (&volume_label, current_header->header.name); + +diff --git a/src/update.c b/src/update.c +index b015175..7dd16cb 100644 +--- a/src/update.c ++++ b/src/update.c +@@ -130,6 +130,7 @@ update_archive (void) + + decode_header (current_header, ¤t_stat_info, + ¤t_format, 0); ++ transform_name_from_header (current_header, ¤t_stat_info); + archive_format = current_format; + + if (subcommand_option == UPDATE_SUBCOMMAND +diff --git a/tests/Makefile.am b/tests/Makefile.am +index fe2535a..7434fc2 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -67,6 +67,7 @@ TESTSUITE_AT = \ + exclude04.at\ + exclude05.at\ + exclude06.at\ ++ exclude07.at\ + extrac01.at\ + extrac02.at\ + extrac03.at\ +diff --git a/tests/exclude07.at b/tests/exclude07.at +new file mode 100644 +index 0000000..ad376aa +--- /dev/null ++++ b/tests/exclude07.at +@@ -0,0 +1,42 @@ ++# Process this file with autom4te to create testsuite. -*- Autotest -*- ++# Copyright (C) 2010 Free Software Foundation, Inc. ++ ++# This program 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, or (at your option) ++# any later version. ++ ++# This program 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 . ++ ++# upstream tar from 14efeb9f956e38d7beaf3fbedb04d3f3bb9ece3a fails to exclude ++# files by stripped part of path by --strip-components ++# ++# Reported-by: Darius Ivanauskas ++# References: https://bugzilla.redhat.com/637085 ++ ++AT_SETUP([exclude: stripped part of path]) ++AT_KEYWORDS([exclude exclude07]) ++ ++AT_TAR_CHECK([ ++mkdir foo bar ++genfile --length 20 -f foo/file1 ++genfile --length 20 -f foo/file2 ++genfile --length 20 -f foo/file3 ++genfile --length 20 -f bar/file4 ++ ++tar cf archive.tar foo bar ++mkdir out ++tar -C out -xf archive.tar --strip-components=1 bar/ ++find out -type f ++], ++[0], ++[out/file4] ++) ++ ++AT_CLEANUP +diff --git a/tests/testsuite.at b/tests/testsuite.at +index ef70b99..8b533ed 100644 +--- a/tests/testsuite.at ++++ b/tests/testsuite.at +@@ -131,6 +131,7 @@ m4_include([exclude03.at]) + m4_include([exclude04.at]) + m4_include([exclude05.at]) + m4_include([exclude06.at]) ++m4_include([exclude07.at]) + + m4_include([delete01.at]) + m4_include([delete02.at]) diff --git a/tar.spec b/tar.spec index c8c964d..0ba3a65 100644 --- a/tar.spec +++ b/tar.spec @@ -5,7 +5,7 @@ Summary: A GNU file archiving program Name: tar Epoch: 2 Version: 1.23 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv3+ Group: Applications/Archiving URL: http://www.gnu.org/software/tar/ @@ -35,6 +35,8 @@ Patch7: tar-1.23-oldarchive.patch Patch8: tar-1.23-longnames.patch #do not crash with --listed-incremental (#635318) Patch9: tar-1.23-listedincremental.patch +#match non-stripped file names (#637085) +Patch10: tar-1.23-stripcomponents.patch Requires: info BuildRequires: autoconf automake gzip texinfo gettext libacl-devel gawk rsh %if %{WITH_SELINUX} @@ -67,6 +69,7 @@ the rmt package. %patch7 -p1 -b .oldarchive %patch8 -p1 -b .longnames %patch9 -p1 -b .listedincremental +%patch10 -p1 -b .stripcomponents autoreconf @@ -113,7 +116,7 @@ fi %files -f %{name}.lang %defattr(-,root,root) -%doc AUTHORS ChangeLog ChangeLog.1 NEWS README THANKS TODO +%doc AUTHORS ChangeLog ChangeLog.1 COPYING NEWS README THANKS TODO %ifos linux /bin/tar /bin/gtar @@ -128,6 +131,9 @@ fi %{_infodir}/tar.info* %changelog +* Fri Sep 24 2010 Kamil Dudka 2:1.23-7 +- match non-stripped file names (#637085) + * Mon Sep 20 2010 Kamil Dudka 2:1.23-6 - fix exclusion of long file names with --xattrs (#634866) - do not crash with --listed-incremental (#635318)