From aa9f35f146419c19cedcd8b9c2f22c1df499b17e Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Fri, 20 Mar 2020 01:13:23 +0300 Subject: [PATCH] Support RHT.security.selinux from GNU tar --- libarchive/archive_read_support_format_tar.c | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index c63d46fc0..a9f755906 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -1796,6 +1796,21 @@ pax_attribute_schily_xattr(struct archive_entry *entry, return 0; } +static int +pax_attribute_rh_selinux(struct archive_entry *entry, + const char *name, const char *value, size_t value_length) +{ + // RHT.security.selinux -> xattr security.selinux + if (strlen(name) < 5 || (memcmp(name, "RHT.", 4)) != 0) + return 1; + + name += 4; + + archive_entry_xattr_add_entry(entry, name, value, value_length); + + return 0; +} + static int pax_attribute_acl(struct archive_read *a, struct tar *tar, struct archive_entry *entry, const char *value, int type) @@ -1966,6 +1981,14 @@ pax_attribute(struct archive_read *a, struct tar *tar, if (memcmp(key, "LIBARCHIVE.xattr.", 17) == 0) pax_attribute_xattr(entry, key, value); break; + case 'R': + /* Upstream GNU tar uses RHT.security header to store SELinux xattrs + * SCHILY.xattr.security.selinux == RHT.security.selinux */ + if (strcmp(key, "RHT.security.selinux") == 0) { + pax_attribute_rh_selinux(entry, key, value, + value_length); + } + break; case 'S': /* We support some keys used by the "star" archiver */ if (strcmp(key, "SCHILY.acl.access") == 0) { -- 2.47.2