summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_extract.c
Commit message (Collapse)AuthorAgeFilesLines
* MFp4: libarchive 2.5.4b. (Still 'b' until I get a bit morekientzle2008-05-261-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | feedback, but the 2.5 branch is shaping up nicely.) In addition to many small bug fixes and code improvements: * Another iteration of versioning; I think I've got it right now. * Portability: A lot of progress on Windows support (though I'm not committing all of the Windows support files to FreeBSD CVS) * Explicit tracking of MBS, WCS, and UTF-8 versions of strings in archive_entry; the archive_entry routines now correctly return NULL only when something is unset, setting NULL properly clears string values. Most charset conversions have been pushed down to archive_string. * Better handling of charset conversion failure when writing or reading UTF-8 headers in pax archives * archive_entry_linkify() provides multiple strategies for hardlink matching to suit different format expectations * More accurate bzip2 format detection * Joerg Sonnenberger's extensive improvements to mtree support * Rough support for self-extracting ZIP archives. Not an ideal approach, but it works for the archives I've tried. * New "sparsify" option in archive_write_disk converts blocks of nulls into seeks. * Better default behavior for the test harness; it now reports all failures by default instead of coredumping at the first one.
* Reconnect the progress callback. It may not get calledkientzle2008-01-181-2/+8
| | | | | | | as often as you might expect, but at least it will get called now. Thanks to: David Topham for asking how this got disconnected.
* libarchive 2.2.3kientzle2007-05-291-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * "compression_program" support uses an external program * Portability: no longer uses "struct stat" as a primary data interchange structure internally * Part of the above: refactor archive_entry to separate out copy_stat() and stat() functions * More complete tests for archive_entry * Finish archive_entry_clone() * Isolate major()/minor()/makedev() in archive_entry; remove these from everywhere else. * Bug fix: properly handle decompression look-ahead at end-of-data * Bug fixes to 'ar' support * Fix memory leak in ZIP reader * Portability: better timegm() emulation in iso9660 reader * New write_disk flags to suppress auto dir creation and not overwrite newer files (for future cpio front-end) * Simplify trailing-'/' fixup when writing tar and pax * Test enhancements: fix various compiler warnings, improve portability, add lots of new tests. * Documentation: document new functions, first draft of libarchive_internals.3 MFC after: 14 days Thanks to: Joerg Sonnenberger (compression_program) Thanks to: Kai Wang (ar) Thanks to: Colin Percival (many small fixes) Thanks to: Many others who sent me various patches and problem reports.
* In libarchive: Downgrade ARCHIVE_FATAL and ARCHIVE_FAILED errors whichcperciva2007-04-161-0/+6
| | | | | | | | | | | | | | | | occur on the write side of extracting a file to ARCHIVE_WARN errors when returning them from archive_read_extract. In bsdtar: Use the return code from archive_read_data_into_fd and archive_read_extract to determine whether we should continue trying to extract an archive after one of the entries fails. This commit makes extracting a truncated tarball complain once about the archive being truncated, instead of complaining twice (once when trying to extract an entry, and once when trying to seek to the next entry). Discussed with: kientzle
* Thanks to Colin for catching my mixup. The original problem wasn'tkientzle2007-04-151-3/+8
| | | | suppressing the second error, it was failing to address the first.
* Pass through error message if any operation fails, not just the last one.kientzle2007-04-141-1/+1
|
* When copying data from one archive to another, only set the errorcperciva2007-04-071-5/+4
| | | | | | message in the reader to the error message from the writer if the error which occurred was in the writer. This avoids error messages of "Empty error message" when extracting truncated archives.
* Libarchive 2.0.23:kientzle2007-03-111-38/+0
| | | | | | | | | | | | * The ACL formatter was mis-formatting entries which had a user/group ID but no name. Make the parser tolerant of these, so that old archives can be correctly restored; fix the formatter to generate correct entries. * Fix overwrite detection by introducing a new "FAILED" return code that indicates the current entry cannot be continued but the archive as a whole is still sound. * Header cleanup: Remove some unused headers, add some that are required with new Linux systems.
* libarchive 2.0kientzle2007-03-031-1541/+76
| | | | | | | | | | | | | | | | | | | * libarchive_test program exercises many of the core features * Refactored old "read_extract" into new "archive_write_disk", which uses archive_write methods to put entries onto disk. In particular, you can now use archive_write_disk to create objects on disk without having an archive available. * Pushed some security checks from bsdtar down into libarchive, where they can be better optimized. * Rearchitected the logic for creating objects on disk to reduce the number of system calls. Several common cases now use a minimum number of system calls. * Virtualized some internal interfaces to provide a clearer separation of read and write handling and make it simpler to override key methods. * New "empty" format reader. * Corrected return types (this ABI breakage required the "2.0" version bump) * Many bug fixes.
* Force the umask to something predictable while creating objectskientzle2007-03-021-1/+2
| | | | on disk. In particular, this fixes tar -xp restore of mode bits.
* Fix the copyright notice; it was always intended to bekientzle2007-01-091-3/+2
| | | | | | | | | a vanilla 2-clause BSD license, but somehow some confusing extra verbage get copied from somewhere. Also, update the copyright dates to 2007 for all of the files. Prompted by: several questions about what those extra words really mean
* Portability and style fixes:kientzle2006-11-101-4/+26
| | | | | | | | | | | | | | * Actually use the HAVE_<header>_H macros to conditionally include system headers. They've been defined for a long time, but only used in a few places. Now they're used pretty consistently throughout. * Fill in a lot of missing casts for conversions from void*. Although Standard C doesn't require this, some people have been trying to use C++ compilers with this code, and they do require it. Bit-for-bit, the compiled object files are identical, except for one assert() whose line number changed, so I'm pretty confident I didn't break anything. ;-)
* Performance: If the dir mode requested is "reasonable", then justkientzle2006-10-041-49/+89
| | | | | | restore it directly and skip chmod() during the post-extract fixup. In particular, bsdtar -xm now completely skips the post-extract fixup for directories, which produces a noticable speedup in that case.
* Some minor corrections:kientzle2006-09-051-2/+3
| | | | | | | * Expose functions for setting the "skip file" dev/ino information * Expose functions for setting/querying the block size on reads * Correctly propagate errors out of archive_read_close/archive_write_close * Update manpage with information about new functions
* Simplify some of the wide-character handling, inspiredkientzle2006-05-011-3/+3
| | | | | | | in part by OpenBSD's not-quite-standard-compliant standard libraries. (No loss of functionality, just minor recoding to not rely on certain "standard" facilities that weren't actually needed.)
* Even if a system does not support restoring extended attributes,kientzle2006-03-221-2/+4
| | | | | | | | | it's only a failure if there were actually attributes to be restored. In particular, this fixes the problem where tar -xp always returned a failure code on FreeBSD (which doesn't yet have all of the extended attribute support). Thanks to: Diego "Flameeyes" Petteno
* POSIX.1e-style Extended Attribute supportkientzle2006-03-211-21/+116
| | | | | | | | | | | This commit implements storing/reading POSIX.1e-style extended attribute information in "pax" format archives. An outline of the storage format is in the tar.5 manpage. The archive_read_extract() function has code to restore those archives to disk for Linux; FreeBSD implementation is forthcoming. Many thanks to Jaakko Heinonen for finding flaws in earlier proposals and doing the bulk of the coding in this work.
* Fix fallout from the previous commit:yar2005-09-091-4/+7
| | | | | | | We shouldn't call chmod() if we've just used fchmod() OK on the same file. Approved by: kientzle
* Terminate metadata restore early only on failure, not success.kientzle2005-09-051-2/+4
| | | | In particular, this bug was preventing the restore of fflags.
* Minor clean up for flags restoration: Use fchflags/lchflags whenkientzle2005-06-041-9/+46
| | | | | available, stub out flags restore on platforms that don't support it, update autoconf to probe for fchflags and lchflags support.
* Start to address the race issue between restoring a file's contentskientzle2005-05-211-102/+187
| | | | | | | | | | | | | | 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
* Portability enhancement: MS Windows won't restore metadata if the filekientzle2005-04-171-1/+1
| | | | | | | 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
* Clean up the support for extracting very long pathnames.kientzle2005-03-291-13/+17
|
* Support extracting entries with pathnames longer than PATH_MAX. Inkientzle2005-03-131-26/+96
| | | | | testing, I've archived and restored dir trees with ~1MB pathnames. Most formats, of course, have much smaller limits.
* Update a comment.kientzle2004-11-051-0/+1
|
* Cache uid-from-uname and gid-from-gname lookups during extraction.kientzle2004-08-271-17/+84
| | | | | | | 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)
* Don't edit permissions of pre-existing directories during extract.kientzle2004-08-261-1/+1
| | | | | | | | 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
* libarchive now has two complete build systems. The usual "Makefile"kientzle2004-08-071-6/+11
| | | | | | | | | | | | | | 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.
* Use "linux" instead of "LINUX" to control Linux-specific code.kientzle2004-07-241-7/+14
| | | | | | | | 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.
* Style: rename 'mkdirpath' so it's clearer exactly what it does.kientzle2004-07-151-22/+27
| | | | (To be precise, it creates the parent dir of the provided path.)
* Correct a brain-o in extract_dir: mkdirpath() and mkdir(2) arekientzle2004-07-101-2/+4
| | | | not interchangable.
* I think this is my fourth complete rewrite of the dir-creationkientzle2004-07-081-139/+213
| | | | | | | | | | | | | | | 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.)
* Yet another pointy hat: When restoring file flags, it's okay to use thekientzle2004-07-041-1/+1
| | | | | shared stat buffer, but don't try to access it through an uninitialized pointer.
* In case symlinks happen to already be sitting around, be sure to usekientzle2004-06-301-6/+20
| | | | chmod() and not lchmod() whenever we know we didn't extract a symlink.
* Some implicit dirs were not having the umask correctlykientzle2004-06-281-4/+13
| | | | | | 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.
* More cleanup work on permissions restore:kientzle2004-06-271-179/+200
| | | | | | | | | | | | | * Rename some variables/functions/etc to try to make things clearer. * Add separate flags to control fflag/acl restore * Collect metadata restore into a single function for clarity * Propagate errors in metadata restore back out to the client * Fix some places where errors were being returned when they shouldn't and vice-versa * Modes are now always restored; ARCHIVE_EXTRACT_PERM just controls whether or not umask is obeyed. * Restore suid/sgid bits only if user/group matches archive * Cache the last stat results to try to reduce the number of stat calls
* Clean up some consistent confusion between "dev" and "rdev."kientzle2004-06-271-4/+4
| | | | | | | | Mostly, these were being used correctly even though a lot of variables and function names were mis-named. In the process, I found and fixed a couple of latent bugs and added a guard against adding an archive to itself.
* More tweaks to implicit directory creation. Even such abominations askientzle2004-06-271-4/+27
| | | | | | | | | | | a/././b/../b/../c/./../d/e/f now work correctly. And yes, a/b and a/c both get created in this example; if you want, you can create an entire dir heirarchy from a tar archive with only one entry. More tweaks to umask support: umasks are now obeyed for all objects, not just directories; the umask used is now the one in effect at the corresponding call to archive_read_extract(), so clients that want to tinker with umask during extract should get the expected behavior.
* * The mode for implicitly-created dirs is now 0777 modified by thekientzle2004-06-271-4/+6
| | | | | | | umask in effect when the archive is closed * Correct a typo that broke implicit dir creation for non-directories. Thanks to: Garret A Wollman for pointing out my umask oversight
* Unify mkdirpath (used to automatically create missing parent dirs) andkientzle2004-06-271-215/+126
| | | | | | | | | | | read_extract_dir (which creates directories in the archive). This brings a number of advantages: * FINALLY fix the problems creating dirs ending in "/." <sigh> * Missing parent dirs now get created securely, just like explicit dirs. (Created 0700 initially, then edited to 0755 at end of extraction.) * Eliminate some duplicate code and some weird special cases. While I'm cleaning, inline the regular-file creation code as well.
* Read gtar-style sparse archives.kientzle2004-06-271-7/+1
| | | | | | | This change also pointed out one API deficiency: the archive_read_data_into_XXX functions were originally defined to return the total bytes read. This is, of course, ambiguous when dealing with non-contiguous files. Change it to just return a status value.
* Always restore permissions for regular files, even if thekientzle2004-06-171-1/+3
| | | | | | | | | file already exists on disk. Pointed out by: www/resin3 port (whose distfile contains the same file twice with different permissions and relies on the permissions associated with the second instance) Thanks again to: Kris Kennaway
* Be a little more careful about creating directories:kientzle2004-06-151-7/+23
| | | | | | | | * Restore directories with 0700 permissions initially, then use the fixup pass to correct the permissions * Trim trailing "/" and "/." in mkdirpath() Suggested by: Garrett Wollman
* Pointy hat: We can't avoid a chown() call without checking both UIDkientzle2004-06-051-1/+5
| | | | and GID. Suppress a premature attempt at optimization.
* YAPHtM: Yet Another Pointy Hat to Me.kientzle2004-06-051-1/+1
| | | | | After calculating new dir permissions that allow creating files, don't be stupid and use the original permissions. <sigh>
* Recognize when we've accidentally created "foo/."kientzle2004-06-051-0/+12
| | | | and don't complain about it.
* Refactor the extraction code somewhat. In particular,kientzle2004-06-031-116/+104
| | | | | | | | | | push extract data down into archive_read_extract.c and out of the library-global archive_private.h; push dir-specific mode/time fixup down into dir restore function; now that the fixup list is file-local, I can use somewhat more natural naming. Oh, yeah, update a bunch of comments to match current reality.
* Previously, restoring an archive with hardlinked files that hadkientzle2004-05-271-86/+147
| | | | | | | | | | | | certain flags set (e.g., schg or uappend) would fail because the flags were restored before the hardlink was created. To address this, I've generalized the existing machinery for deferring directory timestamp/mode restoration and used it to defer the restoration of highly-restrictive flags to the end of the extraction, after any links have been created. Pointed out by: Pawel Jakub Dawidek (pjd@)
* Add hook for a client-provided progress callback to be invokedkientzle2004-05-131-0/+8
| | | | during lengthy extract operations.
* Create missing directories when extracting hardlinks and symlinks.kientzle2004-04-301-9/+39
|
OpenPOWER on IntegriCloud