mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 13:35:27 +00:00
Restart MagiskHide if daemon restarted
This commit is contained in:
parent
e645c6e465
commit
0327fd9710
@ -551,11 +551,6 @@ static int prepare_img() {
|
|||||||
* Entry points *
|
* Entry points *
|
||||||
****************/
|
****************/
|
||||||
|
|
||||||
static void *start_magisk_hide(void *args) {
|
|
||||||
launch_magiskhide(-1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void unblock_boot_process() {
|
static void unblock_boot_process() {
|
||||||
close(open(UNBLOCKFILE, O_RDONLY | O_CREAT));
|
close(open(UNBLOCKFILE, O_RDONLY | O_CREAT));
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
@ -728,14 +723,8 @@ core_only:
|
|||||||
bind_mount(HOSTSFILE, "/system/etc/hosts");
|
bind_mount(HOSTSFILE, "/system/etc/hosts");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable magiskhide by default, only disable when set explicitly
|
auto_start_magiskhide();
|
||||||
char *hide_prop = getprop(MAGISKHIDE_PROP);
|
|
||||||
if (hide_prop == NULL || strcmp(hide_prop, "0") != 0) {
|
|
||||||
pthread_t thread;
|
|
||||||
xpthread_create(&thread, NULL, start_magisk_hide, NULL);
|
|
||||||
pthread_detach(thread);
|
|
||||||
}
|
|
||||||
free(hide_prop);
|
|
||||||
|
|
||||||
unblock:
|
unblock:
|
||||||
unblock_boot_process();
|
unblock_boot_process();
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
#include "magiskpolicy.h"
|
#include "magiskpolicy.h"
|
||||||
|
#include "resetprop.h"
|
||||||
|
|
||||||
pthread_t sepol_patch;
|
pthread_t sepol_patch;
|
||||||
|
int is_restart = 0;
|
||||||
|
|
||||||
static void *request_handler(void *args) {
|
static void *request_handler(void *args) {
|
||||||
// Setup the default error handler for threads
|
// Setup the default error handler for threads
|
||||||
@ -114,6 +116,21 @@ static void *large_sepol_patch(void *args) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *start_magisk_hide(void *args) {
|
||||||
|
launch_magiskhide(-1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void auto_start_magiskhide() {
|
||||||
|
char *hide_prop = getprop2(MAGISKHIDE_PROP, 1);
|
||||||
|
if (hide_prop == NULL || strcmp(hide_prop, "0") != 0) {
|
||||||
|
pthread_t thread;
|
||||||
|
xpthread_create(&thread, NULL, start_magisk_hide, NULL);
|
||||||
|
pthread_detach(thread);
|
||||||
|
}
|
||||||
|
free(hide_prop);
|
||||||
|
}
|
||||||
|
|
||||||
void start_daemon() {
|
void start_daemon() {
|
||||||
setcon("u:r:su:s0");
|
setcon("u:r:su:s0");
|
||||||
umask(0);
|
umask(0);
|
||||||
@ -123,9 +140,17 @@ void start_daemon() {
|
|||||||
xdup2(fd, STDERR_FILENO);
|
xdup2(fd, STDERR_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
if ((is_restart = check_data())) {
|
||||||
|
// Restart many stuffs
|
||||||
|
auto_start_magiskhide();
|
||||||
|
start_debug_log();
|
||||||
|
}
|
||||||
|
|
||||||
// Start the log monitor
|
// Start the log monitor
|
||||||
monitor_logs();
|
monitor_logs();
|
||||||
|
|
||||||
|
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n");
|
||||||
|
|
||||||
// Patch selinux with medium patch before we do anything
|
// Patch selinux with medium patch before we do anything
|
||||||
load_policydb(SELINUX_POLICY);
|
load_policydb(SELINUX_POLICY);
|
||||||
sepol_med_rules();
|
sepol_med_rules();
|
||||||
@ -146,8 +171,6 @@ void start_daemon() {
|
|||||||
// It should stay intact under any circumstances
|
// It should stay intact under any circumstances
|
||||||
err_handler = do_nothing;
|
err_handler = do_nothing;
|
||||||
|
|
||||||
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n");
|
|
||||||
|
|
||||||
// Unlock all blocks for rw
|
// Unlock all blocks for rw
|
||||||
unlock_blocks();
|
unlock_blocks();
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
int logcat_events[] = { -1, -1, -1 };
|
int logcat_events[] = { -1, -1, -1 };
|
||||||
|
extern int is_restart;
|
||||||
static int is_restart = 0;
|
|
||||||
|
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
static int debug_log_pid, debug_log_fd;
|
static int debug_log_pid, debug_log_fd;
|
||||||
@ -120,20 +119,10 @@ static void *debug_magisk_log_thread(void *args) {
|
|||||||
void monitor_logs() {
|
void monitor_logs() {
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
is_restart = check_data();
|
|
||||||
|
|
||||||
// Start log file dumper before monitor
|
// Start log file dumper before monitor
|
||||||
xpthread_create(&thread, NULL, magisk_log_thread, NULL);
|
xpthread_create(&thread, NULL, magisk_log_thread, NULL);
|
||||||
pthread_detach(thread);
|
pthread_detach(thread);
|
||||||
|
|
||||||
#ifdef MAGISK_DEBUG
|
|
||||||
if (is_restart) {
|
|
||||||
// Restart debug logs
|
|
||||||
xpthread_create(&thread, NULL, debug_magisk_log_thread, NULL);
|
|
||||||
pthread_detach(thread);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Start logcat monitor
|
// Start logcat monitor
|
||||||
xpthread_create(&thread, NULL, logger_thread, NULL);
|
xpthread_create(&thread, NULL, logger_thread, NULL);
|
||||||
pthread_detach(thread);
|
pthread_detach(thread);
|
||||||
@ -158,5 +147,15 @@ void stop_debug_full_log() {
|
|||||||
// Start debug thread
|
// Start debug thread
|
||||||
xpthread_create(&thread, NULL, debug_magisk_log_thread, NULL);
|
xpthread_create(&thread, NULL, debug_magisk_log_thread, NULL);
|
||||||
pthread_detach(thread);
|
pthread_detach(thread);
|
||||||
|
start_debug_log();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_debug_log() {
|
||||||
|
#ifdef MAGISK_DEBUG
|
||||||
|
pthread_t thread;
|
||||||
|
// Start debug thread
|
||||||
|
xpthread_create(&thread, NULL, debug_magisk_log_thread, NULL);
|
||||||
|
pthread_detach(thread);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern pthread_t sepol_patch;
|
extern pthread_t sepol_patch;
|
||||||
|
extern int is_restart;
|
||||||
|
|
||||||
// Commands require connecting to daemon
|
// Commands require connecting to daemon
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -40,6 +41,7 @@ typedef enum {
|
|||||||
|
|
||||||
void start_daemon();
|
void start_daemon();
|
||||||
int connect_daemon();
|
int connect_daemon();
|
||||||
|
void auto_start_magiskhide();
|
||||||
|
|
||||||
// socket_trans.c
|
// socket_trans.c
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ extern int logcat_events[];
|
|||||||
void monitor_logs();
|
void monitor_logs();
|
||||||
void start_debug_full_log();
|
void start_debug_full_log();
|
||||||
void stop_debug_full_log();
|
void stop_debug_full_log();
|
||||||
|
void start_debug_log();
|
||||||
|
|
||||||
#else // IS_DAEMON
|
#else // IS_DAEMON
|
||||||
|
|
||||||
|
@ -124,6 +124,8 @@ int magiskhide_main(int argc, char *argv[]) {
|
|||||||
req = RM_HIDELIST;
|
req = RM_HIDELIST;
|
||||||
} else if (strcmp(argv[1], "--ls") == 0) {
|
} else if (strcmp(argv[1], "--ls") == 0) {
|
||||||
req = LS_HIDELIST;
|
req = LS_HIDELIST;
|
||||||
|
} else {
|
||||||
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
int fd = connect_daemon();
|
int fd = connect_daemon();
|
||||||
write_int(fd, req);
|
write_int(fd, req);
|
||||||
|
Loading…
Reference in New Issue
Block a user