aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2016-09-12 22:07:35 +0000
committerMartin Matuska <mm@FreeBSD.org>2016-09-12 22:07:35 +0000
commit9cc2812c536cf3cf20dcf939b304236a2ce961ab (patch)
treecc7776bcf499e9e5637d59b9fc2e8655906c34cd /contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
parent144404ebcb55f47d73c51dab2d293a93d68ede72 (diff)
downloadsrc-9cc2812c536cf3cf20dcf939b304236a2ce961ab.tar.gz
src-9cc2812c536cf3cf20dcf939b304236a2ce961ab.zip
MFC r305422:
Sync libarchive with vendor Vendor issues fixed: PR #777: Multiple bugfixes for setup_acls() This includes a bugfix for a bug that caused ACLs not to be read properly for files and directories inside subdirectories and as a result not being stored or being incorrectly stored in tar archives.
Notes
Notes: svn path=/stable/10/; revision=305755
Diffstat (limited to 'contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c')
-rw-r--r--contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
index 29b4b6cb0869..f2148da42158 100644
--- a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -419,12 +419,32 @@ setup_acls(struct archive_read_disk *a,
if (accpath == NULL)
accpath = archive_entry_pathname(entry);
+ if (*fd < 0 && a->tree != NULL) {
+ if (a->follow_symlinks ||
+ archive_entry_filetype(entry) != AE_IFLNK)
+ *fd = a->open_on_current_dir(a->tree,
+ accpath, O_RDONLY | O_NONBLOCK);
+ if (*fd < 0) {
+ if (a->tree_enter_working_dir(a->tree) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't access %s", accpath);
+ return (ARCHIVE_FAILED);
+ }
+ }
+ }
+
archive_entry_acl_clear(entry);
+ acl = NULL;
+
#ifdef ACL_TYPE_NFS4
/* Try NFS4 ACL first. */
if (*fd >= 0)
+#if HAVE_ACL_GET_FD_NP
+ acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+#else
acl = acl_get_fd(*fd);
+#endif
#if HAVE_ACL_GET_LINK_NP
else if (!a->follow_symlinks)
acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
@@ -437,12 +457,19 @@ setup_acls(struct archive_read_disk *a,
#endif
else
acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+
#if HAVE_ACL_IS_TRIVIAL_NP
- /* Ignore "trivial" ACLs that just mirror the file mode. */
- acl_is_trivial_np(acl, &r);
- if (r) {
- acl_free(acl);
- acl = NULL;
+ if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (r) {
+ acl_free(acl);
+ acl = NULL;
+ /*
+ * Simultaneous NFSv4 and POSIX.1e ACLs for the same
+ * entry are not allowed, so we should return here
+ */
+ return (ARCHIVE_OK);
+ }
}
#endif
if (acl != NULL) {
@@ -450,7 +477,7 @@ setup_acls(struct archive_read_disk *a,
acl_free(acl);
return (ARCHIVE_OK);
}
-#endif
+#endif /* ACL_TYPE_NFS4 */
/* Retrieve access ACL from file. */
if (*fd >= 0)
@@ -467,10 +494,22 @@ setup_acls(struct archive_read_disk *a,
#endif
else
acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+#if HAVE_ACL_IS_TRIVIAL_NP
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+ if (r) {
+ acl_free(acl);
+ acl = NULL;
+ }
+ }
+#endif
+
if (acl != NULL) {
translate_acl(a, entry, acl,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
acl_free(acl);
+ acl = NULL;
}
/* Only directories can have default ACLs. */