58 Commits

Author SHA1 Message Date
Sergey Poznyakoff
44cfdfb8b6 Version 1.32 2019-02-23 14:54:53 +02:00
Sergey Poznyakoff
97d8951536 Minor fixes in docs.
* doc/tar.1: Remove description of the --preserve option
Document verbosity levels.
* doc/tar.texi: Fix description of the -o option.
2019-02-04 21:30:00 +02:00
Daniel Le
bf5d66109c Fix typos in the documentation
Short option "t" was mistranslated to "--test" instead of "--list" in commit
67cad0792b.
2019-01-15 15:29:03 +02:00
Sergey Poznyakoff
bd1b0fc97c Fix build on AIX
* src/unlink.c (flush_deferred_unlinks): Avoid possible duplicate case
(if ENOTEMPTY==EEXIST)
2019-01-15 15:21:03 +02:00
Sergey Poznyakoff
a7289daf5c Version 1.31.90 2019-01-15 14:38:02 +02:00
Sergey Poznyakoff
72506bddee Ensure gnu format when running checkpoint tests 2019-01-14 23:32:15 +02:00
Sergey Poznyakoff
a311b908c0 Fix compression tests
Existing compression tests used tar with compiled-in defaults. However,
some of the defaults are sure to create archives that are not byte-to-byte
reproducible (e.g. DEFAULT_ARCHIVE_FORMAT=POSIX, because the name field
in posix extended headers uses PID of the creating process by default).
Moreover, some compressors (e.g. gzip) store current timestamp in
the file header when compressing from stdin, so that using cmp on the
two created archives as the tests did is error-prone. Another problem
is that the tests implicitly assumed that tar uses archive suffix to
recognize its format when extracting, which isn't the case. Finally,
there's hardly any reason in using sed to create m4 sources, when
everything can be achieved by m4 itself.

* tests/Makefile.am: Remove generation of compress-*.at files.
* tests/compress.at.in: Remove.
* tests/compress.m4: New file.
* tests/testsuite.at: Include compress.m4, use TAR_CHECK_COMPRESS to
check compression options.
2019-01-14 18:55:43 +02:00
Sergey Poznyakoff
cb07844454 Fix possible NULL dereference (savannah bug #55369)
* src/sparse.c (pax_decode_header): Check return from find_next_block.
2019-01-14 15:22:09 +02:00
Sergey Poznyakoff
2f5a57be4b Fix compilation without iconv. 2019-01-14 14:46:43 +02:00
Sergey Poznyakoff
3da8c2850d Fix iconv usage.
Patch by Christian Weisgerber.

* src/utf8.c (utf8_convert): non-zero return from iconv means failure.
2019-01-14 13:59:39 +02:00
Pavel Raiskup
c697d62598 tests: fix numeric.at for BSD
While creating file, BSD kernels inherit the group ownership from
parent directory.
http://lists.gnu.org/archive/html/bug-tar/2016-06/msg00000.html

* tests/numeric.at: Attempt to 'chown' the newly created directory
to proper group (at least on affected machines that command is
expected to succeed).
2019-01-14 12:54:29 +02:00
Sergey Poznyakoff
b0930da045 Fix typo in manpage. 2019-01-14 12:48:16 +02:00
Sergey Poznyakoff
f86722c34c Fix expected output in dirrem tests.
In both tests, the "file changed as we read it" warning might be
produced for dir/sub, depending on the ctime resolution and timing.
The problem was fixed by 64b43fdf70, but regressed
after e7cd377f78, which removed 1 second
delays between each pair of checkpoints. Since the presense or absense
of this warning is irrelevant for the test, it is now suppressed.

* tests/dirrem01.at: Suppress the file-changed warning.
* tests/dirrem02.at: Likewise.
2019-01-14 12:26:59 +02:00
Sergey Poznyakoff
aa0684ce90 Fix the use of --checkpoint without explicit --checkpoint-action
* src/checkpoint.c (checkpoint_finish_compile): Set default action,
if necessary.
* tests/checkpoint/defaults.at: New testcase.
* tests/checkpoint/dot-compat.at: New testcase.
* tests/checkpoint/dot-int.at: New testcase.
* tests/checkpoint/dot.at: New testcase.
* tests/checkpoint/interval.at: New testcase.
* tests/Makefile.am: Add new testcases.
* tests/testsuite.at Include new testcases.
2019-01-12 10:24:47 +02:00
Sergey Poznyakoff
85c005ee13 Remove erroneous abort() call
The call was introduced by commit ccef8581. It caused tar to abort
on perfectly normal operations, like untarring archives containing
./ with the -U option,

See http://lists.gnu.org/archive/html/bug-tar/2019-01/msg00019.html
for details.

* src/extract.c (maybe_recoverable): Remove misplaced call to abort().
2019-01-10 18:18:49 +02:00
Sergey Poznyakoff
2684c88a49 Version 1.31 2019-01-02 20:20:28 +02:00
Sergey Poznyakoff
1ed62596cf Fix the difflink test
Hardlinking a symlink produces hardlink on BSD and symlink
on GNU/Linux. Avoid the ambiguity.

* tests/difflink.at: Create hard link from a regular file.
2018-12-28 17:53:35 +02:00
Sergey Poznyakoff
9d1993f651 Work over a bug in gnulib error()
The error() function from glibc correctly prefixes each message it
prints with program_name as set by set_program_name. However, its
replacement from gnulib, which is linked in on systems where this
function is not available, prints the name returned by getprogname()
instead. Due to this messages output by tar subprocess (which sets its
program name to 'tar (child)') become indiscernible from those printed
by the main process. In particular, this breaks the remfiles01.at and
remfiles02.at test cases.

* configure.ac: Define ENABLE_ERROR_PRINT_PROGNAME if using
gnulib error().
* src/tar.c [ENABLE_ERROR_PRINT_PROGNAME] (tar_print_progname): New function.
(main) [ENABLE_ERROR_PRINT_PROGNAME]: Set error_print_progname.
2018-12-28 17:49:08 +02:00
Sergey Poznyakoff
e7cd377f78 Implement the "wait" checkpoint action.
This action instructs tar to pause until given signal is delivered.
The newer genfile tool uses this action for communication between
genfile and tar in exec mode. This eliminates race conitions and
speeds up the tests based on exec mode.

* doc/tar.texi: Document changes.
* paxutils: Upgrade.
* src/checkpoint.c: Implement the wait action.
* src/common.h (decode_signal): New proto.
* src/tar.c (decode_signal): New function.
(set_stat_signal): Rewrite.
* tests/dirrem01.at: Adjust genfile and tar command line arguments
to use the new feature.
* tests/dirrem02.at: Likewise.
* tests/filerem01.at: Likewise.
* tests/filerem02.at: Likewise.
* tests/grow.at: Likewise.
* tests/sptrcreat.at: Likewise.
* tests/sptrdiff00.at: Likewise.
* tests/sptrdiff01.at: Likewise.
* tests/truncate.at: Likewise.
2018-12-28 13:27:02 +02:00
Sergey Poznyakoff
c15c42ccd1 Fix CVE-2018-20482
* NEWS: Update.
* src/sparse.c (sparse_dump_region): Handle short read condition.
(sparse_extract_region,check_data_region): Fix dumped_size calculation.
Handle short read condition.
(pax_decode_header): Fix dumped_size calculation.
* tests/Makefile.am: Add new testcases.
* tests/testsuite.at: Likewise.

* tests/sptrcreat.at: New file.
* tests/sptrdiff00.at: New file.
* tests/sptrdiff01.at: New file.
2018-12-27 17:53:38 +02:00
Sergey Poznyakoff
3c2a2cd94d Disallow modifications to the global pax extended header in update mode.
Updating global headers in update mode is not possible, because:

1) If the original archive was not in PAX format, writing the
global header would overwrite first member header (and eventually
data blocks) in the archive.
2) Otherwise, using the --pax-option can make the updated header
occupy more blocks than the original one, which would lead to the
same effect as in 1.

This also fixes
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00007.html

* src/xheader.c (xheader_forbid_global): New function.
* src/common.h (xheader_forbid_global): New prototype.
* src/update.c (update_archive): Use xheader_forbid_global, instead
of trying to write global extended header record.
2018-12-21 14:39:49 +02:00
Sergey Poznyakoff
ea3aea06f1 Bugfix
Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00014.html

* src/names.c (collect_and_sort_names): Fix iteration over namelist.
2018-12-21 13:54:12 +02:00
Sergey Poznyakoff
983a82a376 Fix semantics of -K used together with explicit member names.
This also fixes the bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00012.html

* src/common.h (starting_file_option): Describe the variable.
* src/names.c (add_starting_file): New function.
(name_match): Ignore everything before the member indicated by the
--starting-file option
* src/tar.c: Use add_starting_file to handle the -K option.
2018-12-21 13:54:11 +02:00
Sergey Poznyakoff
916fe62ae9 Fix error handling when reading incremental snapshots
Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00008.html

* incremen.c (read_incr_db_01): Don't try to continue after errors.
2018-12-21 13:54:11 +02:00
Sergey Poznyakoff
99d415e190 Reject pax options starting with equals sign
Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00010.html

* xheader.c (xheader_set_keyword_equal): Bail out if the keyword starts
with =
2018-12-21 13:54:11 +02:00
Sergey Poznyakoff
c7c59b57fa Fix buffer overflow
Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00011.html

* src/xheader.c (xheader_format_name): fix length calculation
2018-12-21 13:54:11 +02:00
Sergey Poznyakoff
eae48289c0 Fix improper memory access
Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00009.html

* src/transform.c (parse_transform_expr): Check if re is not empty
before accessing its last byte.
2018-12-21 13:54:11 +02:00
Sergey Poznyakoff
62c0c3a780 Fix parsing of ACLs
Text returned by acl_to_text can contain comments (introduced by #).
Strip comments and horizontal tabs prior to storing ACLs in PAX
headers.

* src/xattrs.c (xattrs_acls_cleanup): New function.
(xattrs__acls_get_a,xattrs__acls_get_d): Use xattrs_acls_cleanup.
2018-11-24 22:10:53 +02:00
Sergey Poznyakoff
ba472050da Don't try to read past the end of header string fields
* src/common.h (assign_string_n): New proto.
(ASSIGN_STRING_N): New macro.
* src/misc.c (assign_string_n): New function.
* gnulib.modules: Add strnlen.
* src/buffer.c: Use assign_string_n where appropriate.
* src/list.c: Likewise.
2018-11-24 17:57:32 +02:00
Sergey Poznyakoff
f6e2860e8a Fix verbose ACL listing
* src/xattrs.c (acls_one_line): Advance pos.
(xattrs_print): Insert a comma between ACL and default ACL if both
are non-empty.
2018-11-12 09:17:25 +02:00
Paul Eggert
2777a2bfd9 tar: fix numbered backup bug
* src/misc.c (maybe_backup_file): Pass chdir_fd, not AT_FDCWD,
to find_backup_file_name.  This fixes a bug whereby the wrong
backup file name was chosen for numbered backups.
2018-10-28 16:24:05 -07:00
Paul Eggert
9fc1cb40f9 * src/tar.c (expand_pax_option): Pacify recent GCC. 2018-10-28 16:08:59 -07:00
Paul Eggert
6238296458 build: update gnulib submodule to latest
* src/misc.c (maybe_backup_file): Adjust to Gnulib change.
2018-10-28 16:08:59 -07:00
Sergey Poznyakoff
9042dfc4b1 Minor fixes in wordsplit.c 2018-08-02 16:36:48 +03:00
Paul Eggert
016d6d27d1 build: update gnulib submodule to latest 2018-08-02 00:12:46 -07:00
Sergey Poznyakoff
e54741745c Silence gcc warnings in wordsplit 2018-07-31 16:05:28 +03:00
Sergey Poznyakoff
110e3bd7a6 Fix double-free introduced by 577dc345
* src/utf8.c (utf8_convert): Don't store freed value in *output
2018-07-31 15:57:11 +03:00
Pavel Raiskup
c1b569d9d6 Report race on systems without O_DIRECTORY
* src/names.c (collect_and_sort_names): Report ENOTDIR after
successful fstat() but !S_ISDIR.
2018-07-31 12:13:48 +03:00
Pavel Raiskup
577dc34565 Avoid some resource leaks
* src/incremen.c (store_rename): Free temp_name, leaked before for
each renamed directory with --listed-incremental.
* src/transform.c (add_literal_segment): Tighten arguments by
const.
(parse_transform_expr): Free 'str', leaked storage for each
--transform option before.
* src/utf8.c (utf8_convert): Deallocate buffer for failed iconv()
call so callers don't have to.
2018-07-31 12:06:09 +03:00
Sergey Poznyakoff
c7b3f0217f Sync wordsplit and paxutils with the most recent versions 2018-07-31 11:56:44 +03:00
Paul Eggert
e81c89ddd6 * doc/tar.1: Fix font typo noted by esr. 2018-06-13 15:07:32 -07:00
Paul Eggert
07b0026e5d * doc/tar.1: Don't refer to nonexistent tar(5). 2018-05-16 09:03:47 -07:00
Jim Meyering
b531801d6f --one-top-level: avoid a heap-buffer-overflow
* NEWS: Mention this.
* src/suffix.c (strip_compression_suffix): Fix string comparison guard.
Without this change, some ASAN-enabled test runs would fail with the
following.  Also, strip an additional .tar suffix only if the just-
stripped suffix did not match /^\.t/".

==30815==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000002ed at pc 0x00000049d1f4 bp 0x7ffeb5906d50 sp 0x7ffeb5906500
READ of size 1 at 0x6020000002ed thread T0
SCARINESS: 12 (1-byte-read-heap-buffer-overflow)
    #0 0x49d1f3 in __interceptor_strncmp /j/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:407
    #1 0x5670f3 in strip_compression_suffix /j/tar/src/suffix.c:107
    #2 0x575788 in decode_options /j/tar/src/tar.c:2545
    #3 0x5760c0 in main /j/tar/src/tar.c:2708
    #4 0x7f105090df29 in __libc_start_main ../csu/libc-start.c:308
    #5 0x408629 in _start (/j/tar/src/tar+0x408629)

0x6020000002ed is located 3 bytes to the left of 6-byte region [0x6020000002f0,0x6020000002f6)
allocated by thread T0 here:
    #0 0x4d0710 in __interceptor_malloc /j/gcc/libsanitizer/asan/asan_malloc_linux.cc:86
    #1 0x4908ad in __interceptor_strndup /j/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:326
    #2 0x5cbcbd in xstrndup /j/tar/gnu/xstrndup.c:32
    #3 0x5a325b in base_name /j/tar/gnu/basename.c:57
    #4 0x575772 in decode_options /j/tar/src/tar.c:2544
    #5 0x5760c0 in main /j/tar/src/tar.c:2708
    #6 0x7f105090df29 in __libc_start_main ../csu/libc-start.c:308
2018-04-13 11:05:01 +03:00
Andrew Hounsell
f563b896cc Tiny fix
* doc/snapshot.texi: Fix a typo
* scripts/tar-snapshot-edit: Fix a typo
2018-04-07 11:07:57 +03:00
Jim Meyering
c90c6fee01 tests: avoid test failure with non-ancient autoconf
Running "make check" would fail with this:
  T-nonl.at:30: error: m4_divert_push: cannot change diversion
  to `GROW' inside m4_expand
* tests/T-nonl.at: Use printf in place of AS_ECHO_N.
These days, printf should work for everyone.
2018-04-07 10:58:00 +03:00
Jim Meyering
0a0242582f maint: avoid -Wstringop-truncation warnings from upcoming GCC8
* src/create.c (start_private_header, start_header): Convert
trivial uses of strncpy to memcpy, to avoid warnings like this:
In function 'strncpy',
    inlined from 'start_private_header' at create.c:522:3:
/usr/include/bits/string_fortified.h:106:10: warning: \
  '__builtin_strncpy' output truncated before terminating nul \
  copying 2 bytes from a string of the same length \
  [-Wstringop-truncation]
2018-04-07 10:38:31 +03:00
Jim Meyering
2baa531ce5 maint: avoid -Wstringop-truncation warnings upcoming GCC8
* src/buffer.c (gnu_add_multi_volume_header): Convert a use of
strncpy to memcpy, to avoid this warning:
In function 'strncpy',
    inlined from 'gnu_add_multi_volume_header' at buffer.c:1782:3,
    ...
/usr/include/bits/string_fortified.h:106:10: error: '__builtin_strncpy'\
   specified bound 100 equals destination size \
   [-Werror=stringop-truncation]
2018-04-07 10:37:16 +03:00
Jim Meyering
ccef8581b8 maint: avoid warnings from upcoming GCC8
* src/transform.c (_single_transform_name_to_obstack): Mark with
FALLTHROUGH statement rather than /* FALL THROUGH */ comment.
Only the former works with gcc-8.
* src/extract.c (maybe_recoverable): Call abort to tell gcc-8 that
this code is unreachable.
2018-04-07 10:36:23 +03:00
Sergey Poznyakoff
2d00d8b321 Rewrite struct tm formatting
* src/list.c (tartime): Use strftime instead of manually formatting
fields of the struct tm. This should also suppress some gcc warnings.
2018-04-07 10:33:27 +03:00
Jim Meyering
e8c3f4860d tests: add coverage for new --zstd and all other compression tools
* tests/compress.at.in: New file: template from which each
per-compression-tool test is derived.
* tests/Makefile.am (TESTSUITE_AT): Add it.
(EXTRA_DIST): Add compress.at.in.
(compress-*.at): New rules to generate a file/tests for each compression tool.
* tests/testsuite.at (Compression): Add each of these generated
files in a new section.
* tests/.gitignore: Ignore the new generated files.
2018-04-07 10:32:38 +03:00
Aaron Schrab
00f03498a9 Fix typo 2018-03-18 12:06:36 +02:00
Sergey Poznyakoff
688924d2a8 Version 1.30.90
* NEWS: Update.
* configure.ac: Update.
* THANKS: Add Adam Borowski.
2018-03-18 10:38:16 +02:00
Adam Borowski
3d45373d3b Add support for zstd compression
* configure.ac (zstd): Register compression program.
* doc/tar.1: Mention --zstd.
* doc/tar.texi: Document zstd support.
* src/buffer.c: Register zstd compression.
* src/suffix.c: Add suffixes zst and tzst.
* src/tar.c: New compression option --zstd.
2018-03-18 10:24:13 +02:00
Pavel Raiskup
64b43fdf70 tests: fix race in dirrem01 and dirrem02
Previously the '--checkpoint-action=echo' was triggered after
'--checkpoint-action=sleep=1' - so the order of events *usually*
was (for --format='gnu'):

  ...
  1. checkpoint handler before write of 'dir/sub' member
  2. one-second delay
  3. stderr write: 'tar: Write checkpoint 3'
  4. write the member 'dir/sub' into the archive
  5. check that the member's ctime has not been changed
  6. genfile's detecting 'Write checkpoint', doing unlink
  ...

But sometimes, the genfile was fast enough to win the race and
unlinked the directory before the member was written into the
archive (IOW, the order was 1-2-3-6-4-5).  This led to the
occasional warning 'tar: dir/sub: file changed as we read it'.

Swap the order of 'sleep=1' and 'echo' actions so the genfile
utility has (hopefully) enough time to do the unlink before
writing the file into the archive (enforce 1-2-3-6-4-5 order).

* tests/dirrem01.at: Swap 'sleep=1' and 'echo' actions.
* tests/dirrem02.at: Likewise.
2018-03-18 08:33:03 +02:00
Sergey Poznyakoff
7b8efcc7cb Fix typos in the docs 2018-03-13 22:20:53 +02:00
Sergey Poznyakoff
c13401c0a7 Provide a way to skip tests that create very large files
Define environment variable TARTEST_SKIP_LARGE_FILES=1 in order
to skip tests that require lots of disk space.

* tests/testsuite.at (AT_SKIP_LARGE_FILES): New macro.
* tests/sparse03.at: Mark test with AT_SKIP_LARGE_FILES.
* tests/sparse05.at: Likewise.
* tests/star/pax-big-10g.at: Likewise.
* tests/star/ustar-big-2g.at: Likewise.
* tests/star/ustar-big-8g.at: Likewise.
2018-03-13 21:58:37 +02:00
Sergey Poznyakoff
847a36f064 Testsuite bugfix
* tests/difflink.at: Define order of files within tested archive.
2018-03-13 09:59:11 +02:00
Sergey Poznyakoff
2b7fc4aee9 testsuite: account for absolute file names starting with double slash
* tests/incr08.at: Absolute file names can start with //
* tests/xform03.at: Likewise.
2018-03-13 08:08:44 +02:00
314 changed files with 2799 additions and 1114 deletions

2
.gitignore vendored
View File

@@ -8,6 +8,7 @@
.deps
.emacs*
.libs
.gdbinit
ABOUT-NLS
ChangeLog
INSTALL
@@ -28,3 +29,4 @@ libtool
m4
rmt
stamp-h1
TAGS

View File

@@ -1,7 +1,6 @@
# Main Makefile for GNU tar.
# Copyright 1994-1997, 1999-2001, 2003, 2007, 2009, 2013-2014, 2016-2017
# Free Software Foundation, Inc.
# Copyright 1994-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

52
NEWS
View File

@@ -1,6 +1,52 @@
GNU tar NEWS - User visible changes. 2017-12-17
GNU tar NEWS - User visible changes. 2019-02-23
Please send GNU tar bug reports to <bug-tar@gnu.org>
version 1.32 - Sergey Poznyakoff, 2019-02-23
* Fix the use of --checkpoint without explicit --checkpoint-action
* Fix extraction with the -U option
See http://lists.gnu.org/archive/html/bug-tar/2019-01/msg00015.html,
for details
* Fix iconv usage on BSD-based systems
* Fix possible NULL dereference (savannah bug #55369)
* Improve the testsuite
version 1.31 - Sergey Poznyakoff, 2019-01-02
* Fix heap-buffer-overrun with --one-top-level.
Bug introduced with the addition of that option in 1.28.
* Support for zstd compression
New option '--zstd' instructs tar to use zstd as compression program.
When listing, extractng and comparing, zstd compressed archives are
recognized automatically.
When '-a' option is in effect, zstd compression is selected if the
destination archive name ends in '.zst' or '.tzst'.
* The -K option interacts properly with member names given in the command line
Names of members to extract can be specified along with the "-K NAME"
option. In this case, tar will extract NAME and those of named members
that appear in the archive after it, which is consistent with the
semantics of the option.
Previous versions of tar extracted NAME, those of named members that
appeared before it, and everything after it.
* Fix CVE-2018-20482
When creating archives with the --sparse option, previous versions of
tar would loop endlessly if a sparse file had been truncated while
being archived.
version 1.30 - Sergey Poznyakoff, 2017-12-17
@@ -42,7 +88,7 @@ causing subsequent link extractions in that directory to fail.
This new warning control option suppresses warning messages about
unreadable files and directories. It has effect only if used together
with the --ignore-failed-read option.
with the --ignore-failed-read option.
* The --warnings=none option now suppresses all warnings
@@ -1641,7 +1687,7 @@ Versions 1.07 back to 1.00 by Jay Fenlason.
Copyright 1994-2001, 2003-2010, 2013-2017 Free Software Foundation, Inc.
Copyright 1994-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

3
README
View File

@@ -221,8 +221,7 @@ and share your findings by writing to <bug-tar@gnu.org>.
* Copying
Copyright 1990-1992, 1994, 1997-2001, 2003-2004, 2007, 2012-2014,
2016-2017 Free Software Foundation, Inc.
Copyright 1990-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -35,8 +35,7 @@ behavior. Run 'bootstrap --help' for a list.
Copyright 2001, 2003-2005, 2007, 2013-2017 Free Software Foundation,
Inc.
Copyright 2001-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -39,7 +39,7 @@ See 'bootstrap --help' for a detailed list.
* Copyright information
Copyright 2007-2009, 2013-2017 Free Software Foundation, Inc.
Copyright 2007-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

2
THANKS
View File

@@ -8,6 +8,7 @@ list of these people. Help me keep it complete and exempt of errors.
See various ChangeLogs for a detailed description of contributions.
Aage Robeck aagero@ifi.uio.no
Adam Borowski kilobyte@angband.pl
Adye, TJ (Tim) T.J.Adye@rl.ac.uk
Akiko Matsushita matusita@sra.co.jp
Alan Bawden Alan@lcs.mit.edu
@@ -94,6 +95,7 @@ Christian Laubscher christian.laubscher@tiscalinet.ch
Christian T. Dum ctd@mpe-garching.mpg.de
Christian von Roques roques@pond.sub.org
Christian Wetzel wetzel@phoenix-pacs.de
Christian Weisgerber naddy@mips.inka.de
Christoph Litauer litauer@mailhost.uni-koblenz.de
Christophe Colle colle@krtkg1.rug.ac.be
Christophe Kalt Christophe.Kalt@kbcfp.com

3
TODO
View File

@@ -45,8 +45,7 @@ Suggestions for improving GNU tar.
* Copyright notice
Copyright 2003-2004, 2007, 2013-2014, 2016-2017 Free Software
Foundation, Inc.
Copyright 2003-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,6 +1,6 @@
dnl Special Autoconf macros for GNU tar -*- autoconf -*-
dnl Copyright 2009, 2013-2014, 2016-2017 Free Software Foundation, Inc.
dnl Copyright 2009-2019 Free Software Foundation, Inc.
dnl
dnl This file is part of GNU tar.
dnl

View File

@@ -4,7 +4,7 @@ scriptversion=2015-08-24.08; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2019 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

View File

@@ -1,7 +1,6 @@
# Bootstrap configuration for GNU tar.
# Copyright 2006-2009, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2006-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,6 +1,6 @@
# Configure template for GNU tar. -*- autoconf -*-
# Copyright 1991, 1994-2010, 2013-2017 Free Software Foundation, Inc.
# Copyright 1991, 1994-2010, 2013-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_INIT([GNU tar], [1.30], [bug-tar@gnu.org])
AC_INIT([GNU tar], [1.32], [bug-tar@gnu.org])
AC_CONFIG_SRCDIR([src/tar.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
@@ -102,6 +102,18 @@ gt_TYPE_SSIZE_T
# gnulib modules
gl_INIT
if test $ac_cv_lib_error_at_line = no; then
# This means that the error() function is not present in libc, so
# the one from gnulib will be used instead. This function precedes
# error messages it prints with the program name as returned by getprogname()
# call, instead of using the name set by set_program_name.
# Install workaround.
AC_DEFINE([ENABLE_ERROR_PRINT_PROGNAME],[1],
[Enable the use of error_print_progname to print program name with error messages.
See comment to function tar_print_progname in src/tar.c])
fi
# paxutils modules
tar_PAXUTILS
@@ -250,6 +262,7 @@ TAR_COMPR_PROGRAM(lzip)
TAR_COMPR_PROGRAM(lzma)
TAR_COMPR_PROGRAM(lzop)
TAR_COMPR_PROGRAM(xz)
TAR_COMPR_PROGRAM(zstd)
AC_MSG_CHECKING(for default archive format)

View File

@@ -1,5 +1,5 @@
%%comments:
Copyright 2004, 2013-2014 Free Software Foundation, Inc.
Copyright 2004-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

1
doc/.gitignore vendored
View File

@@ -24,3 +24,4 @@ tar.tp
tar.vr
version.texi
/parse-datetime.texi
/rmt.8

View File

@@ -1,7 +1,6 @@
# Makefile for GNU tar documentation.
# Copyright 1994-1997, 1999-2001, 2003, 2006-2007, 2013-2014, 2016-2017
# Free Software Foundation, Inc.
# Copyright 1994-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,6 +1,5 @@
@c This is part of the paxutils manual.
@c Copyright (C) 2006-2007, 2014, 2016-2017 Free Software Foundation,
@c Inc.
@c Copyright (C) 2006-2019 Free Software Foundation, Inc.
@c Written by Sergey Poznyakoff
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.

View File

@@ -5,8 +5,7 @@
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000-2002, 2007-2008, 2014, 2016-2017 Free
Software Foundation, Inc.
Copyright @copyright{} 2000-2019 Free Software Foundation, Inc.
@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies

View File

@@ -106,7 +106,7 @@ Please send broken links and other corrections (or suggestions) to
</p>
<p>
Copyright 2004, 2013-2014, 2016-2017 Free Software Foundation, Inc.,
Copyright 2004-2019 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02111, USA
<br />
Verbatim copying and distribution of this entire article is

View File

@@ -1,5 +1,5 @@
@c This is part of the paxutils manual.
@c Copyright (C) 2006, 2014, 2016-2017 Free Software Foundation, Inc.
@c Copyright (C) 2006-2019 Free Software Foundation, Inc.
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.

View File

@@ -1,7 +1,6 @@
;;; mastermenu.el --- Redefinition of texinfo-master-menu-list
;; Copyright 2006-2007, 2013-2014, 2016-2017 Free Software Foundation,
;; Inc.
;; Copyright 2006-2019 Free Software Foundation, Inc.
;; Author: Sergey Poznyakoff
;; Maintainer: bug-tar@gnu.org

View File

@@ -1,5 +1,5 @@
@c This is part of the GNU tar manual.
@c Copyright (C) 2017 Free Software Foundation, Inc.
@c Copyright (C) 2017-2019 Free Software Foundation, Inc.
@c This file is distributed under GFDL 1.3 or any later version
@c published by the Free Software Foundation.

View File

@@ -1,6 +1,5 @@
@c This is part of GNU tar manual.
@c Copyright 1992, 1994-1997, 1999-2004, 2006, 2013-2014, 2016-2017 Free
@c Software Foundation, Inc.
@c Copyright 1992-2019 Free Software Foundation, Inc.
@c See file tar.texi for copying conditions.
@c This file contains support for 'renditions' by Fran@,{c}ois Pinard

View File

@@ -1,6 +1,5 @@
@c This is part of the paxutils manual.
@c Copyright (C) 2005, 2007, 2014, 2016-2017 Free Software Foundation,
@c Inc.
@c Copyright (C) 2005-2019 Free Software Foundation, Inc.
@c Written by Sergey Poznyakoff
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.
@@ -147,7 +146,7 @@ is compiled. To see the specific ranges allowed for a particular
@option{--show-snapshot-field-ranges} option:
@smallexample
$ @kbd{tar --show-shapshot-field-ranges}
$ @kbd{tar --show-snapshot-field-ranges}
This tar's snapshot file field ranges are
(field name => [ min, max ]):

View File

@@ -1,5 +1,5 @@
@c This is part of the paxutils manual.
@c Copyright (C) 2006, 2014, 2016-2017 Free Software Foundation, Inc.
@c Copyright (C) 2006-2019 Free Software Foundation, Inc.
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.
@@ -218,12 +218,12 @@ The real name of the sparse file is stored in the variable
variable @code{GNU.sparse.realsize}.
The sparse map itself is stored in the file data block, preceding the actual
file data. It consists of a series of octal numbers of arbitrary length, delimited
file data. It consists of a series of decimal numbers delimited
by newlines. The map is padded with nulls to the nearest block boundary.
The first number gives the number of entries in the map. Following are map entries,
each one consisting of two numbers giving the offset and size of the
data block it describes.
The first number gives the number of entries in the map. Following are
map entries, each one consisting of two numbers giving the offset and
size of the data block it describes.
The format is designed in such a way that non-posix aware @command{tar}s and @command{tar}s not
supporting @code{GNU.sparse.*} keywords will extract each sparse file

View File

@@ -1,5 +1,5 @@
@c This is part of the paxutils manual.
@c Copyright (C) 2007, 2014, 2016-2017 Free Software Foundation, Inc.
@c Copyright (C) 2007-2019 Free Software Foundation, Inc.
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.

View File

@@ -1,5 +1,5 @@
.\" This file is part of GNU tar. -*- nroff -*-
.\" Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
.\" Copyright 2013-2019 Free Software Foundation, Inc.
.\"
.\" 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
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.TH TAR 1 "November 16, 2017" "TAR" "GNU TAR Manual"
.TH TAR 1 "February 4, 2019" "TAR" "GNU TAR Manual"
.SH NAME
tar \- an archiving utility
.SH SYNOPSIS
@@ -111,7 +111,7 @@ into the archive file
verbosely listing the files being archived:
.PP
.EX
.B tar cfv a.tar /etc
.B tar cfv etc.tar /etc
.EE
.PP
In
@@ -133,9 +133,9 @@ The example command above written in the
could look like:
.PP
.EX
.B tar -cvf a.tar /etc
.B tar -cvf etc.tar /etc
or
.B tar -c -v -f a.tar /etc
.B tar -c -v -f etc.tar /etc
.EE
.PP
In
@@ -152,11 +152,11 @@ method.
Here are several ways of writing the example command in this style:
.PP
.EX
.B tar --create --file a.tar --verbose /etc
.B tar --create --file etc.tar --verbose /etc
.EE
or (abbreviating some options):
.EX
.B tar --cre --file=a.tar --verb /etc
.B tar --cre --file=etc.tar --verb /etc
.EE
.PP
The options in all three styles can be intermixed, although doing so
@@ -256,7 +256,7 @@ exist when creating an archive, it will be created and all files will
be added to the resulting archive (the \fBlevel 0\fR dump). To create
incremental archives of non-zero level \fBN\fR, create a copy of the
snapshot file created during the level \fBN-1\fR, and use it as
\fIFILE\fR.
\fIFILE\fR.
When listing or extracting, the actual contents of \fIFILE\fR is not
inspected, it is needed only due to syntactical requirements. It is
@@ -287,7 +287,7 @@ effect only if the archive is open for reading (e.g. with
.B \-\-list
or
.B \-\-extract
options).
options).
.TP
\fB\-\-no\-check\-device\fR
Do not check device numbers when creating incremental archives.
@@ -383,7 +383,7 @@ Extract files to standard output.
Pipe extracted files to \fICOMMAND\fR. The argument is the pathname
of an external program, optionally with command line arguments. The
program will be invoked and the contents of the file being extracted
supplied to it on its standard output. Additional data will be
supplied to it on its standard input. Additional data will be
supplied via the following environment variables:
.RS
.TP
@@ -465,7 +465,7 @@ Format of the archive being processed. One of:
.BR v7 .
.B TAR_SUBCOMMAND
A short option (with a leading dash) describing the operation \fBtar\fR is
executing.
executing.
.RE
.SS Handling of file attributes
.TP
@@ -562,9 +562,6 @@ stored in archive with owner name \fINEWUSR\fR and UID \fINEWUID\fR.
\fB\-p\fR, \fB\-\-preserve\-permissions\fR, \fB\-\-same\-permissions\fR
extract information about file permissions (default for superuser)
.TP
\fB\-\-preserve\fR
Same as both \fB\-p\fR and \fB\-s\fR.
.TP
\fB\-\-same\-owner\fR
Try extracting files with the same ownership as exists in the archive
(default for superuser).
@@ -694,7 +691,7 @@ executing.
.B TAR_FD
File descriptor which can be used to communicate the new volume name
to
.BR tar .
.BR tar .
.RE
.RS
@@ -732,7 +729,7 @@ When this option is used in conjunction with
.BR \-\-multi\-volume ,
.B tar
will keep track of which volume of a multi-volume archive it is
working in \fIFILE\fR.
working in \fIFILE\fR.
.SS Device blocking
.TP
\fB\-b\fR, \fB\-\-blocking\-factor\fR=\fIBLOCKS\fR
@@ -740,7 +737,7 @@ Set record size to \fIBLOCKS\fRx\fB512\fR bytes.
.TP
\fB\-B\fR, \fB\-\-read\-full\-records\fR
When listing or extracting, accept incomplete input records after
end-of-file marker.
end-of-file marker.
.TP
\fB\-i\fR, \fB\-\-ignore\-zeros\fR
Ignore zeroed blocks in archive. Normally two consecutive 512-blocks
@@ -831,6 +828,10 @@ Filter the archive through
\fB\-Z\fR, \fB\-\-compress\fR, \fB\-\-uncompress\fR
Filter the archive through
.BR compress (1).
.TP
\fB\-\-zstd\fR
Filter the archive through
.BR zstd (1).
.SS Local file selection
.TP
\fB\-\-add\-file\fR=\fIFILE\fR
@@ -1102,7 +1103,7 @@ Show file or archive names after transformation by \fB\-\-strip\fR and
Print total bytes after processing the archive. If \fISIGNAL\fR is
given, print total bytes when this signal is delivered. Allowed
signals are:
.BR SIGHUP ,
.BR SIGHUP ,
.BR SIGQUIT ,
.BR SIGINT ,
.BR SIGUSR1 ", and"
@@ -1113,7 +1114,11 @@ The \fBSIG\fR prefix can be omitted.
Print file modification times in UTC.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Verbosely list files processed.
Verbosely list files processed. Each instance of this option on the
command line increases the verbosity level by one. The maximum
verbosity level is 3. For a detailed discussion of how various
verbosity levels affect tar's output, please refer to \fBGNU Tar
Manual\fR, subsection 2.5.1 "\fBThe \-\-verbose Option\fR".
.TP
\fB\-\-warning\fR=\fIKEYWORD\fR
Enable or disable warning messages identified by \fIKEYWORD\fR. The
@@ -1205,7 +1210,7 @@ default (unless \fB\-\-verbose\fR is used). A common example of what
you can get when using this warning is:
.EX
$ \fBtar --warning=decompress-program -x -f archive.Z
$ tar --warning=decompress-program -x -f archive.Z
tar (child): cannot run compress: No such file or directory
tar (child): trying gzip
.EE
@@ -1296,8 +1301,8 @@ failure during backup to a remote device.
.BR lzop (1),
.BR rmt (8),
.BR symlink (7),
.BR tar (5),
.BR xz (1).
.BR xz (1),
.BR zstd (1).
.PP
Complete \fBtar\fR manual: run
.B info tar
@@ -1328,4 +1333,3 @@ There is NO WARRANTY, to the extent permitted by law.
.\" time-stamp-end: "\""
.\" time-stamp-line-limit: 20
.\" end:

View File

@@ -1464,7 +1464,7 @@ tar: Removing leading '/' from member names
/home/myself/practice/folk
/home/myself/practice/jazz
/home/myself/practice/collection.tar
$ @kbd{tar --test --file practice.tar}
$ @kbd{tar --list --file practice.tar}
home/myself/practice/
home/myself/practice/blues
home/myself/practice/folk
@@ -1495,7 +1495,7 @@ home/myself/practice/blues
home/myself/practice/folk
home/myself/practice/jazz
home/myself/practice/collection.tar
$ @kbd{tar --test --file practice.tar}
$ @kbd{tar --list --file practice.tar}
home/myself/practice/
home/myself/practice/blues
home/myself/practice/folk
@@ -2553,6 +2553,12 @@ Wait for @var{time} seconds.
@item ttyout=@var{string}
Output @var{string} on the current console (@file{/dev/tty}).
@item totals
Print statistics (see @pxref{totals}).
@item wait=@var{signo}
Wait for signal @var{signo}.
@end table
Several @option{--checkpoint-action} options can be specified. The
@@ -3713,6 +3719,9 @@ only attributes from the user namespace.
@itemx -J
Use @command{xz} for compressing or decompressing the archives. @xref{gzip}.
@item --zstd
Use @command{zstd} for compressing or decompressing the archives. @xref{gzip}.
@end table
@node Short Option Summary
@@ -3786,8 +3795,8 @@ them with the equivalent long option.
@item -m @tab @ref{--touch}.
@item -o @tab When creating, @ref{--no-same-owner}, when extracting ---
@ref{--portability}.
@item -o @tab When extracting, same as @ref{--no-same-owner}. When creating,
-- @ref{--old-archive}.
The latter usage is deprecated. It is retained for compatibility with
the earlier versions of @GNUTAR{}. In future releases
@@ -3968,7 +3977,7 @@ successfully. For example, @w{@samp{tar --version}} might print:
@smallexample
tar (GNU tar) @value{VERSION}
Copyright (C) 2013-2017 Free Software Foundation, Inc.
Copyright (C) 2013-2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
@@ -4449,6 +4458,25 @@ checkpoint:
$ @kbd{tar -c --checkpoint=1000 --checkpoint-action=sleep=30}
@end smallexample
@anchor{checkpoint wait}
@cindex @code{wait}, checkpoint action
The @code{wait=@var{signo}} action stops further execution until the
signal @var{signo} is delivered. Valid values for @var{signo} are:
@code{SIGHUP}, @code{SIGQUIT}, @code{SIGINT}, @code{SIGUSR1} and
@code{SIGUSR2}. The @samp{SIG} prefix is optional. For example:
@example
$ @kbd{tar -c -f arc --checkpoint=1000 --checkpoint-action wait=USR1 .}
@end example
In this example, @GNUTAR{} will stop archivation at each 1000th
checkpoint. wait until the @samp{SIGUSR1} signal is delivered,
and resume processing.
This action is used by the @command{genfile} utility to perform
modifications on the input files upon hitting certain checkpoints
(@pxref{Exec Mode, genfile}).
@anchor{checkpoint exec}
@cindex @code{exec}, checkpoint action
Finally, the @code{exec} action executes a given external command.
@@ -5477,7 +5505,7 @@ reproducible archives given a common timestamp for generated files
while still retaining the original timestamps of untouched files.
@smallexample
$ @kbd{tar -c -f archive.tar --clamp-mtime --mtime=@atchar{}$SOURCE_DATE_EPOCH .}
$ @kbd{tar -c -f archive.tar --clamp-mtime --mtime=@@$SOURCE_DATE_EPOCH .}
@end smallexample
@item --owner=@var{user}
@@ -9520,24 +9548,32 @@ switch to @samp{posix}.
@cindex lzma
@cindex lzop
@cindex compress
@cindex zstd
@GNUTAR{} is able to create and read compressed archives. It supports
a wide variety of compression programs, namely: @command{gzip},
@command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
@command{xz} and traditional @command{compress}. The latter is
supported mostly for backward compatibility, and we recommend
@command{zstd}, @command{xz} and traditional @command{compress}. The
latter is supported mostly for backward compatibility, and we recommend
against using it, because it is by far less effective than the other
compression programs@footnote{It also had patent problems in the past.}.
Creating a compressed archive is simple: you just specify a
@dfn{compression option} along with the usual archive creation
commands. The compression option is @option{-z} (@option{--gzip}) to
create a @command{gzip} compressed archive, @option{-j}
(@option{--bzip2}) to create a @command{bzip2} compressed archive,
@option{--lzip} to create an @asis{lzip} compressed archive,
@option{-J} (@option{--xz}) to create an @asis{XZ} archive,
@option{--lzma} to create an @asis{LZMA} compressed
archive, @option{--lzop} to create an @asis{LZOP} archive, and
@option{-Z} (@option{--compress}) to use @command{compress} program.
commands. Available compression options are summarized in the
table below:
@multitable @columnfractions 0.4 0.2 0.4
@headitem Long @tab Short @tab Archive format
@item @option{--gzip} @tab @option{-z} @tab @command{gzip}
@item @option{--bzip2} @tab @option{-j} @tab @command{bzip2}
@item @option{--xz} @tab @option{-J} @tab @command{xz}
@item @option{--lzip} @tab @tab @command{lzip}
@item @option{--lzma} @tab @tab @command{lzma}
@item @option{--lzop} @tab @tab @command{lzop}
@item @option{--zstd} @tab @tab @command{zstd}
@item @option{--compress} @tab @option{-Z} @tab @command{compress}
@end multitable
For example:
@smallexample
@@ -9658,6 +9694,10 @@ Filter the archive through @command{lzma}.
@item --lzop
Filter the archive through @command{lzop}.
@opindex zstd
@item --zstd
Filter the archive through @command{zstd}.
@opindex compress
@opindex uncompress
@item -Z
@@ -9730,6 +9770,8 @@ suffix. The following suffixes are recognized:
@item @samp{.tlz} @tab @command{lzma}
@item @samp{.lzo} @tab @command{lzop}
@item @samp{.xz} @tab @command{xz}
@item @samp{.zst} @tab @command{zstd}
@item @samp{.tzst} @tab @command{zstd}
@end multitable
@anchor{use-compress-program}

View File

@@ -1,5 +1,4 @@
# Copyright 2006-2007, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2006-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,6 +1,5 @@
@c This is part of GNU tar manual.
@c Copyright 1992, 1994-1997, 1999-2006, 2013-2014, 2016-2017 Free
@c Software Foundation, Inc.
@c Copyright 1992-2019 Free Software Foundation, Inc.
@c See file tar.texi for copying conditions.
@macro GNUTAR

2
gnulib

Submodule gnulib updated: 91e834891d...4652c7bafa

View File

@@ -1,7 +1,7 @@
# List of gnulib modules needed for GNU tar.
# A module name per line. Empty lines and comments are ignored.
# Copyright 2005-2010, 2012-2014, 2017 Free Software Foundation, Inc.
# Copyright 2005-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.
@@ -85,6 +85,7 @@ stdint
stpcpy
strdup-posix
strerror
strnlen
strtoimax
strtol
strtoul

View File

@@ -1,7 +1,6 @@
# Makefile for GNU tar library. -*- Makefile -*-
# Copyright 1994-1997, 1999-2001, 2003-2007, 2009-2010, 2013-2014,
# 2016-2017 Free Software Foundation, Inc.
# Copyright 1994-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,5 +1,5 @@
/* Replacement <attr/xattr.h> for platforms that lack it.
Copyright 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2012-2019 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

View File

@@ -1,7 +1,6 @@
/* stdopen.c - ensure that the three standard file descriptors are in use
Copyright 2005, 2007, 2013-2014, 2016-2017 Free Software Foundation,
Inc.
Copyright 2005-2019 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

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* wordsplit - a word splitter
Copyright (C) 2009-2014, 2016-2017 Free Software Foundation, Inc.
Copyright (C) 2009-2018 Sergey Poznyakoff
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
@@ -12,10 +12,7 @@
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 Sergey Poznyakoff
*/
with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef __WORDSPLIT_H
#define __WORDSPLIT_H
@@ -28,42 +25,106 @@
# define __WORDSPLIT_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
struct wordsplit
typedef struct wordsplit wordsplit_t;
/* Structure used to direct the splitting. Members marked with [Input]
can be defined before calling wordsplit(), those marked with [Output]
provide return values when the function returns. If neither mark is
used, the member is internal and must not be used by the caller.
In the comments below, the identifiers in parentheses indicate bits that
must be set (or unset, if starting with !) in ws_flags (if starting with
WRDSF_) or ws_options (if starting with WRDSO_) to initialize or use the
given member.
If not redefined explicitly, most of them are set to some reasonable
default value upon entry to wordsplit(). */
struct wordsplit
{
size_t ws_wordc;
char **ws_wordv;
size_t ws_offs;
size_t ws_wordn;
int ws_flags;
const char *ws_delim;
const char *ws_comment;
const char *ws_escape;
void (*ws_alloc_die) (struct wordsplit * wsp);
size_t ws_wordc; /* [Output] Number of words in ws_wordv. */
char **ws_wordv; /* [Output] Array of parsed out words. */
size_t ws_offs; /* [Input] (WRDSF_DOOFFS) Number of initial
elements in ws_wordv to fill with NULLs. */
size_t ws_wordn; /* Number of elements ws_wordv can accomodate. */
unsigned ws_flags; /* [Input] Flags passed to wordsplit. */
unsigned ws_options; /* [Input] (WRDSF_OPTIONS)
Additional options. */
size_t ws_maxwords; /* [Input] (WRDSO_MAXWORDS) Return at most that
many words */
size_t ws_wordi; /* [Output] (WRDSF_INCREMENTAL) Total number of
words returned so far */
const char *ws_delim; /* [Input] (WRDSF_DELIM) Word delimiters. */
const char *ws_comment; /* [Input] (WRDSF_COMMENT) Comment characters. */
const char *ws_escape[2]; /* [Input] (WRDSF_ESCAPE) Characters to be escaped
with backslash. */
void (*ws_alloc_die) (wordsplit_t *wsp);
/* [Input] (WRDSF_ALLOC_DIE) Function called when
out of memory. Must not return. */
void (*ws_error) (const char *, ...)
__WORDSPLIT_ATTRIBUTE_FORMAT ((__printf__, 1, 2));
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_ERROR) Function used for error
reporting */
void (*ws_debug) (const char *, ...)
__WORDSPLIT_ATTRIBUTE_FORMAT ((__printf__, 1, 2));
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_DEBUG) Function used for debug
output. */
const char **ws_env; /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of
environment variables. */
const char **ws_env;
const char *(*ws_getvar) (const char *, size_t, void *);
void *ws_closure;
char **ws_envbuf;
size_t ws_envidx;
size_t ws_envsiz;
int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos);
/* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
the name VAR (LEN bytes long) in the table of
variables and if found returns in memory
location pointed to by RET the value of that
variable. Returns WRDSE_OK (0) on success,
and an error code (see WRDSE_* defines below)
on error. User-specific errors can be returned
by storing the error diagnostic string in RET
and returning WRDSE_USERERR.
Whatever is stored in RET, it must be allocated
using malloc(3). */
void *ws_closure; /* [Input] (WRDSF_CLOSURE) Passed as the CLOS
argument to ws_getvar and ws_command. */
int (*ws_command) (char **ret, const char *cmd, size_t len, char **argv,
void *clos);
/* [Input] (!WRDSF_NOCMD) Returns in the memory
location pointed to by RET the expansion of
the command CMD (LEN bytes long). If WRDSO_ARGV
option is set, ARGV contains CMD split out to
words. Otherwise ARGV is NULL.
const char *ws_input;
size_t ws_len;
size_t ws_endp;
int ws_errno;
See ws_getvar for a discussion of possible
return values. */
const char *ws_input; /* Input string (the S argument to wordsplit. */
size_t ws_len; /* Length of ws_input. */
size_t ws_endp; /* Points past the last processed byte in
ws_input. */
int ws_errno; /* [Output] Error code, if an error occurred. */
char *ws_usererr; /* Points to textual description of
the error, if ws_errno is WRDSE_USERERR. Must
be allocated with malloc(3). */
struct wordsplit_node *ws_head, *ws_tail;
/* Doubly-linked list of parsed out nodes. */
int ws_lvl; /* Invocation nesting level. */
};
/* Wordsplit flags. Only 2 bits of a 32-bit word remain unused.
It is getting crowded... */
/* Initial size for ws_env, if allocated automatically */
#define WORDSPLIT_ENV_INIT 16
/* Wordsplit flags. */
/* Append the words found to the array resulting from a previous
call. */
#define WRDSF_APPEND 0x00000001
/* Insert we_offs initial NULLs in the array ws_wordv.
/* Insert ws_offs initial NULLs in the array ws_wordv.
(These are not counted in the returned ws_wordc.) */
#define WRDSF_DOOFFS 0x00000002
/* Don't do command substitution. Reserved for future use. */
/* Don't do command substitution. */
#define WRDSF_NOCMD 0x00000004
/* The parameter p resulted from a previous call to
wordsplit(), and wordsplit_free() was not called. Reuse the
@@ -71,10 +132,8 @@ struct wordsplit
#define WRDSF_REUSE 0x00000008
/* Print errors */
#define WRDSF_SHOWERR 0x00000010
/* Consider it an error if an undefined shell variable
is expanded. */
/* Consider it an error if an undefined variable is expanded. */
#define WRDSF_UNDEF 0x00000020
/* Don't do variable expansion. */
#define WRDSF_NOVAR 0x00000040
/* Abort on ENOMEM error */
@@ -85,7 +144,7 @@ struct wordsplit
#define WRDSF_SQUOTE 0x00000200
/* Handle double quotes */
#define WRDSF_DQUOTE 0x00000400
/* Handle quotes and escape directives */
/* Handle single and double quotes */
#define WRDSF_QUOTE (WRDSF_SQUOTE|WRDSF_DQUOTE)
/* Replace each input sequence of repeated delimiters with a single
delimiter */
@@ -113,56 +172,106 @@ struct wordsplit
/* Don't split input into words. Useful for side effects. */
#define WRDSF_NOSPLIT 0x00400000
/* Keep undefined variables in place, instead of expanding them to
empty string */
empty strings. */
#define WRDSF_KEEPUNDEF 0x00800000
/* Warn about undefined variables */
#define WRDSF_WARNUNDEF 0x01000000
/* Handle C escapes */
#define WRDSF_CESCAPES 0x02000000
/* ws_closure is set */
#define WRDSF_CLOSURE 0x04000000
/* ws_env is a Key/Value environment, i.e. the value of a variable is
stored in the element that follows its name. */
#define WRDSF_ENV_KV 0x08000000
/* ws_escape is set */
#define WRDSF_ESCAPE 0x10000000
/* Incremental mode */
#define WRDSF_INCREMENTAL 0x20000000
/* Perform pathname and tilde expansion */
#define WRDSF_PATHEXPAND 0x40000000
/* ws_options is initialized */
#define WRDSF_OPTIONS 0x80000000
#define WRDSF_DEFFLAGS \
(WRDSF_NOVAR | WRDSF_NOCMD | \
WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_CESCAPES)
#define WRDSE_EOF 0
/* Remove the word that produces empty string after path expansion */
#define WRDSO_NULLGLOB 0x00000001
/* Print error message if path expansion produces empty string */
#define WRDSO_FAILGLOB 0x00000002
/* Allow a leading period to be matched by metacharacters. */
#define WRDSO_DOTGLOB 0x00000004
/* ws_command needs argv parameter */
#define WRDSO_ARGV 0x00000008
/* Keep backslash in unrecognized escape sequences in words */
#define WRDSO_BSKEEP_WORD 0x00000010
/* Handle octal escapes in words */
#define WRDSO_OESC_WORD 0x00000020
/* Handle hex escapes in words */
#define WRDSO_XESC_WORD 0x00000040
/* ws_maxwords field is initialized */
#define WRDSO_MAXWORDS 0x00000080
/* Keep backslash in unrecognized escape sequences in quoted strings */
#define WRDSO_BSKEEP_QUOTE 0x00000100
/* Handle octal escapes in quoted strings */
#define WRDSO_OESC_QUOTE 0x00000200
/* Handle hex escapes in quoted strings */
#define WRDSO_XESC_QUOTE 0x00000400
#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD
#define WRDSO_OESC WRDSO_OESC_WORD
#define WRDSO_XESC WRDSO_XESC_WORD
/* Indices into ws_escape */
#define WRDSX_WORD 0
#define WRDSX_QUOTE 1
/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */
#define WRDSO_ESC_SET(ws,q,f) ((ws)->ws_options |= ((f) << 4*(q)))
/* Test WS for escape option F for words (Q==0) or quoted strings (Q==1) */
#define WRDSO_ESC_TEST(ws,q,f) ((ws)->ws_options & ((f) << 4*(q)))
#define WRDSE_OK 0
#define WRDSE_EOF WRDSE_OK
#define WRDSE_QUOTE 1
#define WRDSE_NOSPACE 2
#define WRDSE_NOSUPP 3
#define WRDSE_USAGE 4
#define WRDSE_CBRACE 5
#define WRDSE_UNDEF 6
#define WRDSE_NOINPUT 7
#define WRDSE_USAGE 3
#define WRDSE_CBRACE 4
#define WRDSE_UNDEF 5
#define WRDSE_NOINPUT 6
#define WRDSE_PAREN 7
#define WRDSE_GLOBERR 8
#define WRDSE_USERERR 9
int wordsplit (const char *s, struct wordsplit *p, int flags);
int wordsplit_len (const char *s, size_t len,
struct wordsplit *p, int flags);
void wordsplit_free (struct wordsplit *p);
void wordsplit_free_words (struct wordsplit *ws);
int wordsplit (const char *s, wordsplit_t *ws, unsigned flags);
int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, unsigned flags);
void wordsplit_free (wordsplit_t *ws);
void wordsplit_free_words (wordsplit_t *ws);
void wordsplit_free_envbuf (wordsplit_t *ws);
int wordsplit_get_words (wordsplit_t *ws, size_t *wordc, char ***wordv);
static inline void wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv)
__attribute__ ((deprecated));
static inline void
wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv)
{
wordsplit_get_words (ws, wordc, wordv);
}
int wordsplit_append (wordsplit_t *wsp, int argc, char **argv);
int wordsplit_c_unquote_char (int c);
int wordsplit_c_quote_char (int c);
size_t wordsplit_c_quoted_length (const char *str, int quote_hex,
int *quote);
void wordsplit_general_unquote_copy (char *dst, const char *src, size_t n,
const char *escapable);
void wordsplit_sh_unquote_copy (char *dst, const char *src, size_t n);
void wordsplit_c_unquote_copy (char *dst, const char *src, size_t n);
size_t wordsplit_c_quoted_length (const char *str, int quote_hex, int *quote);
void wordsplit_c_quote_copy (char *dst, const char *src, int quote_hex);
void wordsplit_perror (struct wordsplit *ws);
const char *wordsplit_strerror (struct wordsplit *ws);
void wordsplit_perror (wordsplit_t *ws);
const char *wordsplit_strerror (wordsplit_t *ws);
void wordsplit_clearerr (wordsplit_t *ws);
#endif

View File

@@ -1,7 +1,7 @@
/* openat-style fd-relative functions for operating with extended file
attributes.
Copyright 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2012-2019 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

View File

@@ -1,7 +1,7 @@
/* Prototypes for openat-style fd-relative functions for operating with
extended file attributes.
Copyright 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2012-2019 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

View File

@@ -1,7 +1,6 @@
# List of files which contain translatable strings.
# Copyright 1996, 1999-2000, 2003-2005, 2007, 2013-2014, 2016-2017 Free
# Software Foundation, Inc.
# Copyright 1996-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
# Make GNU tar scripts.
# Copyright 2004, 2006-2007, 2013-2014, 2016-2017 Free Software
# Foundation, Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -82,8 +82,7 @@ SLEEP_MESSAGE="`awk '
}' /dev/null`"
# Copyright 2004, 2007, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
#! /bin/sh
# Make backups.
# Copyright 2004-2006, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -8,8 +8,7 @@
# interested parties that a tape for the next volume of the backup needs to
# be put in the tape drive.
# Copyright 2004-2005, 2010, 2012-2014, 2016-2017 Free Software
# Foundation, Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
#! /bin/sh
# Restore backups.
# Copyright 2004, 2006, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
#! /usr/bin/perl -w
# Display and edit the 'dev' field in tar's snapshots
# Copyright 2007, 2011, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2007-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.
@@ -409,7 +408,7 @@ sub check_field_values ($) {
}
if ( $msg ne "" ) {
$error_found = 1;
print "\n shapshot file header:\n";
print "\n snapshot file header:\n";
print $msg;
}

View File

@@ -3,8 +3,7 @@
# concatenates a GNU tar multi-volume archive into a single tar archive.
# Author: Bruno Haible <bruno@clisp.org>, Sergey Poznyakoff <gray@gnu.org.ua>
# Copyright 2004-2005, 2010, 2013-2014, 2016-2017 Free Software
# Foundation, Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
/* xsparse - expands compressed sparse file images extracted from GNU tar
archives.
Copyright 2006-2007, 2010, 2013-2014, 2016-2017 Free Software
Foundation, Inc.
Copyright 2006-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
# Makefile for GNU tar sources.
# Copyright 1994-1997, 1999-2001, 2003, 2006-2007, 2009, 2013-2014,
# 2016-2017 Free Software Foundation, Inc.
# Copyright 1994-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,6 +1,5 @@
/* Long integers, for GNU tar.
Copyright 1999, 2007, 2013-2014, 2016-2017 Free Software Foundation,
Inc.
Copyright 1999-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
/* Buffer management for tar.
Copyright 1988, 1992-1994, 1996-1997, 1999-2010, 2013-2014, 2016-2017
Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -281,7 +280,8 @@ enum compress_type {
ct_lzip,
ct_lzma,
ct_lzop,
ct_xz
ct_xz,
ct_zstd
};
static enum compress_type archive_compression_type = ct_none;
@@ -310,6 +310,7 @@ static struct zip_magic const magic[] = {
{ ct_lzma, 6, "\xFFLZMA" },
{ ct_lzop, 4, "\211LZO" },
{ ct_xz, 6, "\xFD" "7zXZ" },
{ ct_zstd, 4, "\x28\xB5\x2F\xFD" },
};
#define NMAGIC (sizeof(magic)/sizeof(magic[0]))
@@ -325,6 +326,7 @@ static struct zip_program zip_program[] = {
{ ct_lzma, XZ_PROGRAM, "-J" },
{ ct_lzop, LZOP_PROGRAM, "--lzop" },
{ ct_xz, XZ_PROGRAM, "-J" },
{ ct_zstd, ZSTD_PROGRAM, "--zstd" },
{ ct_none }
};
@@ -1500,7 +1502,7 @@ try_new_volume (void)
if (!read_header0 (&dummy))
return false;
tar_stat_destroy (&dummy);
assign_string (&volume_label, current_header->header.name);
ASSIGN_STRING_N (&volume_label, current_header->header.name);
set_next_block_after (header);
header = find_next_block ();
if (header->header.typeflag != GNUTYPE_MULTIVOL)
@@ -1510,7 +1512,7 @@ try_new_volume (void)
if (!read_header0 (&dummy))
return false;
tar_stat_destroy (&dummy);
assign_string (&continued_file_name, current_header->header.name);
ASSIGN_STRING_N (&continued_file_name, current_header->header.name);
continued_file_size =
UINTMAX_FROM_HEADER (current_header->header.size);
continued_file_offset =
@@ -1653,15 +1655,7 @@ match_volume_label (void)
quote (volume_label_option)));
if (label->header.typeflag == GNUTYPE_VOLHDR)
{
if (memchr (label->header.name, '\0', sizeof label->header.name))
assign_string (&volume_label, label->header.name);
else
{
volume_label = xmalloc (sizeof (label->header.name) + 1);
memcpy (volume_label, label->header.name,
sizeof (label->header.name));
volume_label[sizeof (label->header.name)] = 0;
}
ASSIGN_STRING_N (&volume_label, label->header.name);
}
else if (label->header.typeflag == XGLTYPE)
{
@@ -1697,8 +1691,7 @@ _write_volume_label (const char *str)
memset (label, 0, BLOCKSIZE);
strcpy (label->header.name, str);
assign_string (&current_stat_info.file_name,
label->header.name);
assign_string (&current_stat_info.file_name, label->header.name);
current_stat_info.had_trailing_slash =
strip_trailing_slashes (current_stat_info.file_name);
@@ -1768,15 +1761,19 @@ gnu_add_multi_volume_header (struct bufmap *map)
{
int tmp;
union block *block = find_next_block ();
size_t len = strlen (map->file_name);
if (strlen (map->file_name) > NAME_FIELD_SIZE)
WARN ((0, 0,
_("%s: file name too long to be stored in a GNU multivolume header, truncated"),
quotearg_colon (map->file_name)));
if (len > NAME_FIELD_SIZE)
{
WARN ((0, 0,
_("%s: file name too long to be stored in a GNU multivolume header, truncated"),
quotearg_colon (map->file_name)));
len = NAME_FIELD_SIZE;
}
memset (block, 0, BLOCKSIZE);
strncpy (block->header.name, map->file_name, NAME_FIELD_SIZE);
memcpy (block->header.name, map->file_name, len);
block->header.typeflag = GNUTYPE_MULTIVOL;
OFF_TO_CHARS (map->sizeleft, block->header.size);

View File

@@ -1,6 +1,6 @@
/* Checkpoint management for tar.
Copyright 2007, 2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2007-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -23,6 +23,7 @@
#include <sys/ioctl.h>
#include <termios.h>
#include "fprintftime.h"
#include <signal.h>
enum checkpoint_opcode
{
@@ -32,7 +33,8 @@ enum checkpoint_opcode
cop_ttyout,
cop_sleep,
cop_exec,
cop_totals
cop_totals,
cop_wait
};
struct checkpoint_action
@@ -43,6 +45,7 @@ struct checkpoint_action
{
time_t time;
char *command;
int signal;
} v;
};
@@ -52,6 +55,16 @@ static unsigned checkpoint;
/* List of checkpoint actions */
static struct checkpoint_action *checkpoint_action, *checkpoint_action_tail;
/* State of the checkpoint system */
enum {
CHKP_INIT, /* Needs initialization */
CHKP_COMPILE, /* Actions are being compiled */
CHKP_RUN /* Actions are being run */
};
static int checkpoint_state;
/* Blocked signals */
static sigset_t sigs;
static struct checkpoint_action *
alloc_action (enum checkpoint_opcode opcode)
{
@@ -85,6 +98,12 @@ checkpoint_compile_action (const char *str)
{
struct checkpoint_action *act;
if (checkpoint_state == CHKP_INIT)
{
sigemptyset (&sigs);
checkpoint_state = CHKP_COMPILE;
}
if (strcmp (str, ".") == 0 || strcmp (str, "dot") == 0)
alloc_action (cop_dot);
else if (strcmp (str, "bell") == 0)
@@ -117,6 +136,12 @@ checkpoint_compile_action (const char *str)
}
else if (strcmp (str, "totals") == 0)
alloc_action (cop_totals);
else if (strncmp (str, "wait=", 5) == 0)
{
act = alloc_action (cop_wait);
act->v.signal = decode_signal (str + 5);
sigaddset (&sigs, act->v.signal);
}
else
FATAL_ERROR ((0, 0, _("%s: unknown checkpoint action"), str));
}
@@ -124,15 +149,24 @@ checkpoint_compile_action (const char *str)
void
checkpoint_finish_compile (void)
{
if (checkpoint_option)
if (checkpoint_state == CHKP_INIT
&& checkpoint_option
&& !checkpoint_action)
{
if (!checkpoint_action)
/* Provide a historical default */
checkpoint_compile_action ("echo");
/* Provide a historical default */
checkpoint_compile_action ("echo");
}
if (checkpoint_state == CHKP_COMPILE)
{
sigprocmask (SIG_BLOCK, &sigs, NULL);
if (!checkpoint_option)
/* set default checkpoint rate */
checkpoint_option = DEFAULT_CHECKPOINT;
checkpoint_state = CHKP_RUN;
}
else if (checkpoint_action)
/* Otherwise, set default checkpoint rate */
checkpoint_option = DEFAULT_CHECKPOINT;
}
static const char *checkpoint_total_format[] = {
@@ -390,6 +424,13 @@ run_checkpoint_actions (bool do_write)
case cop_totals:
compute_duration ();
print_total_stats ();
break;
case cop_wait:
{
int n;
sigwait (&sigs, &n);
}
}
}
}

View File

@@ -1,7 +1,6 @@
/* Common declarations for the tar program.
Copyright 1988, 1992-1994, 1996-1997, 1999-2010, 2012-2017 Free
Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -302,6 +301,10 @@ enum hole_detection_method
GLOBAL enum hole_detection_method hole_detection;
/* The first entry in names.c:namelist specifies the member name to
start extracting from. Set by add_starting_file() upon seeing the
-K option.
*/
GLOBAL bool starting_file_option;
/* Specified maximum byte length of each tape volume (multiple of 1024). */
@@ -628,6 +631,8 @@ void skip_member (void);
char const *quote_n_colon (int n, char const *arg);
void assign_string (char **dest, const char *src);
void assign_string_n (char **string, const char *value, size_t n);
#define ASSIGN_STRING_N(s,v) assign_string_n (s, v, sizeof (v))
int unquote_string (char *str);
char *zap_slashes (char *name);
char *normalize_filename (int cdidx, const char *name);
@@ -750,6 +755,7 @@ const char *name_next (int change_dirs);
void name_gather (void);
struct name *addname (char const *string, int change_dir,
bool cmdline, struct name *parent);
void add_starting_file (char const *file_name);
void remname (struct name *name);
bool name_match (const char *name);
void names_notfound (void);
@@ -791,6 +797,8 @@ void set_exit_status (int val);
void request_stdin (const char *option);
int decode_signal (const char *);
/* Where an option comes from: */
enum option_source
{
@@ -829,6 +837,7 @@ void xheader_store (char const *keyword, struct tar_stat_info *st,
void xheader_read (struct xheader *xhdr, union block *header, off_t size);
void xheader_write (char type, char *name, time_t t, struct xheader *xhdr);
void xheader_write_global (struct xheader *xhdr);
void xheader_forbid_global (void);
void xheader_finish (struct xheader *hdr);
void xheader_destroy (struct xheader *hdr);
char *xheader_xhdr_name (struct tar_stat_info *st);

View File

@@ -1,7 +1,6 @@
/* Diff files from a tar archive.
Copyright 1988, 1992-1994, 1996-1997, 1999-2001, 2003-2007,
2009-2010, 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
/* Create a tar archive.
Copyright 1985, 1992-1994, 1996-1997, 1999-2001, 2003-2007,
2009-2010, 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1985-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -518,8 +517,8 @@ start_private_header (const char *name, size_t size, time_t t)
MODE_TO_CHARS (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, header->header.mode);
UID_TO_CHARS (0, header->header.uid);
GID_TO_CHARS (0, header->header.gid);
strncpy (header->header.magic, TMAGIC, TMAGLEN);
strncpy (header->header.version, TVERSION, TVERSLEN);
memcpy (header->header.magic, TMAGIC, TMAGLEN);
memcpy (header->header.version, TVERSION, TVERSLEN);
return header;
}
@@ -917,8 +916,8 @@ start_header (struct tar_stat_info *st)
case POSIX_FORMAT:
case USTAR_FORMAT:
strncpy (header->header.magic, TMAGIC, TMAGLEN);
strncpy (header->header.version, TVERSION, TVERSLEN);
memcpy (header->header.magic, TMAGIC, TMAGLEN);
memcpy (header->header.version, TVERSION, TVERSLEN);
break;
default:

View File

@@ -1,7 +1,6 @@
/* Delete entries from a tar archive.
Copyright 1988, 1992, 1994, 1996-1997, 2000-2001, 2003-2006, 2010,
2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,6 +1,6 @@
/* Per-directory exclusion files for tar.
Copyright 2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2014-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,6 +1,6 @@
/* Exit from GNU tar.
Copyright 2009, 2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2009-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
/* Extract files from a tar archive.
Copyright 1988, 1992-1994, 1996-2001, 2003-2007, 2010, 2012-2014,
2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -788,6 +787,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
case UNLINK_FIRST_OLD_FILES:
break;
}
FALLTHROUGH;
case ENOENT:
/* Attempt creating missing intermediate directories. */

View File

@@ -1,7 +1,6 @@
/* GNU dump extensions to tar.
Copyright 1988, 1992-1994, 1996-1997, 1999-2001, 2003-2009,
2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -915,6 +914,7 @@ store_rename (struct directory *dir, struct obstack *stk)
obstack_code_rename (stk, p->orig->name, p->name);
obstack_code_rename (stk, "", prev->name);
free (temp_name);
}
}
}
@@ -997,10 +997,10 @@ read_incr_db_01 (int version, const char *initbuf)
newer_mtime_option = decode_timespec (buf, &ebuf, false);
if (! valid_timespec (newer_mtime_option))
ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option),
lineno,
_("Invalid time stamp")));
FATAL_ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option),
lineno,
_("Invalid time stamp")));
else
{
if (version == 1 && *ebuf)
@@ -1042,9 +1042,9 @@ read_incr_db_01 (int version, const char *initbuf)
mtime = decode_timespec (strp, &ebuf, false);
strp = ebuf;
if (!valid_timespec (mtime) || *strp != ' ')
ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid modification time")));
FATAL_ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid modification time")));
errno = 0;
u = strtoumax (strp, &ebuf, 10);
@@ -1052,9 +1052,9 @@ read_incr_db_01 (int version, const char *initbuf)
errno = ERANGE;
if (errno || strp == ebuf || *ebuf != ' ')
{
ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid modification time (nanoseconds)")));
FATAL_ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid modification time (nanoseconds)")));
mtime.tv_nsec = -1;
}
else
@@ -1068,17 +1068,17 @@ read_incr_db_01 (int version, const char *initbuf)
TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t));
strp = ebuf;
if (errno || *strp != ' ')
ERROR ((0, errno, "%s:%ld: %s",
FATAL_ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid device number")));
_("Invalid device number")));
ino = strtosysint (strp, &ebuf,
TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t));
strp = ebuf;
if (errno || *strp != ' ')
ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid inode number")));
FATAL_ERROR ((0, errno, "%s:%ld: %s",
quotearg_colon (listed_incremental_option), lineno,
_("Invalid inode number")));
strp++;
unquote_string (strp);

View File

@@ -1,7 +1,6 @@
/* List a tar archive, with support routines for reading a tar archive.
Copyright 1988, 1992-1994, 1996-2001, 2003-2007, 2010, 2012-2017 Free
Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -23,7 +22,7 @@
#include <system.h>
#include <inttostr.h>
#include <quotearg.h>
#include <time.h>
#include "common.h"
union block *current_header; /* points to current archive header */
@@ -631,10 +630,12 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
stat_info->stat.st_mode = mode;
stat_info->mtime.tv_sec = TIME_FROM_HEADER (header->header.mtime);
stat_info->mtime.tv_nsec = 0;
assign_string (&stat_info->uname,
header->header.uname[0] ? header->header.uname : NULL);
assign_string (&stat_info->gname,
header->header.gname[0] ? header->header.gname : NULL);
assign_string_n (&stat_info->uname,
header->header.uname[0] ? header->header.uname : NULL,
sizeof (header->header.uname));
assign_string_n (&stat_info->gname,
header->header.gname[0] ? header->header.gname : NULL,
sizeof (header->header.gname));
xheader_xattr_init (stat_info);
@@ -1049,15 +1050,11 @@ tartime (struct timespec t, bool full_time)
{
if (full_time)
{
sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M:%S", tm);
code_ns_fraction (ns, buffer + strlen (buffer));
}
else
sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min);
strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M", tm);
return buffer;
}
@@ -1443,7 +1440,7 @@ test_archive_label (void)
decode_header (current_header,
&current_stat_info, &current_format, 0);
if (current_header->header.typeflag == GNUTYPE_VOLHDR)
assign_string (&volume_label, current_header->header.name);
ASSIGN_STRING_N (&volume_label, current_header->header.name);
if (volume_label)
{

View File

@@ -1,6 +1,6 @@
/* Owner/group mapping for tar
Copyright 2015-2017 Free Software Foundation, Inc.
Copyright 2015-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
/* Miscellaneous functions, not really specific to GNU tar.
Copyright 1988, 1992, 1994-1997, 1999-2001, 2003-2007, 2009-2010,
2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 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
@@ -50,6 +49,20 @@ assign_string (char **string, const char *value)
*string = value ? xstrdup (value) : 0;
}
void
assign_string_n (char **string, const char *value, size_t n)
{
free (*string);
if (value)
{
size_t l = strnlen (value, n);
char *p = xmalloc (l + 1);
memcpy (p, value, l);
p[l] = 0;
*string = p;
}
}
#if 0
/* This function is currently unused; perhaps it should be removed? */
@@ -727,7 +740,7 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
&& (S_ISBLK (file_stat.st_mode) || S_ISCHR (file_stat.st_mode)))
return true;
after_backup_name = find_backup_file_name (file_name, backup_type);
after_backup_name = find_backup_file_name (chdir_fd, file_name, backup_type);
if (! after_backup_name)
xalloc_die ();

View File

@@ -1,7 +1,6 @@
/* Various processing of names.
Copyright 1988, 1992, 1994, 1996-2001, 2003-2007, 2009, 2013-2017
Free Software Foundation, Inc.
Copyright 1988-2019 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
@@ -1227,6 +1226,34 @@ addname (char const *string, int change_dir, bool cmdline, struct name *parent)
return name;
}
void
add_starting_file (char const *file_name)
{
struct name *name = make_name (file_name);
if (starting_file_option)
{
struct name *head = namelist;
remname (head);
free_name (head);
}
name->prev = NULL;
name->next = namelist;
namelist = name;
if (!nametail)
nametail = namelist;
name->found_count = 0;
name->matching_flags = INCLUDE_OPTIONS;
name->change_dir = 0;
name->directory = NULL;
name->parent = NULL;
name->cmdline = true;
starting_file_option = true;
}
/* Find a match for FILE_NAME (whose string length is LENGTH) in the name
list. */
static struct name *
@@ -1283,19 +1310,22 @@ name_match (const char *file_name)
}
cursor = namelist_match (file_name, length);
if (starting_file_option)
{
/* If starting_file_option is set, the head of the list is the name
of the member to start extraction from. Skip the match unless it
is head. */
if (cursor == namelist)
starting_file_option = false;
else
cursor = NULL;
}
if (cursor)
{
if (!(ISSLASH (file_name[cursor->length]) && recursion_option)
|| cursor->found_count == 0)
cursor->found_count++; /* remember it matched */
if (starting_file_option)
{
free (namelist);
namelist = NULL;
nametail = NULL;
}
chdir_do (cursor->change_dir);
/* We got a match. */
return ISFOUND (cursor);
}
@@ -1767,6 +1797,11 @@ collect_and_sort_names (void)
name->found_count++;
add_hierarchy_to_namelist (&st, name);
}
else
{
errno = ENOTDIR;
open_diag (name->name);
}
}
}
@@ -1821,7 +1856,7 @@ collect_and_sort_names (void)
if (listed_incremental_option)
{
for (name = namelist; name && name->name[0] == 0; name++)
for (name = namelist; name && name->name[0] == 0; name = name->next)
;
if (name)
append_incremental_renames (name->directory);

View File

@@ -1,6 +1,6 @@
/* Functions for dealing with sparse files
Copyright 2003-2007, 2010, 2013-2017 Free Software Foundation, Inc.
Copyright 2003-2019 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
@@ -427,6 +427,30 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
bufsize);
return false;
}
else if (bytes_read == 0)
{
char buf[UINTMAX_STRSIZE_BOUND];
struct stat st;
size_t n;
if (fstat (file->fd, &st) == 0)
n = file->stat_info->stat.st_size - st.st_size;
else
n = file->stat_info->stat.st_size
- (file->stat_info->sparse_map[i].offset
+ file->stat_info->sparse_map[i].numbytes
- bytes_left);
WARNOPT (WARN_FILE_SHRANK,
(0, 0,
ngettext ("%s: File shrank by %s byte; padding with zeros",
"%s: File shrank by %s bytes; padding with zeros",
n),
quotearg_colon (file->stat_info->orig_file_name),
STRINGIFY_BIGINT (n, buf)));
if (! ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
return false;
}
memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read);
bytes_left -= bytes_read;
@@ -464,9 +488,9 @@ sparse_extract_region (struct tar_sparse_file *file, size_t i)
return false;
}
set_next_block_after (blk);
file->dumped_size += BLOCKSIZE;
count = blocking_write (file->fd, blk->buffer, wrbytes);
write_size -= count;
file->dumped_size += count;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
file->offset += count;
if (count != wrbytes)
@@ -598,6 +622,12 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
rdsize);
return false;
}
else if (bytes_read == 0)
{
report_difference (file->stat_info, _("Size differs"));
return false;
}
if (!zero_block_p (diff_buffer, bytes_read))
{
char begbuf[INT_BUFSIZE_BOUND (off_t)];
@@ -609,6 +639,7 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
beg += bytes_read;
}
return true;
}
@@ -635,6 +666,7 @@ check_data_region (struct tar_sparse_file *file, size_t i)
return false;
}
set_next_block_after (blk);
file->dumped_size += BLOCKSIZE;
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
if (bytes_read == SAFE_READ_ERROR)
{
@@ -645,7 +677,11 @@ check_data_region (struct tar_sparse_file *file, size_t i)
rdsize);
return false;
}
file->dumped_size += bytes_read;
else if (bytes_read == 0)
{
report_difference (&current_stat_info, _("Size differs"));
return false;
}
size_left -= bytes_read;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
if (memcmp (blk->buffer, diff_buffer, rdsize))
@@ -1213,7 +1249,8 @@ pax_decode_header (struct tar_sparse_file *file)
union block *blk;
char *p;
size_t i;
off_t start;
#define COPY_BUF(b,buf,src) do \
{ \
char *endp = b->buffer + BLOCKSIZE; \
@@ -1229,8 +1266,9 @@ pax_decode_header (struct tar_sparse_file *file)
if (src == endp) \
{ \
set_next_block_after (b); \
file->dumped_size += BLOCKSIZE; \
b = find_next_block (); \
if (!b) \
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1240,9 +1278,11 @@ pax_decode_header (struct tar_sparse_file *file)
dst[-1] = 0; \
} while (0)
start = current_block_ordinal ();
set_next_block_after (current_header);
file->dumped_size += BLOCKSIZE;
blk = find_next_block ();
if (!blk)
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
@@ -1278,6 +1318,8 @@ pax_decode_header (struct tar_sparse_file *file)
sparse_add_map (file->stat_info, &sp);
}
set_next_block_after (blk);
file->dumped_size += BLOCKSIZE * (current_block_ordinal () - start);
}
return true;

View File

@@ -1,6 +1,5 @@
/* This file is part of GNU tar.
Copyright 2007, 2009, 2013-2014, 2016-2017 Free Software Foundation,
Inc.
Copyright 2007-2019 Free Software Foundation, Inc.
Written by Sergey Poznyakoff.
@@ -46,6 +45,8 @@ static struct compression_suffix compression_suffixes[] = {
{ S(lzo, LZOP) },
{ S(xz, XZ) },
{ S(txz, XZ) }, /* Slackware */
{ S(zst, ZSTD) },
{ S(tzst, ZSTD) },
{ NULL }
#undef S
#undef __CAT2__
@@ -60,7 +61,7 @@ find_compression_suffix (const char *name, size_t *ret_len)
{
size_t len;
struct compression_suffix *p;
suf++;
len = strlen (suf);
@@ -99,10 +100,14 @@ strip_compression_suffix (const char *name)
{
char *s = NULL;
size_t len;
struct compression_suffix const *p = find_compression_suffix (name, &len);
if (find_compression_suffix (name, &len))
if (p)
{
if (strncmp (name + len - 4, ".tar", 4) == 0)
/* Strip an additional ".tar" suffix, but only if the just-stripped
"outer" suffix did not begin with "t". */
if (len > 4 && strncmp (name + len - 4, ".tar", 4) == 0
&& p->suffix[0] != 't')
len -= 4;
if (len == 0)
return NULL;
@@ -112,4 +117,3 @@ strip_compression_suffix (const char *name)
}
return s;
}

View File

@@ -1,7 +1,6 @@
/* System-dependent calls for tar.
Copyright 2003-2008, 2010, 2013-2014, 2016-2017 Free Software
Foundation, Inc.
Copyright 2003-2019 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

View File

@@ -1,7 +1,6 @@
/* A tar (tape archiver) program.
Copyright 1988, 1992-1997, 1999-2001, 2003-2007, 2012-2017 Free
Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
Written by John Gilmore, starting 1985-08-25.
@@ -348,7 +347,8 @@ enum
WARNING_OPTION,
XATTR_OPTION,
XATTR_EXCLUDE,
XATTR_INCLUDE
XATTR_INCLUDE,
ZSTD_OPTION,
};
static char const doc[] = N_("\
@@ -682,6 +682,7 @@ static struct argp_option options[] = {
{"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 },
{"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 },
{"xz", 'J', 0, 0, NULL, GRID+1 },
{"zstd", ZSTD_OPTION, 0, 0, NULL, GRID+1 },
#undef GRID
#define GRID 100
@@ -974,36 +975,37 @@ stat_on_signal (int signo)
#endif
}
static void
set_stat_signal (const char *name)
int
decode_signal (const char *name)
{
static struct sigtab
{
char const *name;
int signo;
} const sigtab[] = {
{ "SIGUSR1", SIGUSR1 },
{ "USR1", SIGUSR1 },
{ "SIGUSR2", SIGUSR2 },
{ "USR2", SIGUSR2 },
{ "SIGHUP", SIGHUP },
{ "HUP", SIGHUP },
{ "SIGINT", SIGINT },
{ "INT", SIGINT },
{ "SIGQUIT", SIGQUIT },
{ "QUIT", SIGQUIT }
};
struct sigtab const *p;
char const *s = name;
if (strncmp (s, "SIG", 3) == 0)
s += 3;
for (p = sigtab; p < sigtab + sizeof (sigtab) / sizeof (sigtab[0]); p++)
if (strcmp (p->name, name) == 0)
{
stat_on_signal (p->signo);
return;
}
if (strcmp (p->name, s) == 0)
return p->signo;
FATAL_ERROR ((0, 0, _("Unknown signal name: %s"), name));
}
static void
set_stat_signal (const char *name)
{
stat_on_signal (decode_signal (name));
}
struct textual_date
{
@@ -1129,6 +1131,10 @@ tar_help_filter (int key, const char *text, void *input)
s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM);
break;
case ZSTD_OPTION:
s = xasprintf (_("filter the archive through %s"), ZSTD_PROGRAM);
break;
case ARGP_KEY_HELP_EXTRA:
{
const char *tstr;
@@ -1151,7 +1157,7 @@ tar_help_filter (int key, const char *text, void *input)
return s;
}
static char *
static char * _GL_ATTRIBUTE_MALLOC
expand_pax_option (struct tar_args *targs, const char *arg)
{
struct obstack stk;
@@ -1437,8 +1443,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'K':
optloc_save (OC_STARTING_FILE, args->loc);
starting_file_option = true;
addname (arg, 0, true, NULL);
add_starting_file (arg);
break;
case ONE_FILE_SYSTEM_OPTION:
@@ -1650,6 +1655,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
set_use_compress_program_option (COMPRESS_PROGRAM, args->loc);
break;
case ZSTD_OPTION:
set_use_compress_program_option (ZSTD_PROGRAM, args->loc);
break;
case ATIME_PRESERVE_OPTION:
atime_preserve_option =
(arg
@@ -2656,7 +2665,28 @@ decode_options (int argc, char **argv)
report_textual_dates (&args);
}
#ifdef ENABLE_ERROR_PRINT_PROGNAME
/* The error() function from glibc correctly prefixes each message it
prints with program_name as set by set_program_name. However, its
replacement from gnulib, which is linked in on systems where this
function is not available, prints the name returned by getprogname()
instead. Due to this messages output by tar subprocess (which sets its
program name to 'tar (child)') become indiscernible from those printed
by the main process. In particular, this breaks the remfiles01.at and
remfiles02.at test cases.
To avoid this, on such systems the following helper function is used
to print proper program name. Its address is assigned to the
error_print_progname variable, which error() then uses instead of
printing getprogname() result.
*/
static void
tar_print_progname (void)
{
fprintf (stderr, "%s: ", program_name);
}
#endif
/* Tar proper. */
@@ -2666,7 +2696,9 @@ main (int argc, char **argv)
{
set_start_time ();
set_program_name (argv[0]);
#ifdef ENABLE_ERROR_PRINT_PROGNAME
error_print_progname = tar_print_progname;
#endif
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);

View File

@@ -1,7 +1,6 @@
/* GNU tar Archive Format description.
Copyright 1988-1989, 1991-1997, 2000-2001, 2003-2007, 2012-2014,
2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,6 +1,5 @@
/* This file is part of GNU tar.
Copyright 2006-2008, 2013-2014, 2016-2017 Free Software Foundation,
Inc.
Copyright 2006-2019 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
@@ -101,7 +100,7 @@ add_segment (struct transform *tf)
}
static void
add_literal_segment (struct transform *tf, char *str, char *end)
add_literal_segment (struct transform *tf, const char *str, const char *end)
{
size_t len = end - str;
if (len)
@@ -273,7 +272,7 @@ parse_transform_expr (const char *expr)
USAGE_ERROR ((0, 0, _("Invalid transform expression: %s"), errbuf));
}
if (str[0] == '^' || str[strlen (str) - 1] == '$')
if (str[0] == '^' || (i > 2 && str[i - 3] == '$'))
tf->transform_type = transform_first;
free (str);
@@ -403,6 +402,7 @@ parse_transform_expr (const char *expr)
cur++;
}
add_literal_segment (tf, beg, cur);
free(str);
return p;
}
@@ -550,7 +550,7 @@ _single_transform_name_to_obstack (struct transform *tf, char *input)
default:
break;
}
/*FALL THROUGH*/
FALLTHROUGH;
case ctl_upcase:
case ctl_locase:

View File

@@ -1,6 +1,6 @@
/* Unlink files.
Copyright 2009, 2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2009-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -127,7 +127,9 @@ flush_deferred_unlinks (bool force)
case EEXIST:
/* OpenSolaris >=10 sets EEXIST instead of ENOTEMPTY
if trying to remove a non-empty directory */
#if defined ENOTEMPTY && ENOTEMPTY != EEXIST
case ENOTEMPTY:
#endif
/* Keep the record in list, in the hope we'll
be able to remove it later */
prev = p;

View File

@@ -1,7 +1,6 @@
/* Update a tar archive.
Copyright 1988, 1992, 1994, 1996-1997, 1999-2001, 2003-2005, 2007,
2010, 2013-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 1988-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -111,7 +110,7 @@ update_archive (void)
name_gather ();
open_archive (ACCESS_UPDATE);
buffer_write_global_xheader ();
xheader_forbid_global ();
while (!found_end)
{

View File

@@ -1,7 +1,6 @@
/* Charset handling for GNU tar.
Copyright 2004, 2006-2007, 2013-2014, 2016-2017 Free Software
Foundation, Inc.
Copyright 2004-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -36,11 +35,14 @@
# define iconv_open(tocode, fromcode) ((iconv_t) -1)
# undef iconv
# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ((size_t) 0)
# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) (errno = ENOSYS, (size_t) -1)
# undef iconv_close
# define iconv_close(cd) 0
# undef iconv_t
# define iconv_t int
#endif
@@ -65,10 +67,9 @@ bool
utf8_convert (bool to_utf, char const *input, char **output)
{
char ICONV_CONST *ib;
char *ob;
char *ob, *ret;
size_t inlen;
size_t outlen;
size_t rc;
iconv_t cd = utf8_init (to_utf);
if (cd == 0)
@@ -81,11 +82,27 @@ utf8_convert (bool to_utf, char const *input, char **output)
inlen = strlen (input) + 1;
outlen = inlen * MB_LEN_MAX + 1;
ob = *output = xmalloc (outlen);
ob = ret = xmalloc (outlen);
ib = (char ICONV_CONST *) input;
rc = iconv (cd, &ib, &inlen, &ob, &outlen);
/* According to POSIX, "if iconv() encounters a character in the input
buffer that is valid, but for which an identical character does not
exist in the target codeset, iconv() shall perform an
implementation-defined conversion on this character." It will "update
the variables pointed to by the arguments to reflect the extent of the
conversion and return the number of non-identical conversions performed".
On error, it returns -1.
In other words, non-zero return always indicates failure, either because
the input was not fully converted, or because it was converted in a
non-reversible way.
*/
if (iconv (cd, &ib, &inlen, &ob, &outlen) != 0)
{
free (ret);
return false;
}
*ob = 0;
return rc != -1;
*output = ret;
return true;
}

View File

@@ -1,6 +1,6 @@
/* Warnings for GNU tar.
Copyright 2009, 2012-2014, 2016-2017 Free Software Foundation, Inc.
Copyright 2009-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,6 +1,6 @@
/* Support for extended attributes.
Copyright (C) 2006-2014, 2016-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -246,13 +246,36 @@ xattrs__acls_set (struct tar_stat_info const *st,
acl_free (acl);
}
/* Cleanup textual representation of the ACL in VAL by eliminating tab
characters and comments */
static void
xattrs_acls_cleanup (char *val, size_t *plen)
{
char *p, *q;
p = q = val + strcspn (val, "#\t");
while (*q)
{
if (*q == '\t')
q++;
else if (*q == '#')
{
while (*q != '\n')
q++;
}
else
*p++ = *q++;
}
*plen = p - val;
*p++ = 0;
}
static void
xattrs__acls_get_a (int parentfd, const char *file_name,
struct tar_stat_info *st,
char **ret_ptr, size_t * ret_len)
{
char *val = NULL;
ssize_t len;
acl_t acl;
if (!(acl = acl_get_file_at (parentfd, file_name, ACL_TYPE_ACCESS)))
@@ -262,7 +285,7 @@ xattrs__acls_get_a (int parentfd, const char *file_name,
return;
}
val = acl_to_text (acl, &len);
val = acl_to_text (acl, NULL);
acl_free (acl);
if (!val)
@@ -272,8 +295,7 @@ xattrs__acls_get_a (int parentfd, const char *file_name,
}
*ret_ptr = xstrdup (val);
*ret_len = len;
xattrs_acls_cleanup (*ret_ptr, ret_len);
acl_free (val);
}
@@ -284,7 +306,6 @@ xattrs__acls_get_d (int parentfd, char const *file_name,
char **ret_ptr, size_t * ret_len)
{
char *val = NULL;
ssize_t len;
acl_t acl;
if (!(acl = acl_get_file_at (parentfd, file_name, ACL_TYPE_DEFAULT)))
@@ -294,7 +315,7 @@ xattrs__acls_get_d (int parentfd, char const *file_name,
return;
}
val = acl_to_text (acl, &len);
val = acl_to_text (acl, NULL);
acl_free (acl);
if (!val)
@@ -304,8 +325,7 @@ xattrs__acls_get_d (int parentfd, char const *file_name,
}
*ret_ptr = xstrdup (val);
*ret_len = len;
xattrs_acls_cleanup (*ret_ptr, ret_len);
acl_free (val);
}
#endif /* HAVE_POSIX_ACLS */
@@ -336,6 +356,7 @@ acls_one_line (const char *prefix, char delim,
obstack_grow (&stk, prefix, pref_len);
obstack_grow (&stk, aclstring, move);
pos += move + 1;
aclstring += move + 1;
}
@@ -740,6 +761,8 @@ xattrs_print (struct tar_stat_info const *st)
{
fprintf (stdlis, " a: ");
acls_one_line ("", ',', st->acls_a_ptr, st->acls_a_len);
if (st->acls_a_len && st->acls_d_len)
fprintf (stdlis, ",");
acls_one_line ("default:", ',', st->acls_d_ptr, st->acls_d_len);
fprintf (stdlis, "\n");
}

View File

@@ -1,6 +1,6 @@
/* Support for extended attributes.
Copyright (C) 2006-2014, 2016-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2019 Free Software Foundation, Inc.
This file is part of GNU tar.

View File

@@ -1,7 +1,6 @@
/* POSIX extended headers for tar.
Copyright (C) 2003-2007, 2009-2010, 2012-2014, 2016-2017 Free
Software Foundation, Inc.
Copyright (C) 2003-2019 Free Software Foundation, Inc.
This file is part of GNU tar.
@@ -185,6 +184,9 @@ xheader_set_keyword_equal (char *kw, char *eq)
bool global = true;
char *p = eq;
if (eq == kw)
USAGE_ERROR ((0, 0, _("Malformed pax option: %s"), quote (kw)));
if (eq[-1] == ':')
{
p--;
@@ -255,7 +257,7 @@ char *
xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
{
char *buf;
size_t len = strlen (fmt);
size_t len;
char *q;
const char *p;
char *dirp = NULL;
@@ -266,43 +268,51 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
char nbuf[UINTMAX_STRSIZE_BOUND];
char const *nptr = NULL;
for (p = fmt; *p && (p = strchr (p, '%')); )
len = 0;
for (p = fmt; *p; p++)
{
switch (p[1])
if (*p == '%' && p[1])
{
case '%':
len--;
break;
case 'd':
if (st)
switch (*++p)
{
if (!dirp)
dirp = dir_name (st->orig_file_name);
dir = safer_name_suffix (dirp, false, absolute_names_option);
len += strlen (dir) - 2;
case '%':
len++;
break;
case 'd':
if (st)
{
if (!dirp)
dirp = dir_name (st->orig_file_name);
dir = safer_name_suffix (dirp, false, absolute_names_option);
len += strlen (dir);
}
break;
case 'f':
if (st)
{
base = last_component (st->orig_file_name);
len += strlen (base);
}
break;
case 'p':
pptr = umaxtostr (getpid (), pidbuf);
len += pidbuf + sizeof pidbuf - 1 - pptr;
break;
case 'n':
nptr = umaxtostr (n, nbuf);
len += nbuf + sizeof nbuf - 1 - nptr;
break;
default:
len += 2;
}
break;
case 'f':
if (st)
{
base = last_component (st->orig_file_name);
len += strlen (base) - 2;
}
break;
case 'p':
pptr = umaxtostr (getpid (), pidbuf);
len += pidbuf + sizeof pidbuf - 1 - pptr - 2;
break;
case 'n':
nptr = umaxtostr (n, nbuf);
len += nbuf + sizeof nbuf - 1 - nptr - 2;
break;
}
p++;
else
len++;
}
buf = xmalloc (len + 1);
@@ -458,6 +468,14 @@ xheader_write_global (struct xheader *xhdr)
}
}
/* Forbid modifications of the global extended header */
void
xheader_forbid_global (void)
{
if (keyword_global_override_list)
USAGE_ERROR ((0, 0, _("can't update global extended header record")));
}
void
xheader_xattr_init (struct tar_stat_info *st)
{

1
tests/.gitignore vendored
View File

@@ -12,3 +12,4 @@ download
ttyemu
checkseekhole
ckmtime
/compress-*.at

View File

@@ -1,6 +1,6 @@
# Makefile for GNU tar regression tests.
# Copyright 1996-1997, 1999-2001, 2003-2007, 2009, 2012-2015 Free Software
# Copyright 1996-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.
@@ -17,9 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 star/README star/quicktest.sh
EXTRA_DIST = $(TESTSUITE_AT) \
testsuite package.m4 star/README star/quicktest.sh \
compress.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
CLEANFILES =
## ------------ ##
## package.m4. ##
@@ -43,6 +47,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
TESTSUITE_AT = \
testsuite.at\
compress.m4\
T-cd.at\
T-dir00.at\
T-dir01.at\
@@ -66,6 +71,11 @@ TESTSUITE_AT = \
chtype.at\
comprec.at\
comperr.at\
checkpoint/defaults.at\
checkpoint/interval.at\
checkpoint/dot.at\
checkpoint/dot-compat.at\
checkpoint/dot-int.at\
delete01.at\
delete02.at\
delete03.at\
@@ -228,6 +238,9 @@ TESTSUITE_AT = \
spmvp00.at\
spmvp01.at\
spmvp10.at\
sptrcreat.at\
sptrdiff00.at\
sptrdiff01.at\
time01.at\
time02.at\
truncate.at\

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2014-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2014-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2006-2007, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2006-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#
@@ -29,9 +29,8 @@ AT_KEYWORDS([files-from nonewline nonl T-nonl])
AT_TAR_CHECK([
genfile --length=0 --file empty
AS_ECHO_N(c) > 1.nonl
echo d > 2.nonl
AS_ECHO_N(e) >> 2.nonl
printf c > 1.nonl
printf 'd\ne' > 2.nonl
touch a b c d e
AT_DATA([filelist],[a
b
@@ -59,4 +58,3 @@ c
[],[],[],[ustar])
AT_CLEANUP

View File

@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2006-2007, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2006-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,5 +1,5 @@
# This file is part of test suite for GNU tar. -*- Autotest -*-
# Copyright 2015-2017 Free Software Foundation, Inc.
# Copyright 2015-2019 Free Software Foundation, Inc.
#
# 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

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2015-2017 Free Software Foundation, Inc.
# Copyright 2015-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2011, 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2011-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2011, 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2011-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2016-2017 Free Software Foundation, Inc.
# Copyright 2016-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

View File

@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2004, 2006-2007, 2013-2014, 2016-2017 Free Software
# Foundation, Inc.
# Copyright 2004-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2005-2007, 2013-2014, 2016-2017 Free Software Foundation,
# Inc.
# Copyright 2005-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2006-2007, 2009, 2013-2014, 2016-2017 Free Software
# Foundation, Inc.
# Copyright 2006-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2010, 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2010-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
#
# Test suite for GNU tar.
# Copyright 2013-2014, 2016-2017 Free Software Foundation, Inc.
# Copyright 2013-2019 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#

Some files were not shown because too many files have changed in this diff Show More