mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-27 12:09:06 +00:00
Add easy knobs to disable security checks
This commit is contained in:
@@ -8,8 +8,12 @@ crate-type = ["staticlib"]
|
|||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["check-signature"]
|
default = ["check-signature", "check-client", "su-check-db"]
|
||||||
|
|
||||||
|
# Disable these features for easier debugging during development
|
||||||
check-signature = []
|
check-signature = []
|
||||||
|
check-client = []
|
||||||
|
su-check-db = []
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cxx-gen = { workspace = true }
|
cxx-gen = { workspace = true }
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ impl MagiskD {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "check-client")]
|
||||||
fn is_client(&self, pid: i32) -> bool {
|
fn is_client(&self, pid: i32) -> bool {
|
||||||
let mut buf = cstr::buf::new::<32>();
|
let mut buf = cstr::buf::new::<32>();
|
||||||
write!(buf, "/proc/{pid}/exe").ok();
|
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) {
|
fn handle_requests(&'static self, mut client: UnixStream) {
|
||||||
let Ok(cred) = client.peer_cred() else {
|
let Ok(cred) = client.peer_cred() else {
|
||||||
// Client died
|
// Client died
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ impl MagiskD {
|
|||||||
info
|
info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "su-check-db")]
|
||||||
fn build_su_info(&self, uid: i32) -> Arc<SuInfo> {
|
fn build_su_info(&self, uid: i32) -> Arc<SuInfo> {
|
||||||
let result: LoggedResult<Arc<SuInfo>> = try {
|
let result: LoggedResult<Arc<SuInfo>> = try {
|
||||||
let cfg = self.get_db_settings()?;
|
let cfg = self.get_db_settings()?;
|
||||||
@@ -283,4 +284,9 @@ impl MagiskD {
|
|||||||
|
|
||||||
result.unwrap_or(Arc::new(SuInfo::deny(uid)))
|
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