From 7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Fri, 13 Jan 2017 13:30:10 -0600 Subject: libtar: backup and restore posix capabilities This patch also allows libtar to combine data from multiple extended tar headers into a single header. Change-Id: I82d13e89a3622ea665b60062b1904ddbedfa41b3 --- libtar/extract.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libtar/extract.c') diff --git a/libtar/extract.c b/libtar/extract.c index ba29a7771..9e24e8ee7 100644 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -20,6 +20,10 @@ #include #include +#include +#include +#include + #ifdef STDC_HEADERS # include #endif @@ -166,6 +170,16 @@ tar_extract_file(TAR *t, const char *realname, const char *prefix, const int *pr } #endif + 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); pathname_len = strlen(pn) + 1; -- cgit v1.2.3