diff options
author | Jin Qian <jinqian@google.com> | 2017-06-20 13:49:53 -0700 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-02-26 12:22:52 -0500 |
commit | 99c4785d7d823e3eb9d03432db35c8b73ab9f66d (patch) | |
tree | d8571d4bddcc32e2d15537ed074b92b40f114d02 | |
parent | 38aaf9d5b4952146fa4c13be040b20d07a278b20 (diff) | |
download | e2fsprogs-99c4785d7d823e3eb9d03432db35c8b73ab9f66d.tar.gz |
AOSP: 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
From AOSP commit: c0bd89b31a7719dd3d51137b3d47a9597ba6b038
-rw-r--r-- | contrib/android/perms.c | 9 | ||||
-rw-r--r-- | contrib/android/perms.h | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/contrib/android/perms.c b/contrib/android/perms.c index b9b2463f4..1a822cfea 100644 --- a/contrib/android/perms.c +++ b/contrib/android/perms.c @@ -291,6 +291,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) { @@ -300,6 +301,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 9955bb56b..c404cb905 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> |