Commit Graph

130 Commits

Author SHA1 Message Date
David E. O'Brien
731239920f Build as a shared lib again.
Discussed with:	kientzle
2004-10-11 22:04:05 +00:00
Tim Kientzle
d6970563b6 Fix two ugly errors:
1. The correct cutoff for large uid/gid handling is 1<<18, not 1<<20.
2. Limit the uid/gid in the 'x' extension header (where numeric extensions
are not permitted) to 1<<18, but use the correct value in the regular
header (where numeric extensions are permitted).
Thanks to: Dan Nelson
MFC after: 3 days
2004-09-17 04:39:07 +00:00
Tim Kientzle
8a95c5cb6e Some old tar archives rely on "regular-file-plus-trailing-slash" to
denote a directory.  Unfortunately, in the presence of GNU or POSIX
extensions, this code was checking the truncated filename stored in the
regular header rather than the full filename stored in the extended
attribute.  As a result, long filenames with '/' in just the right
position would trigger this check and be erroneously marked as
directories.  Move the check so it only considers the full filename.
Note: the check can't simply be disabled for archives that contain
these extensions because there are some very broken archivers out
there.

Thanks to: Will Froning
MFC after: 3 days
2004-09-04 21:49:42 +00:00
Tim Kientzle
00ccc351f8 Per Ruslan, bsd.lib.mk already has support for dynamically-generated
.h files.  This simplifies the Makefile here a bit and makes it behave
better in a couple of situations.  While I'm here, clean up some comments
and try to improve the organization a bit.

Thanks to: Ruslan Ermilov (The Marvelous Makefile Guru)
2004-09-01 05:06:42 +00:00
Tim Kientzle
db9e0127da Cache uid-from-uname and gid-from-gname lookups during extraction.
This should provide a big performance boost for folks using NIS or LDAP.

MFC after: 3 days
Thanks to: Jun Kuriyama (for reminding me that this was still on my TODO list)
2004-08-27 03:40:48 +00:00
Tim Kientzle
2522fe6764 Don't edit permissions of pre-existing directories during extract.
This closes a security hole.  Otherwise, libarchive will happily
extract into directories to which it lacks write permissions by
resetting the permissions during the extract.

Thanks to: Kris Kennaway
2004-08-26 03:53:43 +00:00
Tim Kientzle
c85db499ac It is not legal to re-use a va_list variable. This caused
a crash on amd64, in particular.

Thanks to: Sean McNeil
2004-08-26 03:33:53 +00:00
Tim Kientzle
57b665990a Eliminate reliance on non-portable <err.h> by implementing a very
simple errx() function.
Improve behavior when bzlib/zlib are missing by detecting and
issuing an error message on attempts to read gzip/bzip2 compressed
archives.
2004-08-14 03:45:45 +00:00
Tim Kientzle
6a0724a89e We don't need <paths.h>, so don't bother including it. 2004-08-14 03:43:35 +00:00
Tim Kientzle
7acae2155e Add archive_entry_set_mtime() 2004-08-08 07:39:19 +00:00
Tim Kientzle
0a36c0e86b Oops. Use "unsigned long" instead of "int" for the intermediate variables
in wide-character conversions, since it's guaranteed to be large enough.
Thanks to: Andrey Chernov
2004-08-08 02:22:48 +00:00
Tim Kientzle
61913b5f21 Use 'int' for certain wide-character conversions instead of wchar_t.
That quiets some compiler warnings on platforms with 16-bit wchar_t.
With this change, libarchive now compiles cleanly on Win32/cygwin.
2004-08-08 01:21:10 +00:00
Tim Kientzle
e33730c3c3 The configure-built Makefile wasn't installing archive.h 2004-08-08 00:48:39 +00:00
Tim Kientzle
e8ec6e32d2 If you don't need a header, don't bother including it. 2004-08-08 00:43:21 +00:00
Tim Kientzle
91ce8f27d8 Split archive_{read,write}_finish into separate "close" (finish the archive
and close it) and "finish" (destroy the object) functions.   For backwards
compat and simplicity, have "finish" invoke "close" transparently if needed.
This allows clients to close the archive and check end-of-operation
statistics before destroying the object.
2004-08-07 19:22:50 +00:00
Tim Kientzle
0cc230af33 Don't forget to count the end-of-file padding as part of the finished
file size.
2004-08-07 19:21:18 +00:00
Tim Kientzle
b2d9ea9fd3 Having implemented read support for it, I now know how to document the
GNU sparse file extension.
2004-08-07 17:24:50 +00:00
Tim Kientzle
659c68935c Correct an mdoc error; add a sentence about tar's ancestors "tp" and "tap." 2004-08-07 17:15:33 +00:00
Tim Kientzle
1e28302160 Fix the calculation of the most negative int64_t value, which
is used on systems that lack C99 headers (such as FreeBSD 4).
2004-08-07 06:38:40 +00:00
Tim Kientzle
bfe891b141 libarchive now has two complete build systems. The usual "Makefile"
is present for FreeBSD.  If you "make distfile" on FreeBSD, you will
soon have a tar.gz file suitable for deploying to other systems
(complete with the expected "configure" script, etc).  This latter
relies (at least for now) on the GNU auto??? tools.  (I like autoconf
okay, but someday I hope to write a custom Makefile.in and dispense
with automake, which is somewhat odious.)

As part of this, I've cleaned up some of the conditional
compilation options, added make-foo to construct archive.h dynamically
(it now contains some version constants), and added some useful
informational files.
2004-08-07 03:09:28 +00:00
Tim Kientzle
501fe26500 Pass the pointy hat, please: Don't blow away the high-order
mode bits when setting permissions from ACL data.
Thanks to: David Gilbert for first reporting this and
    Jimmy Olgeni for noticing that it only occurred on
    ACL-enabled filesystems.
2004-08-07 02:50:05 +00:00
Tim Kientzle
af062c24e6 Beef up the "cannot archive this" error message with the
actual mode that failed, to help track down a bug.
2004-08-07 02:24:20 +00:00
Tim Kientzle
16918868d3 Correct the names and descriptions of the man pages. 2004-08-04 06:19:31 +00:00
Tim Kientzle
da40bbb79e For the "portable" distribution, the configure script will overwrite
"Makefile," so I'm moving all the FreeBSD build machinery to
"Makefile.freebsd", with the default "Makefile" containing a single
include.
2004-08-01 19:30:56 +00:00
Tim Kientzle
b5fda35ca3 C standard does not permit empty initializer list.
Thanks to: Stefan Farfeleder
2004-08-01 19:02:49 +00:00
Tim Kientzle
769756525d Conditionalize the bzip2/gzip compression/decompression
code on the existence of the relevant libraries (actually,
the existence of the include files).

This will allow the library to be easily ported to systems
that don't have these libraries.  (Of course, it also means
that clients using the library on such systems will not be
able to take advantage of the automatic compression format
detection.)
2004-07-30 04:14:47 +00:00
Tim Kientzle
e791a7a913 When writing "pax" format, readers are supposed to ignore fields
in the regular ustar header that are overridden by the pax
extended attributes.  As a result, it makes perfect sense to
use numeric extensions in the regular ustar header so that readers
that don't understand pax extensions but do understand some other
extensions can still get useful information out of it.

This is especially important for filesizes, as the failure to
read a file size correctly can get the reader out of sync.

This commit introduces a "non-strict" option into the internal
function to format a ustar header.  In non-strict mode, the formatter
will use longer octal values (overwriting terminators) or binary
("base-256") values as needed to ensure that large file sizes,
negative mtimes, etc, have the correct values stored in the regular
ustar header.
2004-07-26 02:54:42 +00:00
Tim Kientzle
e5cdebc19e Allow "posix" as a synonym for "pax". (The gtar folks chose "posix",
which is really, really dumb and just going to cause confusion among
people who understand that "ustar" is also a POSIX standard tar format.)
2004-07-25 23:10:38 +00:00
Tim Kientzle
3dd77a04e5 We were forcing a pax extension header for files >= 1G. Set that
cutoff to >= 8G, as it should be.
2004-07-25 18:50:24 +00:00
Tim Kientzle
f5589ef9f4 Minor style nits. 2004-07-24 22:30:35 +00:00
Tim Kientzle
e6787adf79 Rework the feature-detection logic in archive_platform.h so that
it will work cleanly with autoconf.
2004-07-24 20:47:11 +00:00
Tim Kientzle
c02f123ff1 Define the PACKAGE_NAME and PACKAGE_VERSION macros. 2004-07-24 20:45:04 +00:00
Tim Kientzle
c91b82e3e5 Suppress a minor compiler warning if the platform doesn't support hi-res
timestamps.
2004-07-24 20:43:22 +00:00
Tim Kientzle
c48a83413a Add some functions to query basic facts about the library:
archive_version: Returns a text string, e.g., "libarchive 1.00.000"
   archive_api_version: Returns the SHLIB major version
   archive_api_feature: Returns a feature number useful for answering
     questions such as "Is this recent enough to do XXX?"

The last two also have macros defined in archive.h, so you can compare
the compile-time and run-time environments.  (In particular, you can
compare ARCHIVE_API_VERSION to archive_api_version() to detect library
version mismatches.)

With these in hand, it will soon be time to turn on the
shared-library version of libarchive...  stay tuned.
2004-07-24 20:08:26 +00:00
Tim Kientzle
73c891fe79 Use "linux" instead of "LINUX" to control Linux-specific code.
Thanks to: David O'Brien for pointing this out.

Also, add in a few additional portability tweaks and make a few
more things conditional on features (HAVE_XXXX macros) rather
than platform.
2004-07-24 17:50:05 +00:00
Tim Kientzle
45e13f191f Fix the handling of signed values when parsing base-256 header values.
In particular, this means we can now correctly read gtar archives that
contain timestamps prior to the start of the Epoch.

Also, make the code in this area more portable.  ANSI C99 headers are
not yet ubiquitous (for example, FreeBSD 4 still lacks them), so be
prepared for systems that don't have the INT64_MAX, INT64_MIN, and
UINT64_MAX macros.  This version still requires int64_t and uint64_t be
defined (which can be done in archive_platform.h if necessary), but
doesn't require them to be exactly 64 bits.
2004-07-24 17:46:45 +00:00
Tim Kientzle
6a1d1828e7 Style: rename 'mkdirpath' so it's clearer exactly what it does.
(To be precise, it creates the parent dir of the provided path.)
2004-07-15 03:13:27 +00:00
Tim Kientzle
47aa50e155 Update the README notes to include the current list of supported
formats and remove some outdated comments about library limitations.
2004-07-12 01:54:37 +00:00
Tim Kientzle
320adc42ea Correct a brain-o in extract_dir: mkdirpath() and mkdir(2) are
not interchangable.
2004-07-10 18:10:20 +00:00
Tim Kientzle
cbf4203db5 I think this is my fourth complete rewrite of the dir-creation
code. <whew!> This version handles all of the following edge cases:
  * Restoring explicit dirs with 000 permissions (star fails this test)
  * Restore of implicit or explicit dirs when umask=777
    (gtar and star both fail this test)
  * Restoring dir paths containing "." and ".." components
This version initially creates all dirs with permission 700 (ignoring
umask), then does a post-extract "fixup" pass to set the correct
permissions (which may or may not depend on umask, depending on the
restore flags and whether it's an explicit or implicit dir).
Permissions are restored depth-first so that permissions within
non-writable dirs can be correctly restored. (The depth-sorting does
correctly account for dirs with ".." components.)
2004-07-08 05:24:48 +00:00
Tim Kientzle
2859e75d07 Minor wordsmithing; remove a controversial colon. 2004-07-05 19:44:35 +00:00
Tim Kientzle
f586f10d0d Add convenience functions to retrieve the atime fields directly,
without having to first pull the stat structure.
2004-07-05 18:11:44 +00:00
Tim Kientzle
7228b0c18b ru@'s ambitious sweep through the manpages is mostly a good thing,
but some colons are supposed to be followed by uppercase letters.
2004-07-05 18:08:32 +00:00
Ruslan Ermilov
51f98e585b Fix the NAME section making whatis(1) happy in particular. 2004-07-05 17:12:53 +00:00
Ruslan Ermilov
284fcee0c0 Fixed cross-references in SEE ALSO.
Emininated double space and hard sentence breaks.
2004-07-04 21:15:37 +00:00
Tim Kientzle
98183bf412 Yet another pointy hat: When restoring file flags, it's okay to use the
shared stat buffer, but don't try to access it through an uninitialized
pointer.
2004-07-04 18:28:56 +00:00
Ruslan Ermilov
1a0a934547 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
Tim Kientzle
5708f1dd7c In case symlinks happen to already be sitting around, be sure to use
chmod() and not lchmod() whenever we know we didn't extract a symlink.
2004-06-30 04:54:07 +00:00
Tim Kientzle
88c3541690 Some implicit dirs were not having the umask correctly
applied to their permissions.  Just calculate the
default dir mode once and use it consistently, rather than
trying to remember to calculate it everywhere it's needed.
2004-06-28 14:12:09 +00:00
Tim Kientzle
b3f695b45c Refuse to extract an entry from an archive on top of the archive being read.
(This is the converse of the "don't add an archive to itself".)
2004-06-27 23:36:39 +00:00