summaryrefslogtreecommitdiffstats
path: root/libtar/append.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/append.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 '')
-rw-r--r--libtar/append.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libtar/append.c b/libtar/append.c
index 438829753..7c679f66d 100644
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -22,6 +22,10 @@
#include <sys/types.h>
#include <stdbool.h>
+#include <sys/capability.h>
+#include <sys/xattr.h>
+#include <linux/xattr.h>
+
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
@@ -154,6 +158,24 @@ tar_append_file(TAR *t, const char *realname, const char *savename)
}
#endif
+ /* get posix file capabilities */
+ if (TH_ISREG(t) && t->options & TAR_STORE_POSIX_CAP)
+ {
+ if (t->th_buf.has_cap_data)
+ {
+ memset(&t->th_buf.cap_data, 0, sizeof(struct vfs_cap_data));
+ t->th_buf.has_cap_data = 0;
+ }
+
+ if (getxattr(realname, XATTR_NAME_CAPS, &t->th_buf.cap_data, sizeof(struct vfs_cap_data)) >= 0)
+ {
+ t->th_buf.has_cap_data = 1;
+#if 1 //def DEBUG
+ print_caps(&t->th_buf.cap_data);
+#endif
+ }
+ }
+
/* check if it's a hardlink */
#ifdef DEBUG
puts("tar_append_file(): checking inode cache for hardlink...");