diff options
author | Eric Borisch <eborisch@gmail.com> | 2018-05-31 22:45:34 -0500 |
---|---|---|
committer | Eric Borisch <eborisch@gmail.com> | 2018-05-31 22:45:34 -0500 |
commit | ad58bd612e45812f106580cb102b2cc034016367 (patch) | |
tree | 37fa2fb18e35acc4b43134e77efa6adf24922ba7 | |
parent | 38c806ec51e2e23e2db65c354e63df258ffcd0bf (diff) | |
download | libarchive-ad58bd612e45812f106580cb102b2cc034016367.tar.gz |
Perform xattrs before mode on Darwin.
Setting the mode on Darwin does not clear xattrs, but xattrs cannot be
set by a non-root user if the mode is not writable. Perform xattrs first
and then mode in _archive_write_disk_finish_entry() on Datwin. Darwin
ACLs are handled later.
Prior change handled --hfsCompression - specific xattrs, this catches
any other (encoded in the archive) attributes.
-rw-r--r-- | libarchive/archive_write_disk_posix.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 88d4b5dd..07f98e55 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -1703,6 +1703,18 @@ _archive_write_disk_finish_entry(struct archive *_a) int r2 = set_ownership(a); if (r2 < ret) ret = r2; } +#ifdef ARCHIVE_XATTR_DARWIN + /* + * Darwin XATTRs must be performed before setting mode (and potentially + * removing owner-writable for a non-root user.) Darwin ACLs have no + * such restriction and are handled below in TODO_MAC_METADATA. Setting + * the mode on Darwin does not clear xattrs. + */ + if (a->todo & TODO_XATTR) { + int r2 = set_xattrs(a); + if (r2 < ret) ret = r2; + } +#endif /* * set_mode must precede ACLs on systems such as Solaris and @@ -1713,6 +1725,7 @@ _archive_write_disk_finish_entry(struct archive *_a) if (r2 < ret) ret = r2; } +#ifndef ARCHIVE_XATTR_DARWIN /* * Security-related extended attributes (such as * security.capability on Linux) have to be restored last, @@ -1722,6 +1735,7 @@ _archive_write_disk_finish_entry(struct archive *_a) int r2 = set_xattrs(a); if (r2 < ret) ret = r2; } +#endif /* * Some flags prevent file modification; they must be restored after |