fix getting and setting contexts in selinux
recreate lost+found with selinux contexts
Change-Id: I19e8696d47319dfb641520956c8a27c2a796a0c3
diff --git a/twrp.cpp b/twrp.cpp
index 765cad3..56ffedb 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -104,10 +104,18 @@
gui_loadResources();
#ifdef HAVE_SELINUX
+ if (TWFunc::Path_Exists("/prebuilt_file_contexts")) {
+ if (TWFunc::Path_Exists("/file_contexts")) {
+ printf("Renaming regular /file_contexts -> /file_contexts.bak\n");
+ rename("/file_contexts", "/file_contexts.bak");
+ }
+ printf("Moving /prebuilt_file_contexts -> /file_contexts\n");
+ rename("/prebuilt_file_contexts", "/file_contexts");
+ }
struct selinux_opt selinux_options[] = {
{ SELABEL_OPT_PATH, "/file_contexts" }
};
- selinux_handle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1);
+ selinux_handle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1);
if (!selinux_handle)
printf("No file contexts for SELinux\n");
else