fix xattrs patch, use upstream version of stripcomponents patch
This commit is contained in:
parent
9934f5707a
commit
ef1451d533
@ -1,191 +0,0 @@
|
|||||||
From: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
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 OFF_FROM_HEADER(where) off_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,
|
|
||||||
if (header->header.typeflag == GNUTYPE_VOLHDR)
|
|
||||||
/* Name transformations don't apply to volume headers. */
|
|
||||||
return;
|
|
||||||
+}
|
|
||||||
|
|
||||||
+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 <http://www.gnu.org/licenses/>.
|
|
||||||
+
|
|
||||||
+# 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 -urNp tar-1.24-orig/tests/xform01.at tar-1.24/tests/xform01.at
|
|
||||||
--- tar-1.24-orig/tests/xform01.at 2010-10-24 20:07:47.000000000 +0200
|
|
||||||
+++ tar-1.24/tests/xform01.at 2010-10-25 15:49:42.866904079 +0200
|
|
||||||
@@ -29,7 +29,7 @@ AT_KEYWORDS([transform xform xform01 vol
|
|
||||||
AT_TAR_CHECK([
|
|
||||||
genfile --file file
|
|
||||||
tar -cf archive.tar -V /label/ file
|
|
||||||
-tar tf archive.tar
|
|
||||||
+tar Ptf archive.tar
|
|
||||||
],
|
|
||||||
[0],
|
|
||||||
[/label/
|
|
252
tar-1.24-stripcomponents.patch
Normal file
252
tar-1.24-stripcomponents.patch
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
From 28e91b48f680a6fab90ee39145123647345f385f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergey Poznyakoff <gray@gnu.org.ua>
|
||||||
|
Date: Tue, 26 Oct 2010 14:47:16 +0000
|
||||||
|
Subject: Make sure name matching occurs before name transformation.
|
||||||
|
|
||||||
|
The commit 9c194c99 altered that order.
|
||||||
|
|
||||||
|
* src/list.c (transform_stat_info): New function. Split off from
|
||||||
|
decode_header.
|
||||||
|
(read_and): Call transform_stat_info right before do_something,
|
||||||
|
and after deciding if we should proceed with this member name,
|
||||||
|
so that name matching occurs before name transformation.
|
||||||
|
|
||||||
|
* tests/extrac17.at: New file.
|
||||||
|
* tests/Makefile.am (TESTSUITE_AT): Add extrac17.at
|
||||||
|
* tests/testsuite.at: Include extrac17.at.
|
||||||
|
---
|
||||||
|
diff --git a/src/list.c b/src/list.c
|
||||||
|
index d15653d..e1e06ca 100644
|
||||||
|
--- a/src/list.c
|
||||||
|
+++ b/src/list.c
|
||||||
|
@@ -75,6 +75,66 @@ base64_init (void)
|
||||||
|
base64_map[(int) base_64_digits[i]] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char *
|
||||||
|
+decode_xform (char *file_name, void *data)
|
||||||
|
+{
|
||||||
|
+ int type = *(int*)data;
|
||||||
|
+
|
||||||
|
+ switch (type)
|
||||||
|
+ {
|
||||||
|
+ case XFORM_SYMLINK:
|
||||||
|
+ /* FIXME: It is not quite clear how and to which extent are the symbolic
|
||||||
|
+ links subject to filename transformation. In the absence of another
|
||||||
|
+ solution, symbolic links are exempt from component stripping and
|
||||||
|
+ name suffix normalization, but subject to filename transformation
|
||||||
|
+ proper. */
|
||||||
|
+ return file_name;
|
||||||
|
+
|
||||||
|
+ case XFORM_LINK:
|
||||||
|
+ file_name = safer_name_suffix (file_name, true, absolute_names_option);
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ case XFORM_REGFILE:
|
||||||
|
+ file_name = safer_name_suffix (file_name, false, absolute_names_option);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (strip_name_components)
|
||||||
|
+ {
|
||||||
|
+ size_t prefix_len = stripped_prefix_len (file_name,
|
||||||
|
+ strip_name_components);
|
||||||
|
+ if (prefix_len == (size_t) -1)
|
||||||
|
+ prefix_len = strlen (file_name);
|
||||||
|
+ file_name += prefix_len;
|
||||||
|
+ }
|
||||||
|
+ return file_name;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static bool
|
||||||
|
+transform_member_name (char **pinput, int type)
|
||||||
|
+{
|
||||||
|
+ return transform_name_fp (pinput, type, decode_xform, &type);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+transform_stat_info (int typeflag, struct tar_stat_info *stat_info)
|
||||||
|
+{
|
||||||
|
+ if (typeflag == GNUTYPE_VOLHDR)
|
||||||
|
+ /* Name transformations don't apply to volume headers. */
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ transform_member_name (&stat_info->file_name, XFORM_REGFILE);
|
||||||
|
+ switch (typeflag)
|
||||||
|
+ {
|
||||||
|
+ case SYMTYPE:
|
||||||
|
+ transform_member_name (&stat_info->link_name, XFORM_SYMLINK);
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ case LNKTYPE:
|
||||||
|
+ transform_member_name (&stat_info->link_name, XFORM_LINK);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Main loop for reading an archive. */
|
||||||
|
void
|
||||||
|
read_and (void (*do_something) (void))
|
||||||
|
@@ -135,7 +195,8 @@ read_and (void (*do_something) (void))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ transform_stat_info (current_header->header.typeflag,
|
||||||
|
+ ¤t_stat_info);
|
||||||
|
(*do_something) ();
|
||||||
|
continue;
|
||||||
|
|
||||||
|
@@ -495,47 +556,6 @@ read_header (union block **return_block, struct tar_stat_info *info,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static char *
|
||||||
|
-decode_xform (char *file_name, void *data)
|
||||||
|
-{
|
||||||
|
- int type = *(int*)data;
|
||||||
|
-
|
||||||
|
- switch (type)
|
||||||
|
- {
|
||||||
|
- case XFORM_SYMLINK:
|
||||||
|
- /* FIXME: It is not quite clear how and to which extent are the symbolic
|
||||||
|
- links subject to filename transformation. In the absence of another
|
||||||
|
- solution, symbolic links are exempt from component stripping and
|
||||||
|
- name suffix normalization, but subject to filename transformation
|
||||||
|
- proper. */
|
||||||
|
- return file_name;
|
||||||
|
-
|
||||||
|
- case XFORM_LINK:
|
||||||
|
- file_name = safer_name_suffix (file_name, true, absolute_names_option);
|
||||||
|
- break;
|
||||||
|
-
|
||||||
|
- case XFORM_REGFILE:
|
||||||
|
- file_name = safer_name_suffix (file_name, false, absolute_names_option);
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (strip_name_components)
|
||||||
|
- {
|
||||||
|
- size_t prefix_len = stripped_prefix_len (file_name,
|
||||||
|
- strip_name_components);
|
||||||
|
- if (prefix_len == (size_t) -1)
|
||||||
|
- prefix_len = strlen (file_name);
|
||||||
|
- file_name += prefix_len;
|
||||||
|
- }
|
||||||
|
- return file_name;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static bool
|
||||||
|
-transform_member_name (char **pinput, int type)
|
||||||
|
-{
|
||||||
|
- return transform_name_fp (pinput, type, decode_xform, &type);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
#define ISOCTAL(c) ((c)>='0'&&(c)<='7')
|
||||||
|
|
||||||
|
/* Decode things from a file HEADER block into STAT_INFO, also setting
|
||||||
|
@@ -655,23 +675,9 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
|
||||||
|
|| stat_info->dumpdir)
|
||||||
|
stat_info->is_dumpdir = true;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- if (header->header.typeflag == GNUTYPE_VOLHDR)
|
||||||
|
- /* Name transformations don't apply to volume headers. */
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- transform_member_name (&stat_info->file_name, XFORM_REGFILE);
|
||||||
|
- switch (header->header.typeflag)
|
||||||
|
- {
|
||||||
|
- case SYMTYPE:
|
||||||
|
- transform_member_name (&stat_info->link_name, XFORM_SYMLINK);
|
||||||
|
- break;
|
||||||
|
-
|
||||||
|
- case LNKTYPE:
|
||||||
|
- transform_member_name (&stat_info->link_name, XFORM_LINK);
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
/* Convert buffer at WHERE0 of size DIGS from external format to
|
||||||
|
uintmax_t. DIGS must be positive. If TYPE is nonnull, the data
|
||||||
|
are of type TYPE. The buffer must represent a value in the range
|
||||||
|
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||||
|
index b71e83c..dd375f3 100644
|
||||||
|
--- a/tests/Makefile.am
|
||||||
|
+++ b/tests/Makefile.am
|
||||||
|
@@ -83,6 +83,7 @@ TESTSUITE_AT = \
|
||||||
|
extrac14.at\
|
||||||
|
extrac15.at\
|
||||||
|
extrac16.at\
|
||||||
|
+ extrac17.at\
|
||||||
|
filerem01.at\
|
||||||
|
filerem02.at\
|
||||||
|
gzip.at\
|
||||||
|
diff --git a/tests/extrac17.at b/tests/extrac17.at
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..952c073
|
||||||
|
--- a/dev/null
|
||||||
|
+++ b/tests/extrac17.at
|
||||||
|
@@ -0,0 +1,49 @@
|
||||||
|
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||||
|
+#
|
||||||
|
+# Test suite for GNU tar.
|
||||||
|
+# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
+
|
||||||
|
+AT_SETUP([name matching/transformation ordering])
|
||||||
|
+AT_KEYWORDS([extract extrac17])
|
||||||
|
+
|
||||||
|
+# Description: Tar 1.24 changed the ordering of name matching and
|
||||||
|
+# name transformation so that the former saw already transformed
|
||||||
|
+# file names (see commit 9c194c99 and exclude06.at). This reverted
|
||||||
|
+# ordering made it impossible to match file names in certain cases.
|
||||||
|
+# In particular, the testcase below would not extract anything.
|
||||||
|
+#
|
||||||
|
+# Reported-by: "Gabor Z. Papp" <gzp@papp.hu>
|
||||||
|
+# References: <x6r5fd9jye@gzp>, <20101026175126.29028@Pirx.gnu.org.ua>
|
||||||
|
+# http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00047.html
|
||||||
|
+
|
||||||
|
+AT_TAR_CHECK([
|
||||||
|
+mkdir dir dir/subdir1 dir/subdir2 out
|
||||||
|
+genfile --file dir/subdir1/file1
|
||||||
|
+genfile --file dir/subdir2/file2
|
||||||
|
+
|
||||||
|
+tar cf dir.tar dir
|
||||||
|
+
|
||||||
|
+tar -x -v -f dir.tar -C out --strip-components=2 dir/subdir1/
|
||||||
|
+],
|
||||||
|
+[0],
|
||||||
|
+[dir/subdir1/file1
|
||||||
|
+])
|
||||||
|
+
|
||||||
|
+AT_CLEANUP
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
diff --git a/tests/testsuite.at b/tests/testsuite.at
|
||||||
|
index 40f0e41..9aaafff 100644
|
||||||
|
--- a/tests/testsuite.at
|
||||||
|
+++ b/tests/testsuite.at
|
||||||
|
@@ -155,6 +155,7 @@ m4_include([extrac13.at])
|
||||||
|
m4_include([extrac14.at])
|
||||||
|
m4_include([extrac15.at])
|
||||||
|
m4_include([extrac16.at])
|
||||||
|
+m4_include([extrac17.at])
|
||||||
|
|
||||||
|
m4_include([label01.at])
|
||||||
|
m4_include([label02.at])
|
||||||
|
--
|
||||||
|
cgit v0.8.3.2
|
Loading…
Reference in New Issue
Block a user