cmArchiveWrite: Clear xattr and acl from entries (#11958)

When reading archive entries from disk strip any xattr and acl entry
headers that may have been loaded from the filesystem (e.g. selinux).
These fields are only useful for backup tools and not for packaging and
distribution of software.  Furthermore, the GNU tar 1.15.1 on at least
one Linux distribution treats unknown entry headers as an error rather
than a warning.  Therefore avoiding such fields is necessary for archive
portability.

Suggested-by: Tim Kientzle <tim@kientzle.com>
This commit is contained in:
Brad King 2011-04-07 08:27:56 -04:00
parent c2f8a13715
commit e8558efa01
1 changed files with 3 additions and 0 deletions

View File

@ -236,6 +236,9 @@ bool cmArchiveWrite::AddFile(const char* file,
this->Error += archive_error_string(this->Disk); this->Error += archive_error_string(this->Disk);
return false; return false;
} }
// Clear acl and xattr fields not useful for distribution.
archive_entry_acl_clear(e);
archive_entry_xattr_clear(e);
if(archive_write_header(this->Archive, e) != ARCHIVE_OK) if(archive_write_header(this->Archive, e) != ARCHIVE_OK)
{ {
this->Error = "archive_write_header: "; this->Error = "archive_write_header: ";