]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Support RHT.security.selinux from GNU tar 1348/head
authorMikhail Novosyolov <m.novosyolov@rosalinux.ru>
Thu, 19 Mar 2020 22:13:23 +0000 (01:13 +0300)
committerMikhail Novosyolov <m.novosyolov@rosalinux.ru>
Thu, 19 Mar 2020 22:25:52 +0000 (01:25 +0300)
libarchive/archive_read_support_format_tar.c

index c63d46fc0ce2b2a64e7c0ed5c875872ea872db57..a9f755906a3a721f8a09fdf1f7026989cc6494e4 100644 (file)
@@ -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) {