Remove invincible mode
This commit is contained in:
parent
a6958ac139
commit
d08fd0561a
@ -95,30 +95,6 @@ static void *start_magisk_hide(void *args) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void daemon_saver() {
|
||||
int fd, val;
|
||||
struct sockaddr_un sun;
|
||||
|
||||
// Change process name
|
||||
strcpy(argv0, "magisk_saver");
|
||||
|
||||
while (1) {
|
||||
fd = setup_socket(&sun);
|
||||
while(connect(fd, (struct sockaddr*) &sun, sizeof(sun)))
|
||||
usleep(10000);
|
||||
|
||||
write_int(fd, DO_NOTHING);
|
||||
|
||||
// Should hold forever unless the other side is closed
|
||||
read(fd, &val, sizeof(int));
|
||||
|
||||
// If it came here, the daemon is terminated
|
||||
close(fd);
|
||||
if (fork_dont_care() == 0)
|
||||
start_daemon(0);
|
||||
}
|
||||
}
|
||||
|
||||
void auto_start_magiskhide() {
|
||||
char *hide_prop = getprop2(MAGISKHIDE_PROP, 1);
|
||||
if (hide_prop == NULL || strcmp(hide_prop, "0") != 0) {
|
||||
@ -129,7 +105,7 @@ void auto_start_magiskhide() {
|
||||
free(hide_prop);
|
||||
}
|
||||
|
||||
void start_daemon(int post_fs_data) {
|
||||
void start_daemon() {
|
||||
setsid();
|
||||
setcon("u:r:"SEPOL_PROC_DOMAIN":s0");
|
||||
int fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
|
||||
@ -138,9 +114,6 @@ void start_daemon(int post_fs_data) {
|
||||
xdup2(fd, STDERR_FILENO);
|
||||
close(fd);
|
||||
|
||||
if (post_fs_data && fork_dont_care() == 0)
|
||||
daemon_saver();
|
||||
|
||||
// Block user signals
|
||||
sigset_t block_set;
|
||||
sigemptyset(&block_set);
|
||||
@ -158,13 +131,6 @@ void start_daemon(int post_fs_data) {
|
||||
// Start the log monitor
|
||||
monitor_logs();
|
||||
|
||||
if (!post_fs_data && (access(MAGISKTMP, F_OK) == 0)) {
|
||||
// Restart stuffs if the daemon is restarted
|
||||
exec_command_sync("logcat", "-b", "all", "-c", NULL);
|
||||
auto_start_magiskhide();
|
||||
start_debug_log();
|
||||
}
|
||||
|
||||
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n");
|
||||
|
||||
// Change process name
|
||||
@ -182,7 +148,7 @@ void start_daemon(int post_fs_data) {
|
||||
}
|
||||
|
||||
/* Connect the daemon, and return a socketfd */
|
||||
int connect_daemon(int post_fs_data) {
|
||||
int connect_daemon() {
|
||||
struct sockaddr_un sun;
|
||||
int fd = setup_socket(&sun);
|
||||
if (connect(fd, (struct sockaddr*) &sun, sizeof(sun))) {
|
||||
@ -196,7 +162,7 @@ int connect_daemon(int post_fs_data) {
|
||||
if (fork_dont_care() == 0) {
|
||||
LOGD("client: connect fail, try launching new daemon process\n");
|
||||
close(fd);
|
||||
start_daemon(post_fs_data);
|
||||
start_daemon();
|
||||
}
|
||||
|
||||
while (connect(fd, (struct sockaddr*) &sun, sizeof(sun)))
|
||||
|
@ -71,14 +71,14 @@ int magisk_main(int argc, char *argv[]) {
|
||||
printf("%s (%d)\n", MAGISK_VER_STR, MAGISK_VER_CODE);
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "-v") == 0) {
|
||||
int fd = connect_daemon(0);
|
||||
int fd = connect_daemon();
|
||||
write_int(fd, CHECK_VERSION);
|
||||
char *v = read_string(fd);
|
||||
printf("%s\n", v);
|
||||
free(v);
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "-V") == 0) {
|
||||
int fd = connect_daemon(0);
|
||||
int fd = connect_daemon();
|
||||
write_int(fd, CHECK_VERSION_CODE);
|
||||
printf("%d\n", read_int(fd));
|
||||
return 0;
|
||||
@ -143,18 +143,18 @@ int magisk_main(int argc, char *argv[]) {
|
||||
clone_attr(argv[2], argv[3]);
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "--daemon") == 0) {
|
||||
int fd = connect_daemon(0);
|
||||
int fd = connect_daemon();
|
||||
close(fd);
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "--startup") == 0) {
|
||||
startup();
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "--post-fs-data") == 0) {
|
||||
int fd = connect_daemon(1);
|
||||
int fd = connect_daemon();
|
||||
write_int(fd, POST_FS_DATA);
|
||||
return read_int(fd);
|
||||
} else if (strcmp(argv[1], "--service") == 0) {
|
||||
int fd = connect_daemon(0);
|
||||
int fd = connect_daemon();
|
||||
write_int(fd, LATE_START);
|
||||
return read_int(fd);
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ enum {
|
||||
|
||||
// daemon.c
|
||||
|
||||
void start_daemon(int post_fs_data);
|
||||
int connect_daemon(int post_fs_data);
|
||||
void start_daemon();
|
||||
int connect_daemon();
|
||||
void auto_start_magiskhide();
|
||||
|
||||
// socket.c
|
||||
|
@ -135,7 +135,7 @@ int magiskhide_main(int argc, char *argv[]) {
|
||||
} else {
|
||||
usage(argv[0]);
|
||||
}
|
||||
int fd = connect_daemon(0);
|
||||
int fd = connect_daemon();
|
||||
write_int(fd, req);
|
||||
if (req == ADD_HIDELIST || req == RM_HIDELIST) {
|
||||
write_string(fd, argv[2]);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2c5a36a8da625079a0617c0d06f96f444c4d4bf4
|
||||
Subproject commit 29d5740205753f911123e6672a53d8d3414e49dc
|
Loading…
Reference in New Issue
Block a user