From c49d7069039241ad02a8a710e9054d253abee3ad Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Fri, 11 Oct 2013 20:28:00 -0400 Subject: fix getting and setting contexts in selinux recreate lost+found with selinux contexts Change-Id: I19e8696d47319dfb641520956c8a27c2a796a0c3 --- libtar/append.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'libtar/append.c') diff --git a/libtar/append.c b/libtar/append.c index 3a8bfc690..dcd864984 100644 --- a/libtar/append.c +++ b/libtar/append.c @@ -92,29 +92,22 @@ tar_append_file(TAR *t, char *realname, char *savename) #ifdef HAVE_SELINUX /* get selinux context */ - if(t->options & TAR_STORE_SELINUX) - { - if(t->th_buf.selinux_context != NULL) - { + if(t->options & TAR_STORE_SELINUX) { + if(t->th_buf.selinux_context != NULL) { free(t->th_buf.selinux_context); t->th_buf.selinux_context = NULL; } security_context_t selinux_context = NULL; - if(getfilecon(realname, &selinux_context) >= 0) - { + if (lgetfilecon(realname, &selinux_context) >= 0) { t->th_buf.selinux_context = strdup(selinux_context); + printf("setting selinux context: %s\n", selinux_context); freecon(selinux_context); } else - { -#ifdef DEBUG perror("Failed to get selinux context"); -#endif - } } #endif - /* check if it's a hardlink */ #ifdef DEBUG puts(" tar_append_file(): checking inode cache for hardlink..."); -- cgit v1.2.3