From b5fab76bea98dff8d0825d16c3dd359397449e9a Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 28 Jan 2016 14:03:33 -0600 Subject: Replace fix permissions with fix contexts for emulated storage Fix permissions rarely fixed anything on more recent versions of Android and usually made things worse. Instead we will replace it with a more dumbed down option that should fix contexts on /data/media with a few improvements to ensure that contexts get fixed for multiple users and on adopted storage. Change-Id: If5523781936a0b04196e2ad871cae767ebae2583 --- partitionmanager.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'partitionmanager.cpp') diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 81d448dc6..89580d069 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -37,7 +37,7 @@ #include "partitions.hpp" #include "data.hpp" #include "twrp-functions.hpp" -#include "fixPermissions.hpp" +#include "fixContexts.hpp" #include "twrpDigest.hpp" #include "twrpDU.hpp" #include "set_metadata.h" @@ -1490,25 +1490,24 @@ int TWPartitionManager::Decrypt_Device(string Password) { return 1; } -int TWPartitionManager::Fix_Permissions(void) { - int result = 0; - if (!Mount_By_Path("/data", true)) - return false; - - if (!Mount_By_Path("/system", true)) - return false; - - Mount_By_Path("/sd-ext", false); - - fixPermissions perms; - result = perms.fixPerms(true, false); +int TWPartitionManager::Fix_Contexts(void) { #ifdef HAVE_SELINUX - if (result == 0 && DataManager::GetIntValue("tw_fixperms_restorecon") == 1) - result = perms.fixContexts(); -#endif + std::vector::iterator iter; + for (iter = Partitions.begin(); iter != Partitions.end(); iter++) { + if ((*iter)->Has_Data_Media) { + if ((*iter)->Mount(true)) { + if (fixContexts::fixDataMediaContexts((*iter)->Mount_Point) != 0) + return -1; + } + } + } UnMount_Main_Partitions(); gui_msg("done=Done."); - return result; + return 0; +#else + LOGERR("Cannot fix contexts, no selinux support present.\n"); + return -1; +#endif } TWPartition* TWPartitionManager::Find_Next_Storage(string Path, bool Exclude_Data_Media) { -- cgit v1.2.3