You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
Check correct KernelSU version
This commit is contained in:
@@ -1,24 +1,37 @@
|
||||
mod kernelsu;
|
||||
mod magisk;
|
||||
|
||||
pub fn uid_on_allowlist(uid: i32) -> bool {
|
||||
if kernelsu::is_kernel_su() {
|
||||
kernelsu::uid_on_allowlist(uid)
|
||||
} else if magisk::is_magisk() {
|
||||
magisk::uid_on_allowlist(uid)
|
||||
use once_cell::sync::OnceCell;
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
enum RootImpl {
|
||||
KernelSU,
|
||||
Magisk,
|
||||
}
|
||||
|
||||
static ROOT_IMPL: OnceCell<RootImpl> = OnceCell::new();
|
||||
|
||||
pub fn setup() -> Result<()> {
|
||||
if kernelsu::is_kernel_su()? {
|
||||
let _ = ROOT_IMPL.set(RootImpl::KernelSU);
|
||||
} else if magisk::is_magisk()? {
|
||||
let _ = ROOT_IMPL.set(RootImpl::Magisk);
|
||||
} else {
|
||||
log::warn!("Unknown root implementation");
|
||||
false
|
||||
bail!("Unknown root implementation");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn uid_on_allowlist(uid: i32) -> bool {
|
||||
match ROOT_IMPL.get().unwrap() {
|
||||
RootImpl::KernelSU => kernelsu::uid_on_allowlist(uid),
|
||||
RootImpl::Magisk => magisk::uid_on_allowlist(uid),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uid_on_denylist(uid: i32) -> bool {
|
||||
if kernelsu::is_kernel_su() {
|
||||
kernelsu::uid_on_denylist(uid)
|
||||
} else if magisk::is_magisk() {
|
||||
magisk::uid_on_denylist(uid)
|
||||
} else {
|
||||
log::warn!("Unknown root implementation");
|
||||
false
|
||||
match ROOT_IMPL.get().unwrap() {
|
||||
RootImpl::KernelSU => kernelsu::uid_on_denylist(uid),
|
||||
RootImpl::Magisk => magisk::uid_on_denylist(uid),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user