Commit Graph

247 Commits

Author SHA1 Message Date
Tim Kientzle
2cac97cafe Fix an aliasing error in the new TP support and reenable it in the build. 2006-01-26 05:28:56 +00:00
Tim Kientzle
d9286f602a Disable "tp" support until I figure out why it's breaking the build. <sigh> 2006-01-18 06:26:42 +00:00
Tim Kientzle
752ede3058 If the attempt to open the archive fails (either the client open
routine fails or the first read fails), invoke the client close
routine immediately so the client can clean up.  Also, don't store the
client pointers in this case, so that the client close routine can't
accidentally get called more than once.

A minor style fix to archive_read_open_fd.c while I'm here.

PR: 86453
Thanks to: Andrew Turner for reporting this and suggesting a fix.
2006-01-17 04:49:04 +00:00
Tim Kientzle
bbf3318c61 Add support for "tp" format. tp was the standard system
archiver for Fourth Edition through Sixth Edition Unix; it was
replaced by tar in Seventh Edition.  (First Edition through
Third Edition used "tap.")

Unfortunately, tp was not so very standard; there were a
few different variants.  The code here attempts to support
what I believe were the most common variants.

tp support is not yet enabled by archive_read_support_format_all(),
as I'm not yet entirely comfortable with the detection
heuristics.  People interested in experimenting can
add archive_read_support_format_tp() just after any calls
to archive_read_support_format_all() in bsdtar to see how
well this works.

TODO: tp format is roughly similar in structure to dump/restore
   archive formats used by many systems.  It should be possible
   to generalize this code to handle many dump/restore variants.
   Format detection heuristics are going to be rough, though.

Thanks to: Warren Toomey, whose very basic tp extraction programs
   and documentation made this possible.
2006-01-17 03:40:42 +00:00
Ruslan Ermilov
a5b0d9050a [mdoc] add missing space before a punctuation type argument. 2005-12-13 17:07:52 +00:00
Tim Kientzle
55be5837f8 Portability: Remove AC_CHECK_MALLOC from configure.ac.in.
libarchive doesn't make malloc(0) requests, so the autoconf
checks aren't needed and the autoconf workarounds for
broken malloc(0) just create problems.

Thanks to: Dan Nelson, who reports that this fixes libarchive on AIX 5.2
2005-11-27 03:16:46 +00:00
Ruslan Ermilov
de599f05ea Fix prototypes. 2005-11-24 10:06:05 +00:00
Ruslan Ermilov
110e1704d3 -mdoc sweep. 2005-11-17 13:00:00 +00:00
Ruslan Ermilov
e4a93f1ef8 Add missing shared library interdependencies. 2005-11-10 18:07:07 +00:00
Tim Kientzle
6487f671b6 Bump the maximum number of archive formats that can be
enabled at one time from 4 to 8.
2005-11-08 07:44:39 +00:00
Tim Kientzle
f0e9186bf9 Correctly clean up if gzip format gets mis-identified as compress format.
(This can only happen in the pathalogical case where the client is
providing single-byte blocks.)
2005-11-08 07:42:42 +00:00
Tim Kientzle
a46c33df05 Fine-tune the format detection for CPIO and ISO9660 sub-types.
This has no impact on the actual operation, it just fixes some
inaccuracies in the format code and description reported back to the caller.
2005-11-08 07:41:03 +00:00
Tim Kientzle
3bdc359ffe Portability: Use some autoconf magic to include the
correct headers for major()/minor()/makedev() on various
platforms.

Thanks to: Darin Broady
2005-11-08 03:52:42 +00:00
Tim Kientzle
a4fd64c861 Portability: timegm() isn't standard, so check for timegm() in
the configure script and substitute mktime() when necessary.

Thanks to:  Darin Broady
2005-11-06 23:38:01 +00:00
Tim Kientzle
2d0d7187c0 Fix installworld breakage. <sigh>
expr and printf are not available during installworld, so
use /bin/sh arithmetic expansion instead of expr and simply
give up on vanity formatting. ;-)
2005-10-14 16:32:50 +00:00
Tim Kientzle
db38abe649 1) Use GNU libtool to build shared libraries on non-FreeBSD
systems (or on FreeBSD systems when using ports).

2) Overhaul the versioning logic.  In particular,
   SHLIB_MAJOR number is now computed as "major+minor",
   which ensures library versions are the same for
   the FreeBSD build system and the portable
   libtool/autoconf/automake build system.
2005-10-13 05:51:38 +00:00
Tim Kientzle
7fb8511e34 Make some purely internal symbols static to reduce link pollution. 2005-10-12 15:38:45 +00:00
Tim Kientzle
f230dd9adb Minor style nit: tab instead of space after #define 2005-10-12 03:28:38 +00:00
Tim Kientzle
a3c4173bb8 When reading GNU-style sparse archive entries, handle
the first sparse block correctly (we used to assume
that the first sparse block was always at offset zero).
2005-10-12 03:27:46 +00:00
Tim Kientzle
52a88d3b57 In pax interchange format, use UTF8 for writing
link names, usernames, or group names that contain
non-ASCII characters.

In particular, this corrects an inconsistency reported
by Ed Maste when archiving symlinks with odd characters:
long symlinks would get preserved, short ones would
be changed.
2005-10-12 03:26:09 +00:00
Tim Kientzle
c4e21983bc signed/unsigned fixes (thanks to GCC4) and a few related minor style corrections. 2005-09-24 21:15:00 +00:00
Tim Kientzle
3be7274eed In archive_read_open(), do not set the internal archive state to
"HEADER" unless the open is successful.  Instead, leave the state as
"NEW."  In particular, if archive_read_open() fails, a subsequent call
to archive_read_next_header() will now cause an explicit assertion
failure instead of a silent segmentation fault.

This may need a little more work to fully realize the intention: If
archive_read_open() fails, you should be able to call it again on the
same archive handle to open a different archive (or the same archive
using a different mechanism).
2005-09-21 04:48:52 +00:00
Tim Kientzle
8aaa8fe733 Add a lot of error checks, based on the patches provided by Dan Lukes.
Also fixes a memory leak reported by Andrew Turner.

PR: bin/83476
Thanks to: Dan Lukes, Andrew Turner
2005-09-21 04:25:06 +00:00
Tim Kientzle
818898d384 Correct the documentation for archive_read_data_into_buffer()
Thanks to: Marcus Alves Grando
PR: docs/85854
MFC after: 7 days
2005-09-20 17:48:57 +00:00
Tim Kientzle
1dd0aa0c18 Style issue: Don't include <wchar.h> where it is not actually needed.
(wchar_t is defined in stddef.h, and only two files need more than that.)

Portability:  Since the wchar requirements are really quite modest,
it's easy to define basic replacements for wcslen, wcscmp, wcscpy,
etc, for use on systems that lack <wchar.h>.  In particular, this allows
libarchive to be used on older OpenBSD systems.
2005-09-10 22:58:06 +00:00
Tim Kientzle
9b98b2d5d1 Fix some errors in archive_read_data that caused failures in bsdtar's
pass-through filtering.

Thanks to: Bjoern Koenigönig
PR: bin/82878
2005-09-10 18:05:54 +00:00
Yaroslav Tykhiy
628bcb899b Fix fallout from the previous commit:
We shouldn't call chmod() if we've just used
fchmod() OK on the same file.

Approved by:	kientzle
2005-09-09 19:02:03 +00:00
Tim Kientzle
731f6a1690 Terminate metadata restore early only on failure, not success.
In particular, this bug was preventing the restore of fflags.
2005-09-05 10:23:55 +00:00
Tim Kientzle
44938dbf6d Record an error message if there are write errors when extracting the
content of an archive entry to a file descriptor.
2005-08-10 15:02:53 +00:00
Tim Kientzle
4b9adc2fef Minor configuration fix to disable ACL support on MacOS X (which
lacks ACL_USER).

Thanks to:  Marcus Geiger, Joe Esch, and Markus Slopianka
2005-08-10 15:01:03 +00:00
Tim Kientzle
01122e2ae0 Generate default fake "device" and "inode" numbers for entries
extracted from tar archives.  Otherwise, converting tar archives to
cpio format (with "bsdtar -cf out.cpio @in.tar") convert every entry
into a hard link to a single file.  This simple logic breaks hard
links, but that's better than the alternative.

MFC after: 7 days
2005-08-02 03:17:57 +00:00
Tim Kientzle
0f61624bd1 When copying time values from the main entry header to be used in the
header of the pax extension entry, clip them to ustar limits.  In particular,
this prevents an internal panic for very old files.

Thanks to: Chris Spiegel
MFC after: 7 days
2005-08-02 03:13:42 +00:00
Tim Kientzle
a2e467d35a Correct a few minor mis-statements (libarchive does support reading
GNU tar sparse files, people have extended cpio) and clarify an
important detail about pax format (that ustar-compliant archivers
can mostly read pax archives correctly).

MFC after: 7 days
2005-08-02 03:10:52 +00:00
Giorgos Keramidas
6fb9b618f5 Fix all the spelling mistakes I could find in the man pages for words
that have at least 3 characters.

MFC after:	1 week
Thanks to:	Music band ``Chingon''
		for keeping me company while searching for these.
2005-07-31 03:30:48 +00:00
Ken Smith
a84020c2b9 Bump the shared library version number of all libraries that have not
been bumped since RELENG_5.

Reviewed by:	ru
Approved by:	re (not needed for commit check but in principle...)
2005-07-22 17:19:05 +00:00
Ruslan Ermilov
f789cb8293 Assorted markup fixes.
Approved by:	re
2005-06-15 19:04:04 +00:00
Tim Kientzle
495b0c0d52 Minor clean up for flags restoration: Use fchflags/lchflags when
available, stub out flags restore on platforms that don't support it,
update autoconf to probe for fchflags and lchflags support.
2005-06-04 22:30:36 +00:00
Tim Kientzle
48864d8c25 Sort archive_entry_ctime/archive_entry_ctime_nsec correctly. 2005-06-04 22:26:23 +00:00
Tim Kientzle
f87c3529a8 Support libarchive with C++ by adding appropriate conditional
extern "C" declarations.
2005-06-04 22:24:04 +00:00
Tim Kientzle
43b1ef9bc2 Fix one error in the example usage of the archive_write API and fill
in a few missing details.  The example code here is now a complete,
functioning example program.
2005-06-04 22:19:25 +00:00
Scott Long
e462283052 Provide missing implementations for archive_entry_ctime() and
archive_entry_ctime_nano()
2005-06-01 18:20:02 +00:00
Tim Kientzle
0f412b97da Remove the C99-specific __func__ that is one of the few barrier to
compiling on IRIX and Solaris.  Remove the "archive_check_magic" macro
that existed only to provide __func__ to the underlying __archive_check_magic
function.

Thanks to: Darin Broady
MFC after: 14 days
2005-06-01 15:52:39 +00:00
Tim Kientzle
f65d1d5147 <Ooops> Two lines got dropped from the previous commit. Apologies.
MFC after: 14 days
2005-06-01 15:46:47 +00:00
Tim Kientzle
3a2a859dd4 A minor refinement to "pax" output: Remove suid/sgid/sticky bits
from mode before using mode for extended attributes entry, copy
mtime/atime/ctime to extended attributes entry so it's a little more
clear that it corresponds to the like-named regular entry.

MFC after: 14 days
2005-06-01 15:44:23 +00:00
Tim Kientzle
b33c1067f8 Start to address the race issue between restoring a file's contents
and restoring the metadata.  In particular, the metadata-restore
functions now all accept a file descriptor and a pathname.  If the
file descriptor is set and the platform supports the appropriate
syscall, restore the metadata through the file descriptor.  Otherwise,
restore it through the pathname.  This is complicated by varying
syscall support (FreeBSD has an fchmod(2) but no fchflags(2), for
example) and because non-file entries don't have an fd to use in
restoring attributes (for example, mknod(2) doesn't return a file
handle).

MFC after: 14 days
2005-05-21 19:45:56 +00:00
Tim Kientzle
21805f33bf Correct return values in myopen() and myclose() in Example code.
Bug: docs/79318
Thanks to: Derek Tattersall
MFC after: 7 days
2005-05-21 19:38:19 +00:00
Tim Kientzle
0e35a97bf9 archive_entry_set_link is supposed to update whichever link field
(symlink or hardlink) is already set.  Instead, it was always setting
the hardlink field.  In particular, this caused GNU tar format long
symlinks to be interpreted as hardlinks.

Thanks to: Brooks Davis
MFC after: 7 days
2005-05-08 19:10:41 +00:00
Tim Kientzle
8d8311c95f Fix broken ACL configuration on FreeBSD 4 and Linux.
Thanks to: Greg Lewis, Juergen Lock, Jaakko Heinonen for reporting and testing
2005-04-23 17:56:34 +00:00
Tim Kientzle
256543d9b1 Certain filenames between 245 and 255 characters long would cause an
internal error if pax extended attributes were being generated.  Being
< 255 characters, the first-pass path editing (to generate a
ustar-compatible name for the main entry) wouldn't occur, and the
second-pass path editing (to generate a ustar name for the pax
attributes entry) assumed the input was already < 245 chars.

The core problem here was using an abbreviated algorithm for the
second pass that relied on the first pass having already run.  The
rewritten code is much simpler: It just uses the full path-shortening
algorithm for building both ustar pathnames.  This way, the second
ustar pathname will always be short enough.

Thanks to: Mark Cammidge
Related to: bin/74385
2005-04-23 17:46:51 +00:00
Tim Kientzle
48a54ddbd0 Portability enhancement: MS Windows won't restore metadata if the file
is still open, so close the file as soon as we've written the
file contents, before we attempt to restore metadata.

Thanks to:  Kees Zeelenberg
2005-04-17 22:49:00 +00:00