Fix daemon crashes in encrypted /data

This commit is contained in:
topjohnwu 2017-06-08 19:15:51 +08:00
parent 0980cb6eb5
commit 201e32d4c4
2 changed files with 12 additions and 11 deletions

View File

@ -21,6 +21,10 @@
static char *buf, *buf2; static char *buf, *buf2;
static struct vector module_list; static struct vector module_list;
#ifdef DEBUG
static int debug_log_pid, debug_log_fd;
#endif
/****************** /******************
* Node structure * * Node structure *
******************/ ******************/
@ -485,12 +489,20 @@ unblock:
void post_fs_data(int client) { void post_fs_data(int client) {
// Error handler // Error handler
err_handler = unblock_boot_process; err_handler = unblock_boot_process;
// ack // ack
write_int(client, 0); write_int(client, 0);
close(client); close(client);
if (!check_data()) if (!check_data())
goto unblock; goto unblock;
#ifdef DEBUG
// Start debug logs in new process
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
char *const command[] = { "logcat", "-v", "brief", NULL };
debug_log_pid = run_command(0, &debug_log_fd, "/system/bin/logcat", command);
#endif
LOGI("** post-fs-data mode running\n"); LOGI("** post-fs-data mode running\n");
// uninstaller // uninstaller

View File

@ -15,10 +15,6 @@
#include "utils.h" #include "utils.h"
#include "daemon.h" #include "daemon.h"
#ifdef DEBUG
int debug_log_pid, debug_log_fd;
#endif
static void *logger_thread(void *args) { static void *logger_thread(void *args) {
// Setup error handler // Setup error handler
err_handler = exit_thread; err_handler = exit_thread;
@ -47,11 +43,4 @@ void monitor_logs() {
pthread_t thread; pthread_t thread;
xpthread_create(&thread, NULL, logger_thread, NULL); xpthread_create(&thread, NULL, logger_thread, NULL);
pthread_detach(thread); pthread_detach(thread);
#ifdef DEBUG
// Start debug logs in new process
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
char *const command[] = { "logcat", "-v", "brief", NULL };
debug_log_pid = run_command(0, &debug_log_fd, "/system/bin/logcat", command);
#endif
} }