From 2f7cfa7ab2aed81d1ed470f95b7c2d035885e1a9 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 15 Apr 2017 19:02:07 +0800 Subject: [PATCH] Link binaries when daemon started --- jni/daemon/daemon.c | 15 +++++++++++++++ jni/daemon/daemon.h | 17 +++++++++++++++++ jni/magisk.h | 14 -------------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/jni/daemon/daemon.c b/jni/daemon/daemon.c index 8868b3a37..fb508e1df 100644 --- a/jni/daemon/daemon.c +++ b/jni/daemon/daemon.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "magisk.h" #include "utils.h" @@ -46,6 +47,15 @@ static void request_handler(int client) { write_int(client, VERSION_CODE); close(client); break; + case POST_FS: + // TODO: post-fs + break; + case POST_FS_DATA: + // TODO: post-fs-data + break; + case LATE_START_SERVICE: + // TODO: late_start service + break; case TEST: s = read_string(client); LOGI("%s\n", s); @@ -107,6 +117,11 @@ void start_daemon() { // Unlock all blocks for rw unlock_blocks(); + // Setup links under /sbin + mount(NULL, "/", NULL, MS_REMOUNT, NULL); + create_links(NULL, "/sbin"); + mount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL); + // Loop forever to listen to requests while(1) { request_handler(xaccept(fd, NULL, NULL)); diff --git a/jni/daemon/daemon.h b/jni/daemon/daemon.h index 70fd9abdd..76061f163 100644 --- a/jni/daemon/daemon.h +++ b/jni/daemon/daemon.h @@ -14,6 +14,9 @@ typedef enum { SUPERUSER, CHECK_VERSION, CHECK_VERSION_CODE, + POST_FS, + POST_FS_DATA, + LATE_START_SERVICE, TEST } client_request; @@ -35,4 +38,18 @@ void write_string(int fd, const char* val); void monitor_logs(); + +/************** + * MagiskHide * + **************/ + +void launch_magiskhide(int client); +void stop_magiskhide(int client); + +/************* + * Superuser * + *************/ + +void su_daemon_receiver(int client); + #endif diff --git a/jni/magisk.h b/jni/magisk.h index c2da6fe98..91c788fb7 100644 --- a/jni/magisk.h +++ b/jni/magisk.h @@ -62,18 +62,4 @@ int resetprop_main(int argc, char *argv[]); } #endif -/************** - * MagiskHide * - **************/ - -void launch_magiskhide(int client); -void stop_magiskhide(int client); - -/************* - * Superuser * - *************/ - -void su_daemon_receiver(int client); - - #endif