From 78e2fc37e540689e8090d280aad4459022d72558 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 2 Oct 2025 04:09:46 -0700 Subject: [PATCH] Add easy knobs to disable security checks --- native/src/core/Cargo.toml | 6 +++++- native/src/core/daemon.rs | 6 ++++++ native/src/core/su/daemon.rs | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/native/src/core/Cargo.toml b/native/src/core/Cargo.toml index f0fdaa60e..590320985 100644 --- a/native/src/core/Cargo.toml +++ b/native/src/core/Cargo.toml @@ -8,8 +8,12 @@ crate-type = ["staticlib"] path = "lib.rs" [features] -default = ["check-signature"] +default = ["check-signature", "check-client", "su-check-db"] + +# Disable these features for easier debugging during development check-signature = [] +check-client = [] +su-check-db = [] [build-dependencies] cxx-gen = { workspace = true } diff --git a/native/src/core/daemon.rs b/native/src/core/daemon.rs index fc4b90233..1f5b95bd0 100644 --- a/native/src/core/daemon.rs +++ b/native/src/core/daemon.rs @@ -161,6 +161,7 @@ impl MagiskD { .ok(); } + #[cfg(feature = "check-client")] fn is_client(&self, pid: i32) -> bool { let mut buf = cstr::buf::new::<32>(); write!(buf, "/proc/{pid}/exe").ok(); @@ -171,6 +172,11 @@ impl MagiskD { } } + #[cfg(not(feature = "check-client"))] + fn is_client(&self, pid: i32) -> bool { + true + } + fn handle_requests(&'static self, mut client: UnixStream) { let Ok(cred) = client.peer_cred() else { // Client died diff --git a/native/src/core/su/daemon.rs b/native/src/core/su/daemon.rs index 77cf08cc7..dd19dde16 100644 --- a/native/src/core/su/daemon.rs +++ b/native/src/core/su/daemon.rs @@ -212,6 +212,7 @@ impl MagiskD { info } + #[cfg(feature = "su-check-db")] fn build_su_info(&self, uid: i32) -> Arc { let result: LoggedResult> = try { let cfg = self.get_db_settings()?; @@ -283,4 +284,9 @@ impl MagiskD { result.unwrap_or(Arc::new(SuInfo::deny(uid))) } + + #[cfg(not(feature = "su-check-db"))] + fn build_su_info(&self, uid: i32) -> Arc { + Arc::new(SuInfo::allow(uid)) + } }