Commit Graph

294 Commits

Author SHA1 Message Date
Tim Kientzle
79cf3de423 Make -lcrypto usage dependent on whether or not we're building with OpenSSL. 2009-04-18 06:03:09 +00:00
Tim Kientzle
5191e7b552 Merge remaining changes from libarchive.googlecode.com:
* Add xz and lzma compression options
 * Rename --format-options to simply --options
 * Add --same-owner for GNU tar compat
 * Add -lmd and -lcrypto to fix link
 * Documentation
2009-04-17 03:45:15 +00:00
Tim Kientzle
4e350e9d6b Set options before opening the archive.
Catch and report close-time errors.
2009-04-17 03:40:40 +00:00
Tim Kientzle
6ffa10bc90 Minor portability improvement in calls to ctype.h macros. 2009-04-17 03:37:09 +00:00
Tim Kientzle
c7e120041d Merge from libarchive.googlecode.com: Numerous Windows-specific build tweaks. 2009-04-17 03:36:07 +00:00
Tim Kientzle
05fa9d9f25 Update version to 2.6.901a to indicate this is synced up with r745 of
libarchive.googlecode.com (except for the lzma/xz support).
2009-03-08 06:20:35 +00:00
Tim Kientzle
abe5b073f4 Merge r492 from libarchive.googlecode.com: First cut at exposing the
new options mechanism to userland.  Documentation pending...
2009-03-08 06:19:28 +00:00
Tim Kientzle
ebf7581e4d Match a comment to reduce differences with libarchive.googlecode.com. 2009-03-08 06:09:20 +00:00
Tim Kientzle
66c8431841 Merge r709,r710 from libarchive.googlecode.com: More work on
Windows support.
2009-03-08 06:07:35 +00:00
Tim Kientzle
ac90bcdea0 Merge r687-689,691,693-701,720 from libarchive.googlecode.com:
Translate getdate.y into C for portability.  Make the get_date()
function easier to test as well:
 * Have it accept a time_t "now" to use as a reference so that test
   code can verify relative time specifications against known starting
   points.
 * Set up default date after parsing the string so that we
   can use the specified timezone (if any) instead of the local
   default.  Otherwise, local DST makes it almost impossible to
   reliably test time specifications such as "sunday UTC"
2009-03-08 06:03:15 +00:00
Tim Kientzle
74d5acaf4c Merger r629-631,633-646,648,654,678,681,682 from libarchive.googlecode.com:
Many changes for Windows compatibility.  bsdtar_test now runs successfully
on both POSIX platforms and Windows.
2009-03-08 05:47:21 +00:00
Tim Kientzle
503c6aa1ca Merge r368,496,625,626 from libarchive.googlecode.com: A number of
style and portability tweaks to the test harness.  Most significantly,
don't use getopt().
2009-03-08 05:38:45 +00:00
Tim Kientzle
97c382f46b Merge r622 from libarchive.googlecode.com: Avoid warning on platforms
that lack regex.h.
2009-03-08 05:35:59 +00:00
Tim Kientzle
a16b186182 Merge r552,r559 from libarchive.googlecode.com: High-resolution time
support on Tru64, AIX, and GNU Hurd, thanks to Björn Jacke.
2009-03-08 05:34:20 +00:00
Tim Kientzle
709693c65a Merge r529 from libarchive.googlecode.com: Fix how we read ext2fs_fs.h
headers on Linux.
2009-03-08 05:28:52 +00:00
Tim Kientzle
88b0df8855 Merge r435,r443 from libarchive.googlecode.com: Let the compiler options
determine how to read config.h.
2009-03-08 05:24:37 +00:00
Tim Kientzle
3ae673ed49 Merge r283,r423 from libarchive.googlecode.com: Use libarchive's new
archive_read_disk API to pull metadata off of disk.  This
removes a lot of platform-specific knowledge of things like
ACLs, file flags, and extended attributes from bsdtar.
2009-03-08 05:22:50 +00:00
Tim Kientzle
e8f0b45249 Merge r374 from libarchive.googlecode.com: Stupid typo in open() call. <sigh> 2009-03-08 05:19:36 +00:00
Tim Kientzle
c9dae218f2 Merge r369 from libarchive.googlecode.com: Test -s option. 2009-03-08 05:17:58 +00:00
Tim Kientzle
5ff33ec7ae Merge r278 from libarchive.googlecode.com: Reduce the number of
patterns tested here from 200 to 170, which seems to be the
most that Cygwin can handle.
2009-03-08 05:14:16 +00:00
Tim Kientzle
7bae205d49 Merge r273 from libarchive.googlecode.com: Use open() correctly. 2009-03-08 05:10:51 +00:00
Tim Kientzle
f64d4bd0f7 Fix multiple -s options.
MFC after:	7 days
2009-02-08 22:04:17 +00:00
Tim Kientzle
ec9d8e0b01 When copying file data to the archive, don't write more
than was read.  This seems to have only affected the shar
writer, since other formats proactively truncate output
to the originally-advertised size.

PR:		bin/131244
MFC after:	7 days
2009-02-08 22:02:46 +00:00
Tim Kientzle
5d42c42369 Spell "substitution" correctly.
PR:		bin/128616
Submitted by:	Jaakko Heinonen
Pointy hat:	Tim Kientzle
MFC after:	30 days
2008-12-15 06:00:25 +00:00
Tim Kientzle
2c2029ada9 bsdtar is synced up with 2.5.903a 2008-12-06 07:38:14 +00:00
Tim Kientzle
286e81aeb0 bsdtar always supports long options now, so we can remove
a documentation disclaimer.
2008-12-06 07:37:55 +00:00
Tim Kientzle
d47cf339f4 Only use GCC-specific __dead2 marker when building with GCC. 2008-12-06 07:37:14 +00:00
Tim Kientzle
5af3583731 When deciding which characters (of a filename, for instance)
are safe to print, try to take into account the current locale.
This iterates over output strings using mbtowc() to identify
multi-byte sequences.  If iswprint() claims the corresponding
wide character is printable, the original bytes are passed
through.  Otherwise, we expand characters into C-style
\-escape sequences.

Submitted by:	Michihiro NAKAJIMA
MFC after:	30 days
2008-11-29 20:06:53 +00:00
Tim Kientzle
2f01c75815 After visiting a subdirectory, we use chdir("..") or
fchdir() to return back to the parent.  If those fail,
we're just dead in the water.  Add a new error value
TREE_ERROR_FATAL to indicate that directory traversal
cannot continue.  Have write.c honor that by exiting
immediately.

MFC after:	30 days
2008-11-27 05:49:52 +00:00
Tim Kientzle
e4504a7d06 If we're unable to chdir() to a directory that we know exists,
that should result in a non-zero return value.

In particular, this should address the issue that David Wolfskill
ran into with a somewhat flaky NFS mount resulting in a damaged
archive even though tar returned success.

MFC after:	4 days
2008-11-27 05:14:36 +00:00
Tim Kientzle
8666079cdb Include more detailed explanation of this case, since it's pretty
subtle why it comes out the way it does.  Once you realize that it
depends on the archiving order, it's also important to realize that
filesystem differences aren't going to break this case.  (Some of the
other tests have had to be extensively rewritten to make them
independent of the order in which a particular filesystem returns file
entries.)

(This commit also serves to note the PR number that I accidentally
omitted from the previous commit.)

PR:		bin/128562
MFC after:	30 days
2008-11-10 05:24:13 +00:00
Tim Kientzle
c4a52c7226 Test --strip-components and fix it to actually work. Jaakko did a
good job writing this test; it exercises a lot of subtle cases.  The
trickiest one is that a hardlink to something that didn't get
extracted should not itself be extracted.  In some sense, this is not
the desired behavior (we'd rather restore the file), but it's the best
you can do in a single-pass restore of a tar archive.

The test here should be extended to exercise cpio and newc formats as
well, since their hardlink models are different, which will lead to
different handling of some of these edge cases.

Submitted by:	Jaakko Heinonen
MFC after:	30 days
2008-11-10 05:04:55 +00:00
Tim Kientzle
85ae3122e9 New command-line parser for bsdtar.
This replaces the getopt()/getopt_long() wrapper, the old-style
argument rewriter and the associated configuration glue with a more
straightforward custom command parser.  In particular, this ensures
that bsdtar will have consistent option parsing on every platform,
regardless of whether the platform supports getopt_long().

MFC after:	30 days
2008-11-08 04:43:24 +00:00
Tim Kientzle
025b20f6e5 When comparing, cast to the larger size, off_t in this case.
Once we know which one is smaller, then we cast to the smaller size.

Thanks to Xin Li (delphij@)
Pointy hat: /me
2008-11-05 06:40:53 +00:00
Tim Kientzle
f4e24c4e7a Fix compile warnings building on amd64. This is modified slightly
from Jaakko's original patch: I have misgivings about the portability
of the 'z' printf modifier so opted to cast the arguments to (int)
instead.

PR:		bin/128561
Submitted by:	Jaakko Heinonen
MFC after:	30 days
2008-11-05 05:26:11 +00:00
Tim Kientzle
8cd2f9bcd0 Clean up flags support just a tad: FreeBSD support depends on
HAVE_STRUCT_STAT_ST_FLAGS, Linux support depends on the
existence of the appropriate ioctl() options.  In particular,
this should fix some nagging compile errors on Linux platforms
that don't have e2fsprogs-devel installed.
2008-09-14 03:49:00 +00:00
Tim Kientzle
1756b590c9 Test handling of restores relative to symlinks.
In particular:
  * tar -x -P follows symlinks to existing dirs, but not without -P
  * symlinks to files are always replaced
  * broken symlinks are always replaced
2008-09-14 02:16:04 +00:00
Tim Kientzle
83cb61fa3a Minor cleanup of the -q test: Assert that stdout/stderr are empty for each
extraction.
2008-08-22 01:35:08 +00:00
Tim Kientzle
ca926f6fbd Don't clean before running tests. 2008-08-22 01:31:13 +00:00
Tim Kientzle
ba1a633912 Explain how the test_option_q test works. 2008-08-22 01:26:55 +00:00
Tim Kientzle
3873424684 Test for -q (aka --fast-read).
Fix the error uncovered by this test.
2008-08-22 01:22:55 +00:00
Tim Kientzle
b1feec2392 The results for test 2 here are short enough to just be included inline.
There's no need to go through the hassle of having a checked-in uuencoded
reference file for comparison.
2008-08-21 22:28:00 +00:00
Tim Kientzle
503b743566 Add some more tests to verify that "./foo" matches "foo" but "/foo" does not. 2008-08-21 07:04:57 +00:00
Tim Kientzle
e0e53b4111 Always display the unedited pathname in -t output.
I would like to provide a way to preview the effects of pathname edits,
but pattern selection has to happen against the unedited path, so it
seems that we have to show people the unedited path to help in
designing selection patterns.
2008-08-21 06:41:14 +00:00
Tim Kientzle
b14f19cf97 Better comment the pattern tests; adjust the filenames for the
reference files to match the corresponding source.

MFC after:	3 days
2008-08-20 06:01:53 +00:00
Tim Kientzle
651eea9aa8 Fix SVN r181821 by not using FNM_LEADING_DIR where
it shouldn't be used.
2008-08-18 18:13:40 +00:00
Tim Kientzle
0f4b98311a Strip leading "./" or ".//" from patterns and filenames
so that "./foo" matches "foo" (and vice versa).

This is related to PR bin/119141.

PR:		bin/119141
MFC after:	4 days
2008-08-18 04:58:54 +00:00
Tim Kientzle
ac2dcb729f Don't strip a leading '/' from a pattern to be matched.
This aligns the pattern-matching behavior with GNU tar
and restores the behavior of bsdtar prior to FreeBSD 6.3.

PR:		bin/117909
MFC after:	3 days
2008-08-17 19:43:45 +00:00
Tim Kientzle
8eccad56d9 Test updates: Handling of patterns on command line, error messages. 2008-08-15 06:12:02 +00:00
Colin Percival
f9bcf9cabf Mark functions as __dead2 in order to help the LLVM static checker
understand which code paths aren't possible.

This commit eliminates 117 false positive bug reports of the form
"allocate memory; error out if pointer is NULL; use pointer".
2008-08-04 01:25:48 +00:00