diff options
Diffstat (limited to '')
-rw-r--r-- | libtar/extract.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libtar/extract.c b/libtar/extract.c index ba29a7771..87ccf245f 100644 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -20,6 +20,10 @@ #include <errno.h> #include <utime.h> +#include <sys/capability.h> +#include <sys/xattr.h> +#include <linux/xattr.h> + #ifdef STDC_HEADERS # include <stdlib.h> #endif @@ -28,9 +32,7 @@ # include <unistd.h> #endif -#ifdef HAVE_SELINUX -# include "selinux/selinux.h" -#endif +#include <selinux/selinux.h> #ifdef HAVE_EXT4_CRYPT # include "ext4crypt_tar.h" @@ -155,7 +157,6 @@ tar_extract_file(TAR *t, const char *realname, const char *prefix, const int *pr return i; } -#ifdef HAVE_SELINUX if((t->options & TAR_STORE_SELINUX) && t->th_buf.selinux_context != NULL) { #ifdef DEBUG @@ -164,7 +165,16 @@ tar_extract_file(TAR *t, const char *realname, const char *prefix, const int *pr if (lsetfilecon(realname, t->th_buf.selinux_context) < 0) fprintf(stderr, "tar_extract_file(): failed to restore SELinux context %s to file %s !!!\n", t->th_buf.selinux_context, realname); } + + if((t->options & TAR_STORE_POSIX_CAP) && t->th_buf.has_cap_data) + { +#if 1 //def DEBUG + printf("tar_extract_file(): restoring posix capabilities to file %s\n", realname); + print_caps(&t->th_buf.cap_data); #endif + if (setxattr(realname, XATTR_NAME_CAPS, &t->th_buf.cap_data, sizeof(struct vfs_cap_data), 0) < 0) + fprintf(stderr, "tar_extract_file(): failed to restore posix capabilities to file %s !!!\n", realname); + } #ifdef LIBTAR_FILE_HASH pn = th_get_pathname(t); |