summaryrefslogtreecommitdiffstats
path: root/libtar/append.c
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2013-08-27 03:10:10 +0200
committerVojtech Bocek <vbocek@gmail.com>2013-09-05 21:43:52 +0200
commit25fd68d0989254bdf921bcd118c4bae4d8afc419 (patch)
treeeb09b5a22aa0a5a2ff881547d769f042a74eebb0 /libtar/append.c
parentUpdate to latest AOSP master (diff)
downloadandroid_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar.gz
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar.bz2
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar.lz
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar.xz
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.tar.zst
android_bootable_recovery-25fd68d0989254bdf921bcd118c4bae4d8afc419.zip
Diffstat (limited to '')
-rw-r--r--libtar/append.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libtar/append.c b/libtar/append.c
index 05024b926..3a8bfc690 100644
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -90,6 +90,31 @@ tar_append_file(TAR *t, char *realname, char *savename)
#endif
th_set_path(t, (savename ? savename : realname));
+#ifdef HAVE_SELINUX
+ /* get selinux context */
+ 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)
+ {
+ t->th_buf.selinux_context = strdup(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...");