You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
Never allow multiple root implementation
This commit is contained in:
@@ -4,12 +4,12 @@ use crate::constants::MIN_MAGISK_VERSION;
|
||||
|
||||
pub fn is_magisk() -> Result<bool> {
|
||||
let version: Option<i32> = Command::new("magisk")
|
||||
.arg("--version")
|
||||
.arg("-V")
|
||||
.stdout(Stdio::piped())
|
||||
.spawn().ok()
|
||||
.and_then(|child| child.wait_with_output().ok())
|
||||
.and_then(|output| String::from_utf8(output.stdout).ok())
|
||||
.and_then(|output| output.parse().ok());
|
||||
.and_then(|output| output.trim().parse().ok());
|
||||
if let Some(version) = version {
|
||||
if version < MIN_MAGISK_VERSION {
|
||||
bail!("Magisk version too old: {}", version);
|
||||
|
||||
@@ -13,6 +13,9 @@ static ROOT_IMPL: OnceCell<RootImpl> = OnceCell::new();
|
||||
|
||||
pub fn setup() -> Result<()> {
|
||||
if kernelsu::is_kernel_su()? {
|
||||
if let Ok(true) = magisk::is_magisk() {
|
||||
bail!("Multiple root implementation");
|
||||
}
|
||||
let _ = ROOT_IMPL.set(RootImpl::KernelSU);
|
||||
} else if magisk::is_magisk()? {
|
||||
let _ = ROOT_IMPL.set(RootImpl::Magisk);
|
||||
|
||||
Reference in New Issue
Block a user