summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordianlujitao <dianlujitao@lineageos.org>2019-05-15 09:33:27 +0200
committerdianlujitao <dianlujitao@lineageos.org>2019-05-15 10:27:17 +0200
commit3cf05a569ed988a9030208db2483bc548bebc150 (patch)
tree99fc8d474bfe21fe72a9f877dcf274a971dc0a73
parentMerge "Pass file_contexts path to e2fsdroid" into android-9.0 (diff)
downloadandroid_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar.gz
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar.bz2
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar.lz
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar.xz
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.tar.zst
android_bootable_recovery-3cf05a569ed988a9030208db2483bc548bebc150.zip
-rw-r--r--partition.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/partition.cpp b/partition.cpp
index 88c2cd3a5..e00322b52 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -2080,13 +2080,19 @@ bool TWPartition::Wipe_EXTFS(string File_System) {
}
if (TWFunc::Path_Exists("/sbin/e2fsdroid")) {
- // Execute e2fsdroid to initialize selinux context
- Command = "e2fsdroid -e -S /file_contexts -a " + Mount_Point + " " + Actual_Block_Device;
- LOGINFO("e2fsdroid command: %s\n", Command.c_str());
- ret = TWFunc::Exec_Cmd(Command);
- if (ret) {
- gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
- return false;
+ const string& File_Contexts_Entry = (Mount_Point == "/system_root" ? "/" : Mount_Point);
+ char *secontext = NULL;
+ if (!selinux_handle || selabel_lookup(selinux_handle, &secontext, File_Contexts_Entry.c_str(), S_IFDIR) < 0) {
+ LOGINFO("Cannot lookup security context for '%s'\n", Mount_Point.c_str());
+ } else {
+ // Execute e2fsdroid to initialize selinux context
+ Command = "e2fsdroid -e -S /file_contexts -a " + File_Contexts_Entry + " " + Actual_Block_Device;
+ LOGINFO("e2fsdroid command: %s\n", Command.c_str());
+ ret = TWFunc::Exec_Cmd(Command);
+ if (ret) {
+ gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
+ return false;
+ }
}
} else {
LOGINFO("e2fsdroid not present\n");