mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-27 09:51:11 +00:00
Add easy knobs to disable security checks
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user