ksud: Disable modules when magisk installed
This commit is contained in:
12
userspace/ksud/Cargo.lock
generated
12
userspace/ksud/Cargo.lock
generated
@@ -808,6 +808,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sys-mount",
|
"sys-mount",
|
||||||
|
"which",
|
||||||
"zip 0.6.4",
|
"zip 0.6.4",
|
||||||
"zip-extensions",
|
"zip-extensions",
|
||||||
]
|
]
|
||||||
@@ -1568,6 +1569,17 @@ version = "0.2.84"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "4.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ rust-embed = { version = "6.4.2", features = [
|
|||||||
"debug-embed",
|
"debug-embed",
|
||||||
"compression", # must clean build after updating binaries
|
"compression", # must clean build after updating binaries
|
||||||
] }
|
] }
|
||||||
|
which = "4.2.2"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
|
||||||
sys-mount = { git = "https://github.com/tiann/sys-mount" }
|
sys-mount = { git = "https://github.com/tiann/sys-mount" }
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ pub fn mount_systemlessly(module_dir: &str) -> Result<()> {
|
|||||||
pub fn on_post_data_fs() -> Result<()> {
|
pub fn on_post_data_fs() -> Result<()> {
|
||||||
crate::ksu::report_post_fs_data();
|
crate::ksu::report_post_fs_data();
|
||||||
|
|
||||||
|
if utils::has_magisk() {
|
||||||
|
warn!("Magisk detected, skip post-fs-data!");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
utils::umask(0);
|
utils::umask(0);
|
||||||
|
|
||||||
let module_update_img = defs::MODULE_UPDATE_IMG;
|
let module_update_img = defs::MODULE_UPDATE_IMG;
|
||||||
@@ -203,11 +208,16 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
pub fn on_services() -> Result<()> {
|
pub fn on_services() -> Result<()> {
|
||||||
utils::umask(0);
|
utils::umask(0);
|
||||||
|
|
||||||
// check safe mode first.
|
if utils::has_magisk() {
|
||||||
|
warn!("Magisk detected, skip services!");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if crate::utils::is_safe_mode() {
|
if crate::utils::is_safe_mode() {
|
||||||
warn!("safe mode, skip module service scripts");
|
warn!("safe mode, skip module service scripts");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = crate::module::exec_common_scripts("service.d", false) {
|
if let Err(e) = crate::module::exec_common_scripts("service.d", false) {
|
||||||
warn!("Failed to exec common service scripts: {}", e);
|
warn!("Failed to exec common service scripts: {}", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,3 +125,7 @@ pub fn umask(mask: u32) {
|
|||||||
pub fn umask(_mask: u32) {
|
pub fn umask(_mask: u32) {
|
||||||
unimplemented!("umask is not supported on this platform")
|
unimplemented!("umask is not supported on this platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_magisk() -> bool {
|
||||||
|
which::which("magisk").is_ok()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user