]> Dogcows Code - chaz/tar/blobdiff - src/xheader.c
Add SELinux context store/restore/list support.
[chaz/tar] / src / xheader.c
index 6141748a7228dc01d4f1272147f340fb5857b358..559e60adb22be629b6e9a01c12b2400e0325b5e1 100644 (file)
@@ -469,6 +469,7 @@ void xheader_xattr_init (struct tar_stat_info *st)
   st->acls_a_len = 0;
   st->acls_d_ptr = NULL;
   st->acls_d_len = 0;
+  st->cntx_name = NULL;
 }
 
 void xheader_xattr_free (struct xattr_array *xattr_map, size_t xattr_map_size)
@@ -1554,6 +1555,20 @@ volume_filename_decoder (struct tar_stat_info *st,
   decode_string (&continued_file_name, arg);
 }
 
+static void
+xattr_selinux_coder (struct tar_stat_info const *st, char const *keyword,
+                     struct xheader *xhdr, void const *data)
+{
+  code_string (st->cntx_name, keyword, xhdr);
+}
+
+static void
+xattr_selinux_decoder (struct tar_stat_info *st,
+                       char const *keyword, char const *arg, size_t size)
+{
+  decode_string (&st->cntx_name, arg);
+}
+
 static void
 xattr_acls_a_coder (struct tar_stat_info const *st , char const *keyword,
                     struct xheader *xhdr, void const *data)
@@ -1703,6 +1718,11 @@ struct xhdr_tab const xhdr_tab[] = {
   { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder,
     XHDR_PROTECTED | XHDR_GLOBAL, false },
 
+  /* We get the SELinux value from filecon, so add a namespace for SELinux
+     instead of storing it in SCHILY.xattr.* (which would be RAW). */
+  { "RHT.security.selinux",
+    xattr_selinux_coder, xattr_selinux_decoder, 0, false },
+
   /* ACLs, use the star format... */
   { "SCHILY.acl.access",
     xattr_acls_a_coder, xattr_acls_a_decoder, 0, false },
This page took 0.022246 seconds and 4 git commands to generate.