From 985454afd45f04773a284c90ba01425291a10482 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 24 Oct 2023 16:41:49 -0700 Subject: [PATCH] Better logging --- .../java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt | 7 ++++++- native/src/core/su/su_daemon.cpp | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt b/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt index c25b1ebdb..afa090c9a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt @@ -58,6 +58,7 @@ class SuRequestHandler( val pid = intent.getIntExtra("pid", -1) val fifo = intent.getStringExtra("fifo") if (uid <= 0 || pid <= 0 || fifo == null) { + Timber.e("Unexpected extras: uid=[${uid}], pid=[${pid}], fifo=[${fifo}]") return false } output = File(fifo) @@ -73,7 +74,11 @@ class SuRequestHandler( respond(SuPolicy.DENY, -1) return false } - return output.canWrite() + if (!output.canWrite()) { + Timber.e("Cannot write to $output") + return false + } + return true } suspend fun respond(action: Int, time: Int) { diff --git a/native/src/core/su/su_daemon.cpp b/native/src/core/su/su_daemon.cpp index 75fd1778d..8f40d9527 100644 --- a/native/src/core/su/su_daemon.cpp +++ b/native/src/core/su/su_daemon.cpp @@ -165,8 +165,6 @@ void prune_su_access() { } static shared_ptr get_su_info(unsigned uid) { - LOGD("su: request from uid=[%d]\n", uid); - if (uid == AID_ROOT) { auto info = make_shared(uid); info->access = SILENT_SU_ACCESS; @@ -252,7 +250,7 @@ static void set_identity(uid_t uid, const std::vector &groups) { } void su_daemon_handler(int client, const sock_cred *cred) { - LOGD("su: request from pid=[%d], client=[%d]\n", cred->pid, client); + LOGD("su: request from uid=[%d], pid=[%d], client=[%d]\n", cred->uid, cred->pid, client); su_context ctx = { .info = get_su_info(cred->uid),