summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_disk_posix.c
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2017-01-29 15:51:02 +0100
committerMartin Matuska <martin@matuska.org>2017-01-29 16:06:30 +0100
commit9f43a7d60fd99cc5a8f6420b6c692bb137f85bb8 (patch)
tree8634df05b77abac826e035cc058cafc6227ca3a0 /libarchive/archive_write_disk_posix.c
parent1220de603e72b73ea6bda25a9246191316493974 (diff)
downloadlibarchive-9f43a7d60fd99cc5a8f6420b6c692bb137f85bb8.tar.gz
Add NFSv4 ACL support for Mac OS X
Mac OS X supports user and group NFSv4-style ACLs only (extended ACLs). File-mode ACLs (owner@, group@ and everyone@) are not supported. Behavior on Mac OS X: - libarchive does not store GUID of Mac OS X extended ACLs. Only uid or gid (and the corresponding user or group name) are stored. - When extracting an archive entry that has mac_metadata, NFSv4 ACLs are not written to disk (mac_metadata already contains ACLs) - When writing ACLs to disk from an archive entry with NFSv4 ACLs owner@, group@ and everyone@ ACLs are ignored. User and group ids are converted to a GUID (this may lead to a fabricated GUID if the user or group ID is not present on the system) - When reading ACL from disk and there is at least one user or group extended ACL entry, owner@, group@ and everyone@ entries mirroring the file mode are added to the end of the entry's ACL.
Diffstat (limited to 'libarchive/archive_write_disk_posix.c')
-rw-r--r--libarchive/archive_write_disk_posix.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c
index fabe6bca..29d687bf 100644
--- a/libarchive/archive_write_disk_posix.c
+++ b/libarchive/archive_write_disk_posix.c
@@ -1702,10 +1702,25 @@ _archive_write_disk_finish_entry(struct archive *_a)
* ACLs that prevent attribute changes (including time).
*/
if (a->todo & TODO_ACLS) {
- int r2 = archive_write_disk_set_acls(&a->archive, a->fd,
- archive_entry_pathname(a->entry),
- archive_entry_acl(a->entry));
+ int r2;
+#ifdef HAVE_DARWIN_ACL
+ /*
+ * On Mac OS, platform ACLs are stored also in mac_metadata by
+ * the operating system. If mac_metadata is present it takes
+ * precedence and we skip extracting libarchive NFSv4 ACLs
+ */
+ const void *metadata;
+ size_t metadata_size;
+ metadata = archive_entry_mac_metadata(a->entry, &metadata_size);
+ if (metadata == NULL || metadata_size == 0) {
+#endif
+ r2 = archive_write_disk_set_acls(&a->archive, a->fd,
+ archive_entry_pathname(a->entry),
+ archive_entry_acl(a->entry));
if (r2 < ret) ret = r2;
+#ifdef HAVE_DARWIN_ACL
+ }
+#endif
}
finish_metadata:
@@ -2264,8 +2279,12 @@ _archive_write_disk_close(struct archive *_a)
if (p->fixup & TODO_MODE_BASE)
chmod(p->name, p->mode);
if (p->fixup & TODO_ACLS)
- archive_write_disk_set_acls(&a->archive,
- -1, p->name, &p->acl);
+#ifdef HAVE_DARWIN_ACL
+ if (p->mac_metadata == NULL ||
+ p->mac_metadata_size == 0)
+#endif
+ archive_write_disk_set_acls(&a->archive,
+ -1, p->name, &p->acl);
if (p->fixup & TODO_FFLAGS)
set_fflags_platform(a, -1, p->name,
p->mode, p->fflags_set, 0);