14 Commits

Author SHA1 Message Date
Sergey Poznyakoff
ecd700fbfb Version 1.25
* configure.ac: Version 1.25
* NEWS: Describe the changes.
2010-11-07 16:04:48 +02:00
Sergey Poznyakoff
f1fed3996a Run alternative decompression programs if the principal one is not available.
Some compression programs are able to handle various compression formats
(e.g. `gzip' can decompress files created by `compress', `xz' is able
to handle lzma, etc.)  Tar tries to use such programs for decompression
if the principal decompressor cannot be started.

* src/buffer.c (compress_type): Swap ct_none and ct_tar.
(archive_compression_type): New static variable.
(zip_magic): Remove program and option fields.
(zip_program): New structure and static.
(compress_program): Remove macro.
(find_zip_program): New static function.
(first_decompress_program,next_decompress_program): New functions.
(open_compressed_archive): Set archive_compression_type instead of
use_compress_program_option.
* src/common.h (first_decompress_program)
(next_decompress_program): New functions.
(WARN_DECOMPRESS_PROGRAM): New flag.
(WARN_VERBOSE_WARNINGS): Include WARN_DECOMPRESS_PROGRAM.
* src/warning.c (warning_args): Add "decompress-program".
(warning_types): Add WARN_DECOMPRESS_PROGRAM.
* src/system.c (run_decompress_program): New function.
(sys_child_open_for_uncompress): Use run_decompress_program
instead of calling execlp directly.
2010-11-05 10:09:51 +02:00
Paul Eggert
b32edff5aa tests: fix some issues with signals, timestamps, "test" typo
* tests/extrac17.at: Add --warning=no-timestamp, to avoid
bogus warning due to NFS clock skew.
* tests/remfiles01.at: Discard diagnostics that some shells
generate about broken pipes.
* tests/sigpipe.at: Likewise.
* tests/remfiles01.at: Fix typo: "test $EC" was written where
"test $EC -ne 0" was intended.
2010-11-02 01:05:16 -07:00
Sergey Poznyakoff
3913675640 Fix extraction of device nodes.
* src/extract.c (extract_node): Do not mask out node type.
The bug was introduced in commit ea964cce.
2010-11-01 15:05:25 +02:00
Paul Eggert
b8feb2b142 tar: don't cross struct member boundaries with OLDGNU_MAGIC
* src/create.c (write_gnu_long_link, start_header): Access
header->buffer + offsetof (struct posix_header, magic), instead of
header->header.magic, when reading or writing the OLDGNU_MAGIC
pattern.  The code violates the C standard without this change,
and GCC warns about this if fortify checking is enabled.  It's not
a bug on traditional (i.e., non-debugging) platforms, but it does
violate the C standard so it should be fixed.  Problem originally
reported by John Emil Karlson in
<http://lists.gnu.org/archive/html/bug-tar/2010-04/msg00023.html>.
* src/list.c (decode_header): Likewise.
2010-10-27 22:31:16 -07:00
Paul Eggert
3fe59ed5ef tests: port to sh variants that squirrel away file descriptors
OpenBSD /bin/sh, and some other sh variants, squirrel away file
descriptors before closing them.  For example, for "cat 3<&-" they
first dup file descriptor 3 to a fd that is 10 or greater, then
close 3 (because if "cat" had been a builtin command like ":" then
they would have wanted to avoid the fork and restore the fd after
":" finished); and they treat ordinary (forking) commands the same
as builtin commands.  This approach fails after "ulimit -n 10".
Work around this deficiency by closing the file descriptors before
invoking ulimit.  Problem reported by Christian Weisgerber in
<http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00041.html>;
solution suggested by Jilles Tjoelker in
<http://article.gmane.org/gmane.comp.shells.dash/415>.

* tests/extrac11.at (scarce file descriptors): Close file
descriptors before invoking ulimit -n.
2010-10-27 20:25:56 -07:00
Sergey Poznyakoff
5af29cb944 Transform file names when updating and appendig to archives.
This complements 28e91b48.

* src/common.h (transform_stat_info): New prototype.
* src/list.c (transform_stat_info): Remove static qualifier.
* src/update.c (update_archive): Call transform_stat_info.
* tests/Makefile.am (TESTSUITE_AT): Add append03.at
* tests/testsuite.at: Include append03.at
2010-10-27 14:07:46 +03:00
Paul Eggert
7dd57ebdfa tests: port to Solaris diff
* tests/extrac13.at: Don't assume that "diff -c" outputs nothing
when there are no differences.  This is not true on Solaris,
where it outputs "No differences encounted".
2010-10-26 18:13:03 -07:00
Paul Eggert
e23d123b93 tar: fix -x --overwrite bug (no --dereference, ! O_NOFOLLOW)
This bug was discovered on Solaris 8.  On older hosts lacking
O_NOFOLLOW, tar -x --overwrite (without --dereference) follows
symbolic links, causing the "extract over symlinks" test to fail.

* src/extract.c (open_output_file): If O_NOFOLLOW is needed but
does not work, check for a symlink separately.
2010-10-26 17:58:53 -07:00
Paul Eggert
6398c7a79c tar: don't use "((" in shell scripts
* tests/extrac11.at: Replace "((" with "( (" in shell scripts, as
"((" is not portable to the Korn shell, and POSIX 1003.1-2008 says
that "((" is not portable.
2010-10-26 15:04:56 -07:00
Sergey Poznyakoff
28e91b48f6 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.
2010-10-26 22:29:02 +03:00
Paul Eggert
3c0bedd494 tar: don't assume stdin is open when testing fd limits
* tests/extrac11.at: Redirect stdin from /dev/null, in case
the parent 'make' is running with stdin closed.
2010-10-26 11:33:38 -07:00
Sergey Poznyakoff
c520964e84 Further fixes in bootstrap.
* bootstrap: Restore the default for gnulib_path
(symlink_to_dir): Re-apply 67cad07.
2010-10-26 16:48:40 +03:00
Paul Eggert
acb77ac5bd tar: fix bug with -C and extracting directories
Problem reported by Denis Excoffier in
<http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00034.html>.

* src/extract.c (extract_dir): Use mkdirat, not mkdir.
* tests/extrac16.at: New file, to test for this bug.
* tests/Makefile.am (TESTSUITE_AT): Add it.
* tests/testsuite.at: Include it.

This file is a placeholder. It will be replaced with the actual ChangeLog
by make dist.  Run make ChangeLog if you wish to create it earlier.
2010-10-25 20:21:06 -07:00
21 changed files with 441 additions and 113 deletions

30
NEWS
View File

@@ -1,6 +1,34 @@
GNU tar NEWS - User visible changes. 2010-10-24
GNU tar NEWS - User visible changes. 2010-11-07
Please send GNU tar bug reports to <bug-tar@gnu.org>
version 1.25 - Sergey Poznyakoff, 2010-11-07
* Fix extraction of empty directories with the -C option in effect.
* Fix extraction of device nodes.
* Make sure name matching occurs before eventual name transformation.
Tar 1.24 changed the ordering of name matching and name transformation
so that the former saw already transformed file names. This made it
impossible to match file names in certain cases. It is fixed now.
* Fix the behavior of tar -x --overwrite on hosts lacking O_NOFOLLOW.
* Improve the testsuite.
* Alternative decompression programs.
If extraction from a compressed archive fails because the corresponding
compression program is not installed and the following two conditions
are met, tar retries extraction using an alternative decompressor:
1. Another compression program supported by tar is able to handle this
compression format.
2. The compression program was not explicitly requested in the command
line by the use of such options as -z, -j, etc.
For example, if `compress' is not available, tar will try `gzip'.
version 1.24 - Sergey Poznyakoff, 2010-10-24

View File

@@ -464,8 +464,7 @@ git_modules_config () {
}
gnulib_path=`git_modules_config submodule.gnulib.path`
: ${gnulib_path=gnulib}
: ${gnulib_path:=gnulib}
# Get gnulib files.
case ${GNULIB_SRCDIR--} in
@@ -623,6 +622,7 @@ symlink_to_dir()
/*) ;;
*)
case /$dst/ in
/./*) ;;
*//* | */../* | */./* | /*/*/*/*/*/)
echo >&2 "$0: invalid symlink calculation: $src -> $dst"
exit 1;;

View File

@@ -19,7 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
AC_INIT([GNU tar], [1.24], [bug-tar@gnu.org])
AC_INIT([GNU tar], [1.25], [bug-tar@gnu.org])
AC_CONFIG_SRCDIR([src/tar.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])

View File

@@ -4166,6 +4166,23 @@ Disable all warning messages.
@cindex @samp{Ignoring unknown extended header keyword `%s'}, warning message
@item unknown-keyword
@samp{Ignoring unknown extended header keyword `%s'}
@kwindex decompress-program
@item decompress-program
Controls verbose messages describing execution failures when trying
alternative decompressor programs (@pxref{alternative decompression
programs}). This warning is disabled by default (unless
@option{--verbose} is used). A common example of what you can get
when using this warning is:
@smallexample
$ @kbd{tar --warning=decompress-program -x -f archive.Z}
tar (child): cannot run compress: No such file or directory
tar (child): trying gzip
@end smallexample
This means that @command{tar} first tried to decompress
@file{archive.Z} using @command{compress}, and, when that
failed, switched to @command{gzip}.
@end table
@subheading Keywords controlling incremental extraction:
@@ -8755,6 +8772,24 @@ certain compression formats. If this approach fails, @command{tar}
falls back to using archive name suffix to determine its format
(@pxref{auto-compress}, for a list of recognized suffixes).
@anchor{alternative decompression programs}
@cindex alternative decompression programs
Some compression programs are able to handle different compression
formats. @GNUTAR{} uses this, if the principal decompressor for the
given format is not available. For example, if @command{compress} is
not installed, @command{tar} will try to use @command{gzip}. As of
version @value{VERSION} the following alternatives are
tried@footnote{To verbosely trace the decompressor selection, use the
@option{--warning=decompress-program} option
(@pxref{warnings,decompress-program}).}:
@multitable @columnfractions 0.3 0.3 0.3
@headitem Format @tab Main decompressor @tab Alternatives
@item compress @tab compress @tab gzip
@item lzma @tab lzma @tab xz
@item bzip2 @tab bzip2 @tab lbzip2
@end multitable
The only case when you have to specify a decompression option while
reading the archive is when reading from a pipe or from a tape drive
that does not support random access. However, in this case @GNUTAR{}

View File

@@ -261,8 +261,8 @@ compute_duration ()
/* Compression detection */
enum compress_type {
ct_tar, /* Plain tar file */
ct_none, /* Unknown compression type */
ct_tar, /* Plain tar file */
ct_compress,
ct_gzip,
ct_bzip2,
@@ -272,31 +272,102 @@ enum compress_type {
ct_xz
};
static enum compress_type archive_compression_type = ct_none;
struct zip_magic
{
enum compress_type type;
size_t length;
char const *magic;
};
struct zip_program
{
enum compress_type type;
char const *program;
char const *option;
};
static struct zip_magic const magic[] = {
{ ct_tar },
{ ct_none, },
{ ct_compress, 2, "\037\235", COMPRESS_PROGRAM, "-Z" },
{ ct_gzip, 2, "\037\213", GZIP_PROGRAM, "-z" },
{ ct_bzip2, 3, "BZh", BZIP2_PROGRAM, "-j" },
{ ct_lzip, 4, "LZIP", LZIP_PROGRAM, "--lzip" },
{ ct_lzma, 6, "\xFFLZMA", LZMA_PROGRAM, "--lzma" },
{ ct_lzop, 4, "\211LZO", LZOP_PROGRAM, "--lzop" },
{ ct_xz, 6, "\xFD" "7zXZ", XZ_PROGRAM, "-J" },
{ ct_tar },
{ ct_compress, 2, "\037\235" },
{ ct_gzip, 2, "\037\213" },
{ ct_bzip2, 3, "BZh" },
{ ct_lzip, 4, "LZIP" },
{ ct_lzma, 6, "\xFFLZMA" },
{ ct_lzop, 4, "\211LZO" },
{ ct_xz, 6, "\xFD" "7zXZ" },
};
#define NMAGIC (sizeof(magic)/sizeof(magic[0]))
#define compress_option(t) magic[t].option
#define compress_program(t) magic[t].program
static struct zip_program zip_program[] = {
{ ct_compress, COMPRESS_PROGRAM, "-Z" },
{ ct_compress, GZIP_PROGRAM, "-z" },
{ ct_gzip, GZIP_PROGRAM, "-z" },
{ ct_bzip2, BZIP2_PROGRAM, "-j" },
{ ct_bzip2, "lbzip2", "-j" },
{ ct_lzip, LZIP_PROGRAM, "--lzip" },
{ ct_lzma, LZMA_PROGRAM, "--lzma" },
{ ct_lzma, XZ_PROGRAM, "-J" },
{ ct_lzop, LZOP_PROGRAM, "--lzop" },
{ ct_xz, XZ_PROGRAM, "-J" },
{ ct_none }
};
static struct zip_program const *
find_zip_program (enum compress_type type, int *pstate)
{
int i;
for (i = *pstate; zip_program[i].type != ct_none; i++)
{
if (zip_program[i].type == type)
{
*pstate = i + 1;
return zip_program + i;
}
}
*pstate = i;
return NULL;
}
const char *
first_decompress_program (int *pstate)
{
struct zip_program const *zp;
if (use_compress_program_option)
return use_compress_program_option;
if (archive_compression_type == ct_none)
return NULL;
*pstate = 0;
zp = find_zip_program (archive_compression_type, pstate);
return zp ? zp->program : NULL;
}
const char *
next_decompress_program (int *pstate)
{
struct zip_program const *zp;
if (use_compress_program_option)
return NULL;
zp = find_zip_program (archive_compression_type, pstate);
return zp ? zp->program : NULL;
}
static const char *
compress_option (enum compress_type type)
{
struct zip_program const *zp;
int i = 0;
zp = find_zip_program (type, &i);
return zp ? zp->option : NULL;
}
/* Check if the file ARCHIVE is a compressed archive. */
static enum compress_type
@@ -395,7 +466,7 @@ open_compressed_archive (void)
break;
default:
use_compress_program_option = compress_program (type);
archive_compression_type = type;
break;
}
}

View File

@@ -440,6 +440,9 @@ void mv_size_left (off_t size);
void buffer_write_global_xheader (void);
const char *first_decompress_program (int *pstate);
const char *next_decompress_program (int *pstate);
/* Module create.c. */
enum dump_status
@@ -550,6 +553,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_stat_info (int typeflag, struct tar_stat_info *stat_info);
char const *tartime (struct timespec t, bool full_time);
#define OFF_FROM_HEADER(where) off_from_header (where, sizeof (where))
@@ -804,10 +808,12 @@ void checkpoint_run (bool do_write);
#define WARN_UNKNOWN_CAST 0x00010000
#define WARN_UNKNOWN_KEYWORD 0x00020000
#define WARN_XDEV 0x00040000
#define WARN_DECOMPRESS_PROGRAM 0x00080000
/* The warnings composing WARN_VERBOSE_WARNINGS are enabled by default
in verbose mode */
#define WARN_VERBOSE_WARNINGS (WARN_RENAME_DIRECTORY|WARN_NEW_DIRECTORY)
#define WARN_VERBOSE_WARNINGS (WARN_RENAME_DIRECTORY|WARN_NEW_DIRECTORY|\
WARN_DECOMPRESS_PROGRAM)
#define WARN_ALL (~WARN_VERBOSE_WARNINGS)
void set_warning_option (const char *arg);

View File

@@ -562,7 +562,8 @@ write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
GNAME_TO_CHARS (tmpname, header->header.gname);
free (tmpname);
strcpy (header->header.magic, OLDGNU_MAGIC);
strcpy (header->buffer + offsetof (struct posix_header, magic),
OLDGNU_MAGIC);
header->header.typeflag = type;
finish_header (st, header, -1);
@@ -899,7 +900,8 @@ start_header (struct tar_stat_info *st)
case OLDGNU_FORMAT:
case GNU_FORMAT: /*FIXME?*/
/* Overwrite header->header.magic and header.version in one blow. */
strcpy (header->header.magic, OLDGNU_MAGIC);
strcpy (header->buffer + offsetof (struct posix_header, magic),
OLDGNU_MAGIC);
break;
case POSIX_FORMAT:

View File

@@ -777,7 +777,7 @@ extract_dir (char *file_name, int typeflag)
for (;;)
{
status = mkdir (file_name, mode);
status = mkdirat (chdir_fd, file_name, mode);
if (status == 0)
{
current_mode = mode & ~ current_umask;
@@ -864,6 +864,20 @@ open_output_file (char const *file_name, int typeflag, mode_t mode,
}
}
/* If O_NOFOLLOW is needed but does not work, check for a symlink
separately. There's a race condition, but that cannot be avoided
on hosts lacking O_NOFOLLOW. */
if (! O_NOFOLLOW && overwriting_old_files && ! dereference_option)
{
struct stat st;
if (fstatat (chdir_fd, file_name, &st, AT_SYMLINK_NOFOLLOW) == 0
&& S_ISLNK (st.st_mode))
{
errno = ELOOP;
return -1;
}
}
fd = openat (chdir_fd, file_name, openflag, mode);
if (0 <= fd)
{
@@ -1191,7 +1205,7 @@ static int
extract_node (char *file_name, int typeflag)
{
bool interdir_made = false;
mode_t mode = (current_stat_info.stat.st_mode & MODE_RWX
mode_t mode = (current_stat_info.stat.st_mode & (MODE_RWX | S_IFBLK | S_IFCHR)
& ~ (0 < same_owner_option ? S_IRWXG | S_IRWXO : 0));
while (mknodat (chdir_fd, file_name, mode, current_stat_info.stat.st_rdev)

View File

@@ -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);
}
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,
&current_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
@@ -572,7 +592,9 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
else
format = USTAR_FORMAT;
}
else if (strcmp (header->header.magic, OLDGNU_MAGIC) == 0)
else if (strcmp (header->buffer + offsetof (struct posix_header, magic),
OLDGNU_MAGIC)
== 0)
format = hbits ? OLDGNU_FORMAT : GNU_FORMAT;
else
format = V7_FORMAT;
@@ -655,23 +677,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

View File

@@ -455,6 +455,29 @@ sys_child_open_for_compress (void)
wait_for_grandchild (grandchild_pid);
}
static void
run_decompress_program (void)
{
int i;
const char *p, *prog = NULL;
for (p = first_decompress_program (&i); p; p = next_decompress_program (&i))
{
if (prog)
{
WARNOPT (WARN_DECOMPRESS_PROGRAM,
(0, errno, _("cannot run %s"), prog));
WARNOPT (WARN_DECOMPRESS_PROGRAM,
(0, 0, _("trying %s"), p));
}
prog = p;
execlp (p, p, "-d", NULL);
}
if (!prog)
FATAL_ERROR ((0, 0, _("unable to run decompression program")));
exec_fatal (prog);
}
/* Set ARCHIVE for uncompressing, then reading an archive. */
pid_t
sys_child_open_for_uncompress (void)
@@ -501,9 +524,7 @@ sys_child_open_for_uncompress (void)
open_fatal (archive_name_array[0]);
xdup2 (archive, STDIN_FILENO);
priv_set_restore_linkdir ();
execlp (use_compress_program_option, use_compress_program_option,
"-d", (char *) 0);
exec_fatal (use_compress_program_option);
run_decompress_program ();
}
/* We do need a grandchild tar. */
@@ -520,9 +541,7 @@ sys_child_open_for_uncompress (void)
xdup2 (child_pipe[PREAD], STDIN_FILENO);
xclose (child_pipe[PWRITE]);
priv_set_restore_linkdir ();
execlp (use_compress_program_option, use_compress_program_option,
"-d", (char *) 0);
exec_fatal (use_compress_program_option);
run_decompress_program ();
}
/* The child tar is still here! */

View File

@@ -130,6 +130,8 @@ update_archive (void)
decode_header (current_header, &current_stat_info,
&current_format, 0);
transform_stat_info (current_header->header.typeflag,
&current_stat_info);
archive_format = current_format;
if (subcommand_option == UPDATE_SUBCOMMAND

View File

@@ -41,6 +41,7 @@ static char const *const warning_args[] = {
"unknown-cast",
"unknown-keyword",
"xdev",
"decompress-program",
NULL
};
@@ -64,7 +65,8 @@ static int warning_types[] = {
WARN_TIMESTAMP,
WARN_UNKNOWN_CAST,
WARN_UNKNOWN_KEYWORD,
WARN_XDEV
WARN_XDEV,
WARN_DECOMPRESS_PROGRAM
};
ARGMATCH_VERIFY (warning_args, warning_types);

View File

@@ -52,6 +52,7 @@ TESTSUITE_AT = \
append.at\
append01.at\
append02.at\
append03.at\
backup01.at\
chtype.at\
comprec.at\
@@ -82,6 +83,8 @@ TESTSUITE_AT = \
extrac13.at\
extrac14.at\
extrac15.at\
extrac16.at\
extrac17.at\
filerem01.at\
filerem02.at\
gzip.at\

43
tests/append03.at Normal file
View File

@@ -0,0 +1,43 @@
# 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([append with name transformation])
AT_KEYWORDS([append append03])
# Description: Make sure filenames are transformed during append.
AT_TAR_CHECK([
genfile --file file.1
genfile --file file.2
tar -c -f archive --transform 's/file/plik/' file.*
echo Appending
tar -r -f archive --transform 's/file/plik/' -v --show-transformed-names file.1
echo Testing
tar tf archive
],
[0],
[Appending
plik.1
Testing
plik.1
plik.2
plik.1
])
AT_CLEANUP

View File

@@ -24,6 +24,7 @@ AT_SETUP([scarce file descriptors])
AT_KEYWORDS([extract extrac11])
AT_TAR_CHECK([
exec </dev/null
dirs='a
a/b
a/b/c
@@ -45,31 +46,37 @@ for dir in $dirs; do
done
done
# Check that "ulimit" itself works.
((ulimit -n 100 &&
tar -cf archive1.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
tar -xf archive1.tar -C dest1 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
) &&
diff -r a dest1/a
# Check that "ulimit" itself works. Close file descriptors before
# invoking ulimit, to work around a bug (or a "feature") in some shells,
# where they squirrel away dups of file descriptors into FD 10 and up
# before closing the originals.
( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
ulimit -n 100 &&
tar -cf archive1.tar a &&
tar -xf archive1.tar -C dest1 a
) &&
diff -r a dest1/a
) >/dev/null 2>&1 ||
AT_SKIP_TEST
# Another test that "ulimit" itself works:
# tar should fail when completely starved of file descriptors.
((ulimit -n 4 &&
tar -cf archive2.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
tar -xf archive2.tar -C dest2 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
) &&
diff -r a dest2/a
( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
ulimit -n 4 &&
tar -cf archive2.tar a &&
tar -xf archive2.tar -C dest2 a
) &&
diff -r a dest2/a
) >/dev/null 2>&1 &&
AT_SKIP_TEST
# Tar should work when there are few, but enough, file descriptors.
((ulimit -n 10 &&
tar -cf archive3.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
tar -xf archive3.tar -C dest3 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
) &&
diff -r a dest3/a >/dev/null 2>&1
( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
ulimit -n 10 &&
tar -cf archive3.tar a &&
tar -xf archive3.tar -C dest3 a
) &&
diff -r a dest3/a >/dev/null 2>&1
) || { diff -r a dest3/a; exit 1; }
],
[0],[],[],[],[],[gnu])

View File

@@ -33,20 +33,20 @@ echo target1 >target1
tar -cf archive.tar -C src . &&
tar -xf archive.tar -C dst1 --warning=no-timestamp &&
diff -c src/file1 dst1/file1 &&
diff -c target1 dst1/target1
diff src/file1 dst1/file1 &&
diff target1 dst1/target1
ln -s target1 dst2/file1
echo target1 >dst2/target1
tar --overwrite -xf archive.tar -C dst2 --warning=no-timestamp &&
diff -c src/file1 dst2/file1 &&
diff -c target1 dst2/target1
diff src/file1 dst2/file1 &&
diff target1 dst2/target1
ln -s target1 dst3/file1
echo target1 >dst3/target1
tar --overwrite -xhf archive.tar -C dst3 --warning=no-timestamp &&
diff -c src/file1 dst3/file1 &&
diff -c src/file1 dst3/target1
diff src/file1 dst3/file1 &&
diff src/file1 dst3/target1
],
[0],[],[],[],[],[gnu])

36
tests/extrac16.at Normal file
View File

@@ -0,0 +1,36 @@
# 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/>.
# written by Paul Eggert from a bug report by Denis Excoffier
# <http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00034.html>
# Check extraction of empty directory with -C.
AT_SETUP([extract empty directory with -C])
AT_KEYWORDS([extract extrac16])
AT_TAR_CHECK([
mkdir src src/a src/a/b dest
touch src/a/c
tar -cf archive.tar -C src a &&
tar -xf archive.tar -C dest
],
[0],[],[],[],[],[gnu])
AT_CLEANUP

46
tests/extrac17.at Normal file
View File

@@ -0,0 +1,46 @@
# 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 --warning=no-timestamp \
dir/subdir1/
],
[0],
[dir/subdir1/file1
])
AT_CLEANUP

View File

@@ -47,14 +47,16 @@ mkdir c
# or
# tar: Child returned status 2
tar -c -f a -z --remove-files b c 2>err
# Discard diagnostics that some shells generate about broken pipes,
# and discard all of tar's diagnostics except for the ones saying "(child)".
# Gzip's exit code is propagated to the shell. Usually it is 141.
# Convert all non-zero exits to 2 to make it predictable.
(tar -c -f a -z --remove-files b c 2>err || (exit 2) ) 2>/dev/null
EC=$?
sed -n '/(child)/p' err >&2
rm err
find . | sort
# Gzip exit code is propagated to the shell. Usually it is
# 141. We convert all non-zero exits to 2 to make it predictable.
test $EC && exit 2
exit $EC
],
[2],
[.

View File

@@ -32,7 +32,8 @@ genfile --length 2049 --file third
tar cf archive first second third
tar tf archive | :
# Discard diagnostics that some shells generate about broken pipes.
(tar tf archive 2>&3 | :) 3>&2 2>/dev/null
],
[0])

View File

@@ -121,6 +121,7 @@ m4_include([verbose.at])
m4_include([append.at])
m4_include([append01.at])
m4_include([append02.at])
m4_include([append03.at])
m4_include([xform-h.at])
m4_include([xform01.at])
@@ -154,6 +155,8 @@ m4_include([extrac12.at])
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])