Mike Frysinger [Thu, 23 Mar 2017 06:26:52 +0000 (02:26 -0400)]
constify variables more
A bunch of constant variables/tables are missing const markings.
Adding them allows moving more data to the read only sections, and
ends up shrinking writable data a bit by 1k on x86_64/Linux. Not
much, but still nice.
Martin Matuska [Thu, 23 Mar 2017 14:27:59 +0000 (15:27 +0100)]
Improve extended attribute support
Mac OS X changes:
- add support for extended file attributes via sys/xattr.h
- when extracting an archive entry that has mac_metadata and
mac_metadata is requested to be extracted, extended attributes
are restored only from mac_metadata.
- by default, extended attributes are stored both in mac_metadata and
SCHILY.xattr/LIBARCHIVE.xattr. This is subject to review and change.
To match behavior on other platforms, store extended attributes on
FreeBSD with extattr_set_link() if no fd is provided.
Detection of extended attributes support in configure stage has been
rewritten.
Added xattr platform test to libarchive and xattrs option test to bsdtar.
Martin Matuska [Wed, 15 Mar 2017 22:27:48 +0000 (23:27 +0100)]
Add NFSv4 ACL support for Linux via librichacl
Richacls are interpreted as NFSv4 ACLs and stored in archive_acl (Richacl
flags and masks are not stored). Analog to mac_metadata, NFSv4 ACLs do not
get extracted when the extraction of extended attributes is enabled and the
"trusted.richacl" extended attribute is present.
RichACL masks and are calculated from file mode on extraction.
mac_metadata acl check has been moved in the code to be together with the
richacl check.
Martin Matuska [Mon, 13 Mar 2017 14:49:38 +0000 (15:49 +0100)]
Move platform-specific ACL code to individual source files.
This makes the code much more readable and eases the addition of new
ACL implementatons in the future.
Additional changes:
- most of ACL detection is now done at configure stage
- configuration now reports what ACL was detected
- NFSv4 ACL tests now test INHERIT_ONLY and NO_PROPAGATE_INHERIT
Tim Kientzle [Sat, 11 Mar 2017 23:30:38 +0000 (15:30 -0800)]
Break out the library version functions into a separate source file.
This breaks a static dependency on libbz2. Before this,
any use of libarchive that ended up linking archive_util.c would
require libbz2. (And since archive_util.c contains a bunch of
very core functions, this is pretty much everybody.)
Now you only require libbz2 if you request library version information
or actually use some other feature that involves bzip2 support.
Note that most of the libraries provide version information via
compile-time macros -- libbz2 only provides such information via
a function call, which is why this issue only arises with libbz2.
In particular, the libbz2 version reports the version that we
are currently linked against; the other library versions report
the version we were compiled with (which may not be the same as
what we are currently using).
Tim Kientzle [Sat, 11 Mar 2017 23:13:23 +0000 (15:13 -0800)]
OSS-Fuzz Issue 806: integer overflow in mtree_atol10
Rework the mtree_atol10 integer parser so it can parse
INT64_MIN without overflowing the intermediate value.
While here, make this function behave a little more predictably for
too-large input: It now always advances the pointer to the first
non-digit character.
Martin Matuska [Mon, 6 Mar 2017 23:50:12 +0000 (00:50 +0100)]
Darwin ACL: avoid using mbr_identifier_to_uuid()
Use mbr_uid_to_uuid() and mbr_gid_to_uuid() for backwards compatibility
instead. These functions have been introduced together with membership.h.
Martin Matuska [Thu, 2 Mar 2017 13:19:38 +0000 (14:19 +0100)]
New tar test: test_option_acls
Add sunacl_get() and setTestAcl() to common test code
Test for membership.h on Mac OS X and make it a requirement for ACLs
Phillip Berndt [Mon, 20 Feb 2017 16:45:56 +0000 (17:45 +0100)]
seekable zip backend: Accept files with valid ZIP64 EOCD headers
Previously, a ZIP64 file needed to have a valid classic EOCD header.
This is not the case at least for archives generated by PHPZipStreamer.
This commit allows for a bit more than necessary: While PHPZipStreamer
sets the classic EOCD header to all -1's, the bidding function now
succeeds also if the EOCD header values have arbitrary values, as long
as the ZIP64 EOCD header seems plausible. This simplifies the logic and
should not do any harm in practice.
Brad King [Fri, 24 Feb 2017 12:26:35 +0000 (07:26 -0500)]
Define bcrypt macro not available in Win 7 SDK
VS 2010 comes with the Win 7 SDK and its bcrypt.h does not define the
`BCRYPT_HASH_REUSABLE_FLAG` macro. Provide the definition locally if
it is not available.
Martin Matuska [Fri, 24 Feb 2017 01:33:40 +0000 (02:33 +0100)]
Do not archive NFSv4 ACLs on Mac OS X by default.
This avoids wrtiting ACLs to tar files twice. Preferred method is
via copyfile(3) (tar option --mac-metadata). If user wants to create
archives with portable NFSv4 ACLs only (SCHILY.acl.ace header with no
GUID data) the --acls and --no-mac-metadata options must be specified
on the command line.
In the manual page be more specific which types of ACLs are stored
with --acls and --mac-metadata options.
Martin Matuska [Thu, 23 Feb 2017 21:56:40 +0000 (22:56 +0100)]
tar: add new options to allow fine-tuning of --preserve-permissions
Allow enabling and disabling reading or writing of:
Access Control Lists (--acls, --no-acls)
Extended file flags (--fflags, --no-fflags)
Extended attributes (--xattrs, --no-xattrs)
Mac OS X metadata in AppleDouble (--mac-metadata, --no-mac-metadata)
Make --disable-copyfile an alias to --no-mac-metadata.
Martin Matuska [Sat, 18 Feb 2017 21:38:38 +0000 (22:38 +0100)]
disk read: improve path handling for acls, xattrs and mac_metadata
- Do not execute pathname code at all if we have a fd. The only exception
is setup_acls() for directory entries where default ACLs can be
retrieved only with acl_get_file() - e.g. on Linux.
- Do not fail if tree_enter_working_dir() fails. Fallback to
archive_entry_pathname() instead and try with path-based functions.
- Do not fail if open_on_current_dir() fails. Try with path-based
functions.
- Pass pathname to setup_xattr() to avoid execution of duplicate code.
Martin Matuska [Sat, 18 Feb 2017 01:36:20 +0000 (02:36 +0100)]
disk read: rework handling of paths for acls, xattrs and mac_metadata
If path is read from archive_entry_sourcepath(), always enter tree
working dir. If path is read from archive_entry_pathname(), don't.
This prevents reading acls, xattrs or mac_metadata from wrong files
or not at all if no fd is provided (e.g. default ACLs on Linux can
be read only from a pathname).
Martin Matuska [Wed, 15 Feb 2017 19:43:54 +0000 (20:43 +0100)]
New archive_acl_to_text() style flag: ARCHIVE_ENTRY_ACL_STYLE_COMPACT
- outputs NFSv4 permission and flags fields without minus characters
Use new compact format as default for the SCHILY.acl.ace pax header