Never allow multiple root implementation

This commit is contained in:
Nullptr
2023-02-24 08:57:51 +08:00
parent d08b415577
commit 915749e59b
5 changed files with 13 additions and 4 deletions
+6
View File
@@ -28,6 +28,12 @@ if [ "$BOOTMODE" ] && [ "$KSU" ]; then
ui_print "! Please update KernelSU Manager to latest version" ui_print "! Please update KernelSU Manager to latest version"
abort "*********************************************************" abort "*********************************************************"
fi fi
if [ "$(which magisk)" ]; then
ui_print "*********************************************************"
ui_print "! Multiple root implementation is NOT supported!"
ui_print "! Please uninstall Magisk before installing Zygisksu"
abort "*********************************************************"
fi
elif [ "$BOOTMODE" ] && [ "$MAGISK_VER_CODE" ]; then elif [ "$BOOTMODE" ] && [ "$MAGISK_VER_CODE" ]; then
ui_print "- Installing from Magisk app" ui_print "- Installing from Magisk app"
if [ "$MAGISK_VER_CODE" -lt "$MIN_MAGISK_VERSION" ]; then if [ "$MAGISK_VER_CODE" -lt "$MIN_MAGISK_VERSION" ]; then
+1 -1
View File
@@ -8,7 +8,7 @@ fi
cd "$MODDIR" cd "$MODDIR"
export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge) export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
if [ $(which magisk) ] && [ ".." -ef "/data/adb/modules" ]; then if [ "$(which magisk)" ] && [ ".." -ef "/data/adb/modules" ]; then
for file in ../*; do for file in ../*; do
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
if [ -f "$file/post-fs-data.sh" ]; then if [ -f "$file/post-fs-data.sh" ]; then
+1 -1
View File
@@ -7,7 +7,7 @@ fi
cd "$MODDIR" cd "$MODDIR"
if [ $(which magisk) ] && [ ".." -ef "/data/adb/modules" ]; then if [ "$(which magisk)" ] && [ ".." -ef "/data/adb/modules" ]; then
for file in ../*; do for file in ../*; do
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
if [ -f "$file/service.sh" ]; then if [ -f "$file/service.sh" ]; then
+2 -2
View File
@@ -4,12 +4,12 @@ use crate::constants::MIN_MAGISK_VERSION;
pub fn is_magisk() -> Result<bool> { pub fn is_magisk() -> Result<bool> {
let version: Option<i32> = Command::new("magisk") let version: Option<i32> = Command::new("magisk")
.arg("--version") .arg("-V")
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn().ok() .spawn().ok()
.and_then(|child| child.wait_with_output().ok()) .and_then(|child| child.wait_with_output().ok())
.and_then(|output| String::from_utf8(output.stdout).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 let Some(version) = version {
if version < MIN_MAGISK_VERSION { if version < MIN_MAGISK_VERSION {
bail!("Magisk version too old: {}", version); bail!("Magisk version too old: {}", version);
+3
View File
@@ -13,6 +13,9 @@ static ROOT_IMPL: OnceCell<RootImpl> = OnceCell::new();
pub fn setup() -> Result<()> { pub fn setup() -> Result<()> {
if kernelsu::is_kernel_su()? { if kernelsu::is_kernel_su()? {
if let Ok(true) = magisk::is_magisk() {
bail!("Multiple root implementation");
}
let _ = ROOT_IMPL.set(RootImpl::KernelSU); let _ = ROOT_IMPL.set(RootImpl::KernelSU);
} else if magisk::is_magisk()? { } else if magisk::is_magisk()? {
let _ = ROOT_IMPL.set(RootImpl::Magisk); let _ = ROOT_IMPL.set(RootImpl::Magisk);