summaryrefslogtreecommitdiffstats
path: root/libtar/extract.c
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2017-01-13 20:30:10 +0100
committerDees Troy <dees_troy@teamw.in>2017-01-18 17:11:33 +0100
commit7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8 (patch)
treec04d4c315064be2dd94f58717ea4d2773f03fb87 /libtar/extract.c
parentADBbackups: Fix wrong owner on binary backups. (diff)
downloadandroid_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar.gz
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar.bz2
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar.lz
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar.xz
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.tar.zst
android_bootable_recovery-7118774ec94bb1a2e8ef7a5f8cbcb6b781ccfdd8.zip
Diffstat (limited to 'libtar/extract.c')
-rw-r--r--libtar/extract.c14
1 files changed, 14 insertions, 0 deletions
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 <errno.h>
#include <utime.h>
+#include <sys/capability.h>
+#include <sys/xattr.h>
+#include <linux/xattr.h>
+
#ifdef STDC_HEADERS
# include <stdlib.h>
#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;