mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 20:27:37 +00:00
Handle zygote restarts
This commit is contained in:
parent
9c774f96db
commit
490a784993
@ -356,7 +356,7 @@ void boot_complete(int client) {
|
||||
DAEMON_STATE = STATE_BOOT_COMPLETE;
|
||||
setup_logfile(false);
|
||||
|
||||
LOGI("** boot_complete triggered\n");
|
||||
LOGI("** boot-complete triggered\n");
|
||||
|
||||
if (safe_mode)
|
||||
return;
|
||||
@ -366,5 +366,14 @@ void boot_complete(int client) {
|
||||
xmkdir(SECURE_DIR, 0700);
|
||||
|
||||
// Ensure manager exists
|
||||
need_pkg_refresh();
|
||||
get_manager(0, nullptr, true);
|
||||
}
|
||||
|
||||
void zygote_restart(int client) {
|
||||
close(client);
|
||||
|
||||
LOGI("** zygote restarted\n");
|
||||
pkg_xml_ino = 0;
|
||||
prune_su_access();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
extern bool RECOVERY_MODE;
|
||||
extern int DAEMON_STATE;
|
||||
extern std::atomic<ino_t> pkg_xml_ino;
|
||||
|
||||
// Daemon state
|
||||
enum : int {
|
||||
|
@ -150,6 +150,9 @@ static void handle_request_async(int client, int code, const sock_cred &cred) {
|
||||
case MainRequest::BOOT_COMPLETE:
|
||||
boot_complete(client);
|
||||
break;
|
||||
case MainRequest::ZYGOTE_RESTART:
|
||||
zygote_restart(client);
|
||||
break;
|
||||
case MainRequest::SQLITE_CMD:
|
||||
exec_sql(client);
|
||||
break;
|
||||
@ -233,6 +236,7 @@ static void handle_request(pollfd *pfd) {
|
||||
case MainRequest::POST_FS_DATA:
|
||||
case MainRequest::LATE_START:
|
||||
case MainRequest::BOOT_COMPLETE:
|
||||
case MainRequest::ZYGOTE_RESTART:
|
||||
case MainRequest::SQLITE_CMD:
|
||||
case MainRequest::GET_PATH:
|
||||
case MainRequest::DENYLIST:
|
||||
|
@ -29,9 +29,8 @@ Options:
|
||||
Advanced Options (Internal APIs):
|
||||
--daemon manually start magisk daemon
|
||||
--stop remove all magisk changes and stop daemon
|
||||
--[init trigger] start service for init trigger
|
||||
Supported init triggers:
|
||||
post-fs-data, service, boot-complete
|
||||
--[init trigger] callback on init triggers. Valid triggers:
|
||||
post-fs-data, service, boot-complete, zygote-restart
|
||||
--unlock-blocks set BLKROSET flag to OFF for all block devices
|
||||
--restorecon restore selinux context on Magisk files
|
||||
--clone-attr SRC DEST clone permission, owner, and selinux context
|
||||
@ -95,6 +94,9 @@ int magisk_main(int argc, char *argv[]) {
|
||||
} else if (argv[1] == "--boot-complete"sv) {
|
||||
close(connect_daemon(MainRequest::BOOT_COMPLETE));
|
||||
return 0;
|
||||
} else if (argv[1] == "--zygote-restart"sv) {
|
||||
close(connect_daemon(MainRequest::ZYGOTE_RESTART));
|
||||
return 0;
|
||||
} else if (argv[1] == "--denylist"sv) {
|
||||
return denylist_cli(argc - 1, argv + 1);
|
||||
} else if (argc >= 3 && argv[1] == "--sqlite"sv) {
|
||||
|
@ -14,7 +14,7 @@ using namespace std;
|
||||
// so performance is absolutely critical. Most operations should either have its result cached
|
||||
// or simply skipped unless necessary.
|
||||
|
||||
static atomic<ino_t> pkg_xml_ino = 0;
|
||||
atomic<ino_t> pkg_xml_ino = 0;
|
||||
static atomic_flag skip_check;
|
||||
|
||||
static pthread_mutex_t pkg_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
@ -28,6 +28,7 @@ enum : int {
|
||||
POST_FS_DATA,
|
||||
LATE_START,
|
||||
BOOT_COMPLETE,
|
||||
ZYGOTE_RESTART,
|
||||
DENYLIST,
|
||||
SQLITE_CMD,
|
||||
REMOVE_MODULES,
|
||||
@ -81,6 +82,7 @@ void android_logging();
|
||||
void post_fs_data(int client);
|
||||
void late_start(int client);
|
||||
void boot_complete(int client);
|
||||
void zygote_restart(int client);
|
||||
void denylist_handler(int client, const sock_cred *cred);
|
||||
void su_daemon_handler(int client, const sock_cred *cred);
|
||||
void zygisk_handler(int client, const sock_cred *cred);
|
||||
@ -90,6 +92,7 @@ void preserve_stub_apk();
|
||||
bool need_pkg_refresh();
|
||||
std::vector<bool> get_app_no_list();
|
||||
int get_manager(int user_id = 0, std::string *pkg = nullptr, bool install = false);
|
||||
void prune_su_access();
|
||||
|
||||
// Denylist
|
||||
void initialize_denylist();
|
||||
|
@ -31,4 +31,12 @@ constexpr char MAGISK_RC[] =
|
||||
"on property:sys.boot_completed=1\n"
|
||||
" exec %1$s/magisk --boot-complete\n"
|
||||
"\n"
|
||||
|
||||
"on property:init.svc.zygote=restarting\n"
|
||||
" exec %1$s/magisk --zygote-restart\n"
|
||||
"\n"
|
||||
|
||||
"on property:init.svc.zygote=stopped\n"
|
||||
" exec %1$s/magisk --zygote-restart\n"
|
||||
"\n"
|
||||
;
|
||||
|
@ -137,7 +137,7 @@ bool uid_granted_root(int uid) {
|
||||
return granted;
|
||||
}
|
||||
|
||||
static void prune_su_access() {
|
||||
void prune_su_access() {
|
||||
vector<bool> app_no_list = get_app_no_list();
|
||||
vector<int> rm_uids;
|
||||
char query[256], *err;
|
||||
|
Loading…
x
Reference in New Issue
Block a user