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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user