diff options
author | Dees Troy <dees_troy@teamw.in> | 2013-09-05 21:53:36 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@198.50.184.117> | 2013-09-05 21:53:36 +0200 |
commit | 8807a1ead605b54d86ba96466aee648fcd189ab4 (patch) | |
tree | 6b7cde9b953529948a725a606078818731db69fc /libtar/extract.c | |
parent | Extract file_contexts from zips if it exists (diff) | |
parent | libtar: store SELinux file context in tar archives (diff) | |
download | android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar.gz android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar.bz2 android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar.lz android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar.xz android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.tar.zst android_bootable_recovery-8807a1ead605b54d86ba96466aee648fcd189ab4.zip |
Diffstat (limited to 'libtar/extract.c')
-rw-r--r-- | libtar/extract.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libtar/extract.c b/libtar/extract.c index 613e29fff..d19ba859d 100644 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -154,6 +154,18 @@ tar_extract_file(TAR *t, char *realname, char *prefix) printf("FAILED SETTING PERMS: %d\n", i); return i; } + +#ifdef HAVE_SELINUX + if((t->options & TAR_STORE_SELINUX) && t->th_buf.selinux_context != NULL) + { +#ifdef DEBUG + printf(" Restoring SELinux context %s to file %s\n", t->th_buf.selinux_context, realname); +#endif + if(setfilecon(realname, t->th_buf.selinux_context) < 0) + fprintf(stderr, "Failed to restore SELinux context %s!\n", strerror(errno)); + } +#endif + /* pathname_len = strlen(th_get_pathname(t)) + 1; realname_len = strlen(realname) + 1; |