From 25fd68d0989254bdf921bcd118c4bae4d8afc419 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Tue, 27 Aug 2013 03:10:10 +0200 Subject: libtar: store SELinux file context in tar archives * Using RedHat's "RHT.security.selinux=" tag in extended tar header (type 'x') Signed-off-by: Vojtech Bocek Change-Id: I102e492e4fa5b8a08fae4d34eb36386862509b4d --- libtar/libtar.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libtar/libtar.h') diff --git a/libtar/libtar.h b/libtar/libtar.h index e7a355a85..91523d043 100644 --- a/libtar/libtar.h +++ b/libtar/libtar.h @@ -35,6 +35,9 @@ extern "C" #define GNU_LONGNAME_TYPE 'L' #define GNU_LONGLINK_TYPE 'K' +/* extended metadata for next file - used to store selinux_context */ +#define TH_EXT_TYPE 'x' + /* our version of the tar header structure */ struct tar_header { @@ -57,6 +60,9 @@ struct tar_header char padding[12]; char *gnu_longname; char *gnu_longlink; +#ifdef HAVE_SELINUX + char *selinux_context; +#endif }; @@ -96,6 +102,7 @@ TAR; #define TAR_CHECK_MAGIC 16 /* check magic in file header */ #define TAR_CHECK_VERSION 32 /* check version in file header */ #define TAR_IGNORE_CRC 64 /* ignore CRC in file header */ +#define TAR_STORE_SELINUX 128 /* store selinux context */ /* this is obsolete - it's here for backwards-compatibility only */ #define TAR_IGNORE_MAGIC 0 @@ -177,6 +184,7 @@ int th_write(TAR *t); || S_ISFIFO((mode_t)oct_to_int((t)->th_buf.mode))) #define TH_ISLONGNAME(t) ((t)->th_buf.typeflag == GNU_LONGNAME_TYPE) #define TH_ISLONGLINK(t) ((t)->th_buf.typeflag == GNU_LONGLINK_TYPE) +#define TH_ISEXTHEADER(t) ((t)->th_buf.typeflag == TH_EXT_TYPE) /* decode tar header info */ #define th_get_crc(t) oct_to_int((t)->th_buf.chksum) -- cgit v1.2.3