mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 08:47:39 +00:00
Fix --remove-modules command
This commit is contained in:
parent
03c1053871
commit
5fd574a14f
@ -19,12 +19,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern vector<string> module_list;
|
||||
static bool no_secure_dir = false;
|
||||
static bool pfs_done = false;
|
||||
|
||||
extern void auto_start_magiskhide();
|
||||
|
||||
/*********
|
||||
* Setup *
|
||||
*********/
|
||||
@ -139,30 +136,13 @@ static bool magisk_env() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void reboot() {
|
||||
void reboot() {
|
||||
if (RECOVERY_MODE)
|
||||
exec_command_sync("/system/bin/reboot", "recovery");
|
||||
else
|
||||
exec_command_sync("/system/bin/reboot");
|
||||
}
|
||||
|
||||
void remove_modules() {
|
||||
LOGI("* Remove all modules and reboot");
|
||||
auto dir = xopen_dir(MODULEROOT);
|
||||
int dfd = dirfd(dir.get());
|
||||
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
||||
if (entry->d_type == DT_DIR) {
|
||||
if (entry->d_name == ".core"sv)
|
||||
continue;
|
||||
|
||||
int modfd = xopenat(dfd, entry->d_name, O_RDONLY | O_CLOEXEC);
|
||||
close(xopenat(modfd, "remove", O_RDONLY | O_CREAT | O_CLOEXEC));
|
||||
close(modfd);
|
||||
}
|
||||
}
|
||||
reboot();
|
||||
}
|
||||
|
||||
static bool check_data() {
|
||||
bool mnt = false;
|
||||
bool data = false;
|
||||
|
@ -56,6 +56,14 @@ static void *request_handler(void *args) {
|
||||
close(client);
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
case REMOVE_MODULES:
|
||||
if (credential.uid != UID_SHELL && credential.uid != UID_ROOT) {
|
||||
write_int(client, 1);
|
||||
close(client);
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -88,12 +96,8 @@ static void *request_handler(void *args) {
|
||||
exec_sql(client);
|
||||
break;
|
||||
case REMOVE_MODULES:
|
||||
if (credential.uid == UID_SHELL || credential.uid == UID_ROOT) {
|
||||
remove_modules();
|
||||
write_int(client, 0);
|
||||
} else {
|
||||
write_int(client, 1);
|
||||
}
|
||||
remove_modules();
|
||||
write_int(client, 0);
|
||||
close(client);
|
||||
break;
|
||||
case GET_PATH:
|
||||
|
@ -686,3 +686,23 @@ void handle_modules() {
|
||||
|
||||
mount_modules();
|
||||
}
|
||||
|
||||
void remove_modules() {
|
||||
LOGI("* Remove all modules and reboot\n");
|
||||
auto dir = open_dir(MODULEROOT);
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
int dfd = dirfd(dir.get());
|
||||
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
||||
if (entry->d_type == DT_DIR) {
|
||||
if (entry->d_name == ".core"sv)
|
||||
continue;
|
||||
|
||||
int modfd = xopenat(dfd, entry->d_name, O_RDONLY | O_CLOEXEC);
|
||||
close(xopenat(modfd, "remove", O_RDONLY | O_CREAT | O_CLOEXEC, 0));
|
||||
close(modfd);
|
||||
}
|
||||
}
|
||||
reboot();
|
||||
}
|
||||
|
@ -29,46 +29,28 @@ enum {
|
||||
DAEMON_LAST
|
||||
};
|
||||
|
||||
// daemon.cpp
|
||||
extern int SDK_INT;
|
||||
extern bool RECOVERY_MODE;
|
||||
extern std::vector<std::string> module_list;
|
||||
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
|
||||
|
||||
int connect_daemon(bool create = false);
|
||||
|
||||
/***************
|
||||
* Boot Stages *
|
||||
***************/
|
||||
|
||||
void unlock_blocks();
|
||||
// Daemon handlers
|
||||
void post_fs_data(int client);
|
||||
void late_start(int client);
|
||||
void boot_complete(int client);
|
||||
void handle_modules();
|
||||
void magiskhide_handler(int client);
|
||||
void su_daemon_handler(int client, struct ucred *credential);
|
||||
void remove_modules();
|
||||
|
||||
/*************
|
||||
* Scripting *
|
||||
*************/
|
||||
// Misc
|
||||
int connect_daemon(bool create = false);
|
||||
void auto_start_magiskhide();
|
||||
void unlock_blocks();
|
||||
void handle_modules();
|
||||
void reboot();
|
||||
|
||||
// Scripting
|
||||
void exec_script(const char *script);
|
||||
void exec_common_script(const char *stage);
|
||||
void exec_module_script(const char *stage, const std::vector<std::string> &module_list);
|
||||
void install_apk(const char *apk);
|
||||
|
||||
/**************
|
||||
* MagiskHide *
|
||||
**************/
|
||||
|
||||
void magiskhide_handler(int client);
|
||||
|
||||
/*************
|
||||
* Superuser *
|
||||
*************/
|
||||
|
||||
void su_daemon_handler(int client, struct ucred *credential);
|
||||
|
||||
/*********************
|
||||
* Daemon Global Vars
|
||||
*********************/
|
||||
|
||||
extern int SDK_INT;
|
||||
extern bool RECOVERY_MODE;
|
||||
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <magisk.hpp>
|
||||
#include <utils.hpp>
|
||||
#include <db.hpp>
|
||||
#include <daemon.hpp>
|
||||
|
||||
#include "magiskhide.hpp"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user