Check for /data/system/file_contexts first in restorecon.
diff --git a/src/android.c b/src/android.c
index 21741bf..ad7a018 100644
--- a/src/android.c
+++ b/src/android.c
@@ -28,8 +28,10 @@
"/seapp_contexts",
0 };
-#define FILE_CONTEXTS "/file_contexts"
-
+static const struct selinux_opt seopts[] = {
+ { SELABEL_OPT_PATH, "/data/system/file_contexts" },
+ { SELABEL_OPT_PATH, "/file_contexts" },
+ { 0, NULL } };
struct seapp_context {
/* input selectors */
@@ -486,12 +488,14 @@
static void file_context_init(void)
{
+ int i = 0;
- struct selinux_opt seopts[] = {
- { SELABEL_OPT_PATH, FILE_CONTEXTS }
- };
+ sehandle = NULL;
+ while ((sehandle == NULL) && seopts[i].value) {
+ sehandle = selabel_open(SELABEL_CTX_FILE, &seopts[i], 1);
+ i++;
+ }
- sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);
if (!sehandle)
selinux_log(SELINUX_ERROR,"%s: Error getting sehandle label (%s)\n",
__FUNCTION__, strerror(errno));