Link binaries when daemon started

This commit is contained in:
topjohnwu 2017-04-15 19:02:07 +08:00
parent bdcb813ee6
commit 2f7cfa7ab2
3 changed files with 32 additions and 14 deletions

View File

@ -13,6 +13,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mount.h>
#include "magisk.h" #include "magisk.h"
#include "utils.h" #include "utils.h"
@ -46,6 +47,15 @@ static void request_handler(int client) {
write_int(client, VERSION_CODE); write_int(client, VERSION_CODE);
close(client); close(client);
break; 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: case TEST:
s = read_string(client); s = read_string(client);
LOGI("%s\n", s); LOGI("%s\n", s);
@ -107,6 +117,11 @@ void start_daemon() {
// Unlock all blocks for rw // Unlock all blocks for rw
unlock_blocks(); 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 // Loop forever to listen to requests
while(1) { while(1) {
request_handler(xaccept(fd, NULL, NULL)); request_handler(xaccept(fd, NULL, NULL));

View File

@ -14,6 +14,9 @@ typedef enum {
SUPERUSER, SUPERUSER,
CHECK_VERSION, CHECK_VERSION,
CHECK_VERSION_CODE, CHECK_VERSION_CODE,
POST_FS,
POST_FS_DATA,
LATE_START_SERVICE,
TEST TEST
} client_request; } client_request;
@ -35,4 +38,18 @@ void write_string(int fd, const char* val);
void monitor_logs(); void monitor_logs();
/**************
* MagiskHide *
**************/
void launch_magiskhide(int client);
void stop_magiskhide(int client);
/*************
* Superuser *
*************/
void su_daemon_receiver(int client);
#endif #endif

View File

@ -62,18 +62,4 @@ int resetprop_main(int argc, char *argv[]);
} }
#endif #endif
/**************
* MagiskHide *
**************/
void launch_magiskhide(int client);
void stop_magiskhide(int client);
/*************
* Superuser *
*************/
void su_daemon_receiver(int client);
#endif #endif