Small tweaks

This commit is contained in:
topjohnwu 2017-04-24 21:43:30 +08:00
parent 95fec2100e
commit 495654f9ff
6 changed files with 15 additions and 8 deletions

View File

@ -89,8 +89,6 @@ static int setup_socket(struct sockaddr_un *sun) {
return fd; return fd;
} }
static void do_nothing() {}
static void *large_sepol_patch(void *args) { static void *large_sepol_patch(void *args) {
LOGD("sepol: Starting large patch thread\n"); LOGD("sepol: Starting large patch thread\n");
// Patch su to everything // Patch su to everything
@ -117,6 +115,7 @@ void start_daemon() {
} }
xsetsid(); xsetsid();
xsetcon("u:r:su:s0"); xsetcon("u:r:su:s0");
umask(022);
// Patch selinux with medium patch before we do anything // Patch selinux with medium patch before we do anything
load_policydb("/sys/fs/selinux/policy"); load_policydb("/sys/fs/selinux/policy");

View File

@ -33,9 +33,10 @@
// Global handler for PLOGE // Global handler for PLOGE
extern __thread void (*err_handler)(void); extern __thread void (*err_handler)(void);
// Two common error handlers // Common error handlers
static inline void exit_proc() { exit(1); } static inline void exit_proc() { exit(1); }
static inline void exit_thread() { pthread_exit(NULL); } static inline void exit_thread() { pthread_exit(NULL); }
static inline void do_nothing() {}
// Dummy function to depress debug message // Dummy function to depress debug message
static inline void stub(const char *fmt, ...) {} static inline void stub(const char *fmt, ...) {}

View File

@ -102,7 +102,7 @@ int init_list() {
return 1; return 1;
vec_init(hide_list); vec_init(hide_list);
// Might return 1 if first time // Might error if file doesn't exist, no need to report
file_to_vector(HIDELIST, hide_list); file_to_vector(HIDELIST, hide_list);
char *line; char *line;

View File

@ -43,6 +43,9 @@ static void usage(char *arg0) {
} }
void launch_magiskhide(int client) { void launch_magiskhide(int client) {
// We manually handle crashes
err_handler = do_nothing;
if (hideEnabled) { if (hideEnabled) {
write_int(client, HIDE_IS_ENABLED); write_int(client, HIDE_IS_ENABLED);
close(client); close(client);
@ -52,8 +55,12 @@ void launch_magiskhide(int client) {
LOGI("* Starting MagiskHide\n"); LOGI("* Starting MagiskHide\n");
hideEnabled = 1; hideEnabled = 1;
init_resetprop();
setprop2("persist.magisk.hide", "1", 0); if (init_resetprop())
goto error;
if (setprop2("persist.magisk.hide", "1", 0))
goto error;
hide_sensitive_props(); hide_sensitive_props();

View File

@ -66,7 +66,7 @@ static void proc_monitor_err() {
void proc_monitor() { void proc_monitor() {
// Register the cancel signal // Register the cancel signal
signal(SIGUSR1, quit_pthread); signal(SIGUSR1, quit_pthread);
// The error handler should only exit the thread, not the whole process // The error handler should stop magiskhide services
err_handler = proc_monitor_err; err_handler = proc_monitor_err;
int pid; int pid;

2
jni/su

@ -1 +1 @@
Subproject commit b499ac8abacc9d009d110146e2f681a9b0a66f19 Subproject commit c5583620349aa7700435bda0b0f356c3510e550e