From 6b600f964471cef977821689185db687f67d2c19 Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Sun, 5 Jan 2014 18:13:43 -0500 Subject: Restore contexts when doing mkdierhier in libtar Do a restore of loaded file contexts to /data/media directory. This will help denials to be prevented when internal storage is wiped. Change-Id: Ie49bbfa48d2f3ee4f08376d9c1877b92c051017c --- partition.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index 95f6bcac4..974f7e4a5 100644 --- a/partition.cpp +++ b/partition.cpp @@ -40,6 +40,7 @@ #include "twrpDigest.hpp" #include "twrpTar.hpp" #include "twrpDU.hpp" +#include "fixPermissions.hpp" extern "C" { #include "mtdutils/mtdutils.h" #include "mtdutils/mounts.h" @@ -1511,6 +1512,9 @@ bool TWPartition::Wipe_F2FS() { bool TWPartition::Wipe_Data_Without_Wiping_Media() { string dir; + #ifdef HAVE_SELINUX + fixPermissions perms; + #endif // This handles wiping data on devices with "sdcard" in /data/media if (!Mount(true)) @@ -1541,6 +1545,10 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() { } closedir(d); + #ifdef HAVE_SELINUX + perms.fixDataInternalContexts(); + #endif + gui_print("Done.\n"); return true; } @@ -1811,12 +1819,19 @@ void TWPartition::Find_Actual_Block_Device(void) { void TWPartition::Recreate_Media_Folder(void) { string Command; + #ifdef HAVE_SELINUX + fixPermissions perms; + #endif + if (!Mount(true)) { LOGERR("Unable to recreate /data/media folder.\n"); } else if (!TWFunc::Path_Exists("/data/media")) { PartitionManager.Mount_By_Path(Symlink_Mount_Point, true); LOGINFO("Recreating /data/media folder.\n"); mkdir("/data/media", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + #ifdef HAVE_SELINUX + perms.fixDataInternalContexts(); + #endif PartitionManager.UnMount_By_Path(Symlink_Mount_Point, true); } } -- cgit v1.2.3