Update policy for handling /data/adb
This commit is contained in:
parent
99ef20627a
commit
fc1844b4df
@ -20,7 +20,6 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static bool pfs_done = false;
|
static bool pfs_done = false;
|
||||||
static bool no_secure_dir = false;
|
|
||||||
static bool safe_mode = false;
|
static bool safe_mode = false;
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
@ -225,11 +224,6 @@ static void collect_logs(bool reset) {
|
|||||||
* Entry points *
|
* Entry points *
|
||||||
****************/
|
****************/
|
||||||
|
|
||||||
[[noreturn]] static void exit_post_fs_data() {
|
|
||||||
close(xopen(UNBLOCKFILE, O_RDONLY | O_CREAT, 0));
|
|
||||||
pthread_exit(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void post_fs_data(int client) {
|
void post_fs_data(int client) {
|
||||||
// ack
|
// ack
|
||||||
write_int(client, 0);
|
write_int(client, 0);
|
||||||
@ -239,7 +233,7 @@ void post_fs_data(int client) {
|
|||||||
xmount(nullptr, "/", nullptr, MS_REMOUNT | MS_RDONLY, nullptr);
|
xmount(nullptr, "/", nullptr, MS_REMOUNT | MS_RDONLY, nullptr);
|
||||||
|
|
||||||
if (!check_data())
|
if (!check_data())
|
||||||
exit_post_fs_data();
|
goto unblock_init;
|
||||||
|
|
||||||
collect_logs(true);
|
collect_logs(true);
|
||||||
|
|
||||||
@ -249,17 +243,21 @@ void post_fs_data(int client) {
|
|||||||
unlock_blocks();
|
unlock_blocks();
|
||||||
|
|
||||||
if (access(SECURE_DIR, F_OK) != 0) {
|
if (access(SECURE_DIR, F_OK) != 0) {
|
||||||
/* If the folder is not automatically created by the system,
|
if (SDK_INT < 24) {
|
||||||
* do NOT proceed further. Manual creation of the folder
|
// There is no FBE pre 7.0, we can directly create the folder without issues
|
||||||
* will cause bootloops on FBE devices. */
|
xmkdir(SECURE_DIR, 0700);
|
||||||
LOGE(SECURE_DIR " is not present, abort...");
|
} else {
|
||||||
no_secure_dir = true;
|
/* If the folder is not automatically created by Android,
|
||||||
exit_post_fs_data();
|
* do NOT proceed further. Manual creation of the folder
|
||||||
|
* will cause bootloops on FBE devices. */
|
||||||
|
LOGE(SECURE_DIR " is not present, abort...\n");
|
||||||
|
goto unblock_init;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!magisk_env()) {
|
if (!magisk_env()) {
|
||||||
LOGE("* Magisk environment setup incomplete, abort\n");
|
LOGE("* Magisk environment setup incomplete, abort\n");
|
||||||
exit_post_fs_data();
|
goto unblock_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getprop("persist.sys.safemode", true) == "1") {
|
if (getprop("persist.sys.safemode", true) == "1") {
|
||||||
@ -273,10 +271,12 @@ void post_fs_data(int client) {
|
|||||||
handle_modules();
|
handle_modules();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We still want to do magic mount because root itself might need it
|
// We still do magic mount because root itself might need it
|
||||||
magic_mount();
|
magic_mount();
|
||||||
pfs_done = true;
|
pfs_done = true;
|
||||||
exit_post_fs_data();
|
|
||||||
|
unblock_init:
|
||||||
|
close(xopen(UNBLOCKFILE, O_RDONLY | O_CREAT, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void late_start(int client) {
|
void late_start(int client) {
|
||||||
@ -287,14 +287,6 @@ void late_start(int client) {
|
|||||||
|
|
||||||
collect_logs(false);
|
collect_logs(false);
|
||||||
|
|
||||||
if (no_secure_dir) {
|
|
||||||
// It's safe to create the folder at this point if the system didn't create it
|
|
||||||
if (access(SECURE_DIR, F_OK) != 0)
|
|
||||||
xmkdir(SECURE_DIR, 0700);
|
|
||||||
// And reboot to make proper setup possible
|
|
||||||
reboot();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pfs_done || safe_mode)
|
if (!pfs_done || safe_mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -310,10 +302,16 @@ void boot_complete(int client) {
|
|||||||
|
|
||||||
collect_logs(false);
|
collect_logs(false);
|
||||||
|
|
||||||
if (!pfs_done || safe_mode)
|
if (safe_mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto_start_magiskhide();
|
/* It's safe to create the folder at this point if the system didn't create it
|
||||||
|
* Magisk Manager should finish up the remaining environment setup */
|
||||||
|
if (access(SECURE_DIR, F_OK) != 0)
|
||||||
|
xmkdir(SECURE_DIR, 0700);
|
||||||
|
|
||||||
|
if (pfs_done)
|
||||||
|
auto_start_magiskhide();
|
||||||
|
|
||||||
if (access(MANAGERAPK, F_OK) == 0) {
|
if (access(MANAGERAPK, F_OK) == 0) {
|
||||||
// Install Magisk Manager if exists
|
// Install Magisk Manager if exists
|
||||||
|
Loading…
Reference in New Issue
Block a user