aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian <jinqian@google.com>2017-06-20 13:49:53 -0700
committerJin Qian <jinqian@google.com>2017-06-26 17:14:22 -0700
commit2fff6fb036cbbb6dedd7da3d208b312a9038a5ce (patch)
tree39bd1712eca2a32c84f373f843456f97b0c9c0c7
parent778eaa84a0e539e755ef0a8c1928685eddb87aaf (diff)
downloadandroid_external_e2fsprogs-2fff6fb036cbbb6dedd7da3d208b312a9038a5ce.tar.gz
android_external_e2fsprogs-2fff6fb036cbbb6dedd7da3d208b312a9038a5ce.tar.bz2
android_external_e2fsprogs-2fff6fb036cbbb6dedd7da3d208b312a9038a5ce.zip
e2fsdroid: use libselinux function to read file context on device
When e2fsdroid runs on device, location of selinux file contexts should be determined by libselinux instead of using arbitrary paths. Bug: 35219933 Change-Id: I413b198422eddb212599498b532ba2c4d8bb36c6 Merged-In: I413b198422eddb212599498b532ba2c4d8bb36c6
-rw-r--r--contrib/android/perms.c9
-rw-r--r--contrib/android/perms.h2
2 files changed, 10 insertions, 1 deletions
diff --git a/contrib/android/perms.c b/contrib/android/perms.c
index 9a7a93f5..9ae8e586 100644
--- a/contrib/android/perms.c
+++ b/contrib/android/perms.c
@@ -297,6 +297,7 @@ errcode_t android_configure_fs(ext2_filsys fs, char *src_dir, char *target_out,
struct selabel_handle *sehnd = NULL;
/* Retrieve file contexts */
+#if !defined(__ANDROID__)
if (nopt > 0) {
sehnd = selabel_open(SELABEL_CTX_FILE, seopts, nopt);
if (!sehnd) {
@@ -306,6 +307,14 @@ errcode_t android_configure_fs(ext2_filsys fs, char *src_dir, char *target_out,
return -EINVAL;
}
}
+#else
+ sehnd = selinux_android_file_context_handle();
+ if (!sehnd) {
+ com_err(__func__, -EINVAL,
+ _("while opening android file_contexts"));
+ return -EINVAL;
+ }
+#endif
/* Load the FS config */
if (fs_config_file) {
diff --git a/contrib/android/perms.h b/contrib/android/perms.h
index 9955bb56..c404cb90 100644
--- a/contrib/android/perms.h
+++ b/contrib/android/perms.h
@@ -25,7 +25,7 @@ static inline errcode_t android_configure_fs(ext2_filsys fs,
# else
# include <selinux/selinux.h>
# include <selinux/label.h>
-# if !defined(HOST)
+# if defined(__ANDROID__)
# include <selinux/android.h>
# endif
# include <private/android_filesystem_config.h>