Add easy knobs to disable security checks

This commit is contained in:
topjohnwu
2025-10-02 04:09:46 -07:00
parent ca2e40593f
commit 78e2fc37e5
3 changed files with 17 additions and 1 deletions

View File

@@ -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 }

View File

@@ -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

View File

@@ -212,6 +212,7 @@ impl MagiskD {
info
}
#[cfg(feature = "su-check-db")]
fn build_su_info(&self, uid: i32) -> Arc<SuInfo> {
let result: LoggedResult<Arc<SuInfo>> = 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<SuInfo> {
Arc::new(SuInfo::allow(uid))
}
}