Skip to content

Commit

Permalink
Make sure native bridge is restored on daemon restart
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Nov 9, 2023
1 parent ef48abf commit 977c981
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion native/src/core/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,24 @@ static void handle_request_sync(int client, int code) {
case MainRequest::START_DAEMON:
rust::get_magiskd().setup_logfile();
break;
case MainRequest::STOP_DAEMON:
case MainRequest::STOP_DAEMON: {
// Unmount all overlays
denylist_handler(-1, nullptr);

// Restore native bridge property
auto nb = get_prop(NBPROP);
auto len = sizeof(ZYGISKLDR) - 1;
if (nb == ZYGISKLDR) {
set_prop(NBPROP, "0");
} else if (nb.size() > len) {
set_prop(NBPROP, nb.data() + len);
}

write_int(client, 0);

// Terminate the daemon!
exit(0);
}
default:
__builtin_unreachable();
}
Expand Down

0 comments on commit 977c981

Please sign in to comment.