From e4044766097d39a2f926b42d41c8bf086b46b0e1 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 7 Dec 2017 23:25:43 +0800 Subject: [PATCH] Fix logs on decrypted /data --- core/jni/core/daemon.c | 7 +++---- core/jni/core/log_monitor.c | 5 ++--- core/jni/include/daemon.h | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/jni/core/daemon.c b/core/jni/core/daemon.c index 6b9a9e732..3e5d9c5f9 100644 --- a/core/jni/core/daemon.c +++ b/core/jni/core/daemon.c @@ -20,7 +20,6 @@ #include "daemon.h" #include "resetprop.h" -pthread_t sepol_patch; int is_daemon_init = 0, seperate_vendor = 0; static void *request_handler(void *args) { @@ -232,6 +231,9 @@ void start_daemon() { exit(1); xlisten(fd, 10); + // Start the log monitor + monitor_logs(); + if ((is_daemon_init = access(MAGISKTMP, F_OK) == 0)) { // Restart stuffs if the daemon is restarted exec_command_sync("logcat", "-b", "all", "-c", NULL); @@ -241,9 +243,6 @@ void start_daemon() { daemon_init(); } - // Start the log monitor - monitor_logs(); - LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n"); // Change process name diff --git a/core/jni/core/log_monitor.c b/core/jni/core/log_monitor.c index 44d7f9ae7..2b44f3e02 100644 --- a/core/jni/core/log_monitor.c +++ b/core/jni/core/log_monitor.c @@ -50,7 +50,7 @@ static void *logger_thread(void *args) { static void *magisk_log_thread(void *args) { int have_data = 0; - // Temp buffer for logs before we have data access + // Buffer logs before we have data access struct vector logs; vec_init(&logs); @@ -70,8 +70,7 @@ static void *magisk_log_thread(void *args) { if (!have_data) { if ((have_data = check_data())) { // Dump buffered logs to file - if (!is_daemon_init) - rename(LOGFILE, LASTLOG); + rename(LOGFILE, LASTLOG); log = xfopen(LOGFILE, "a"); setbuf(log, NULL); char *tmp; diff --git a/core/jni/include/daemon.h b/core/jni/include/daemon.h index 255b02f40..1e7217e50 100644 --- a/core/jni/include/daemon.h +++ b/core/jni/include/daemon.h @@ -7,7 +7,6 @@ #include #include -extern pthread_t sepol_patch; extern int is_daemon_init, seperate_vendor; // Commands require connecting to daemon