You've already forked ZygiskNext
mirror of
https://github.com/Dr-TSNG/ZygiskNext.git
synced 2025-08-27 23:46:34 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d648d9aa4 | ||
|
|
843086f6f3 | ||
|
|
49e3ac9d7a | ||
|
|
446ed92f26 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "loader/src/external/liblsplt"]
|
||||
path = loader/src/external/liblsplt
|
||||
url = https://github.com/LSPosed/LSPlt
|
||||
[submodule "loader/src/external/lsplt"]
|
||||
path = loader/src/external/lsplt
|
||||
url = https://github.com/LSPosed/lsplt
|
||||
[submodule "loader/src/external/parallel-hashmap"]
|
||||
path = loader/src/external/parallel-hashmap
|
||||
url = https://github.com/greg7mdp/parallel-hashmap
|
||||
|
||||
@@ -13,11 +13,8 @@ Also works as standalone loader for Magisk on purpose of getting rid of LD_PRELO
|
||||
### KernelSU
|
||||
|
||||
+ Minimal KernelSU version: 10654
|
||||
+ Minimal ksud version: 10647
|
||||
+ Minimal ksud version: 10670
|
||||
+ Kernel has full SELinux patch support
|
||||
+ For old kernels, you may need to manually add the following code to `sepolicy.rule`:
|
||||
`allow zygote appdomain_tmpfs file *`
|
||||
`allow zygote appdomain_tmpfs dir *`
|
||||
|
||||
### Magisk
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ val gitCommitHash = "git rev-parse --verify --short HEAD".execute()
|
||||
|
||||
val moduleId by extra("zygisksu")
|
||||
val moduleName by extra("Zygisk on KernelSU")
|
||||
val verName by extra("v4-0.6.0")
|
||||
val verName by extra("v4-0.6.2")
|
||||
val verCode by extra(gitCommitCount)
|
||||
val minKsuVersion by extra(10654)
|
||||
val minKsudVersion by extra(10647)
|
||||
val minKsudVersion by extra(10670)
|
||||
val maxKsuVersion by extra(20000)
|
||||
val minMagiskVersion by extra(25208)
|
||||
|
||||
|
||||
8
loader/src/external/Android.mk
vendored
8
loader/src/external/Android.mk
vendored
@@ -3,14 +3,14 @@ LOCAL_PATH := $(call my-dir)
|
||||
# liblsplt.a
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:= liblsplt
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/liblsplt/lsplt/src/main/jni/include
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/lsplt/lsplt/src/main/jni/include
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
|
||||
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
|
||||
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden -DLOG_DISABLED
|
||||
LOCAL_CPPFLAGS := -std=c++20
|
||||
LOCAL_STATIC_LIBRARIES := libcxx
|
||||
LOCAL_SRC_FILES := \
|
||||
liblsplt/lsplt/src/main/jni/elf_util.cc \
|
||||
liblsplt/lsplt/src/main/jni/lsplt.cc
|
||||
lsplt/lsplt/src/main/jni/elf_util.cc \
|
||||
lsplt/lsplt/src/main/jni/lsplt.cc
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# Header only library
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
namespace {
|
||||
constexpr auto KSU_MODULE_DIR = "/data/adb/ksu/modules";
|
||||
constexpr auto MODULE_DIR = "/data/adb/modules";
|
||||
|
||||
struct overlay_backup {
|
||||
std::string target;
|
||||
@@ -38,10 +38,10 @@ void revert_unmount_ksu() {
|
||||
std::list<overlay_backup> backups;
|
||||
|
||||
// Unmount ksu module dir last
|
||||
targets.emplace_back(KSU_MODULE_DIR);
|
||||
targets.emplace_back(MODULE_DIR);
|
||||
|
||||
for (auto& info: parse_mount_info("self")) {
|
||||
if (info.target == KSU_MODULE_DIR) {
|
||||
if (info.target == MODULE_DIR) {
|
||||
ksu_loop = info.source;
|
||||
continue;
|
||||
}
|
||||
@@ -51,8 +51,7 @@ void revert_unmount_ksu() {
|
||||
}
|
||||
// Unmount ksu overlays
|
||||
if (info.type == "overlay") {
|
||||
LOGV("Overlay: %s (%s)", info.target.data(), info.fs_option.data());
|
||||
if (str_contains(info.fs_option, KSU_MODULE_DIR)) {
|
||||
if (str_contains(info.fs_option, MODULE_DIR)) {
|
||||
targets.emplace_back(info.target);
|
||||
} else {
|
||||
auto backup = overlay_backup{
|
||||
@@ -66,7 +65,7 @@ void revert_unmount_ksu() {
|
||||
}
|
||||
for (auto& info: parse_mount_info("self")) {
|
||||
// Unmount everything from ksu loop except ksu module dir
|
||||
if (info.source == ksu_loop && info.target != KSU_MODULE_DIR) {
|
||||
if (info.source == ksu_loop && info.target != MODULE_DIR) {
|
||||
targets.emplace_back(info.target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ extract "$ZIPFILE" 'sepolicy.rule' "$TMPDIR"
|
||||
|
||||
if [ "$KSU" ]; then
|
||||
ui_print "- Checking SELinux patches"
|
||||
if [ "$(getprop ro.product.first_api_level)" -lt 31 ]; then
|
||||
echo "allow zygote appdomain_tmpfs file *" >> "$TMPDIR/sepolicy.rule"
|
||||
echo "allow zygote appdomain_tmpfs dir *" >> "$TMPDIR/sepolicy.rule"
|
||||
fi
|
||||
if ! check_sepolicy "$TMPDIR/sepolicy.rule"; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Unable to apply SELinux patches!"
|
||||
@@ -93,8 +97,8 @@ fi
|
||||
ui_print "- Extracting module files"
|
||||
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
||||
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
|
||||
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"
|
||||
extract "$ZIPFILE" 'service.sh' "$MODPATH"
|
||||
mv "$TMPDIR/sepolicy.rule" "$MODPATH"
|
||||
|
||||
HAS32BIT=false && [ -d "/system/lib" ] && HAS32BIT=true
|
||||
HAS64BIT=false && [ -d "/system/lib64" ] && HAS64BIT=true
|
||||
|
||||
@@ -9,7 +9,7 @@ cd "$MODDIR"
|
||||
getprop ro.dalvik.vm.native.bridge > /dev/.native_bridge
|
||||
resetprop ro.dalvik.vm.native.bridge libzygisk_loader.so
|
||||
|
||||
if [ "$(which magisk)" ] && [ ".." -ef "/data/adb/modules" ]; then
|
||||
if [ "$(which magisk)" ]; then
|
||||
for file in ../*; do
|
||||
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
|
||||
if [ -f "$file/post-fs-data.sh" ]; then
|
||||
|
||||
@@ -10,6 +10,7 @@ allow * magisk_file lnk_file *
|
||||
allow * magisk_file sock_file *
|
||||
|
||||
allow system_server system_server process execmem
|
||||
allow zygote adb_data_file dir search
|
||||
allow zygote mnt_vendor_file dir search
|
||||
allow zygote system_file dir mounton
|
||||
allow zygote labeledfs filesystem mount
|
||||
|
||||
@@ -11,7 +11,7 @@ cd "$MODDIR"
|
||||
export NATIVE_BRIDGE=$(cat /dev/.native_bridge)
|
||||
rm /dev/.native_bridge
|
||||
|
||||
if [ "$(which magisk)" ] && [ ".." -ef "/data/adb/modules" ]; then
|
||||
if [ "$(which magisk)" ]; then
|
||||
for file in ../*; do
|
||||
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
|
||||
if [ -f "$file/service.sh" ]; then
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
mod kernelsu;
|
||||
mod magisk;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
pub enum RootImpl {
|
||||
None,
|
||||
TooOld,
|
||||
@@ -12,47 +10,50 @@ pub enum RootImpl {
|
||||
Magisk,
|
||||
}
|
||||
|
||||
static ROOT_IMPL: OnceCell<RootImpl> = OnceCell::new();
|
||||
// FIXME: OnceCell bugs on 32 bit
|
||||
static mut ROOT_IMPL: RootImpl = RootImpl::None;
|
||||
|
||||
pub fn setup() {
|
||||
let ksu_version = kernelsu::get_kernel_su();
|
||||
let magisk_version = magisk::get_magisk();
|
||||
|
||||
let _ = match (ksu_version, magisk_version) {
|
||||
(None, None) => ROOT_IMPL.set(RootImpl::None),
|
||||
(Some(_), Some(_)) => ROOT_IMPL.set(RootImpl::Multiple),
|
||||
let impl_ = match (ksu_version, magisk_version) {
|
||||
(None, None) => RootImpl::None,
|
||||
(Some(_), Some(_)) => RootImpl::Multiple,
|
||||
(Some(ksu_version), None) => {
|
||||
let val = match ksu_version {
|
||||
match ksu_version {
|
||||
kernelsu::Version::Supported => RootImpl::KernelSU,
|
||||
kernelsu::Version::TooOld => RootImpl::TooOld,
|
||||
kernelsu::Version::Abnormal => RootImpl::Abnormal,
|
||||
};
|
||||
ROOT_IMPL.set(val)
|
||||
}
|
||||
}
|
||||
(None, Some(magisk_version)) => {
|
||||
let val = match magisk_version {
|
||||
match magisk_version {
|
||||
magisk::Version::Supported => RootImpl::Magisk,
|
||||
magisk::Version::TooOld => RootImpl::TooOld,
|
||||
};
|
||||
ROOT_IMPL.set(val)
|
||||
}
|
||||
}
|
||||
};
|
||||
unsafe { ROOT_IMPL = impl_; }
|
||||
}
|
||||
|
||||
pub fn get_impl() -> &'static RootImpl {
|
||||
ROOT_IMPL.get().unwrap()
|
||||
unsafe { &ROOT_IMPL }
|
||||
}
|
||||
|
||||
// FIXME: Without #[inline(never)], this function will lag forever
|
||||
#[inline(never)]
|
||||
pub fn uid_on_allowlist(uid: i32) -> bool {
|
||||
match ROOT_IMPL.get().unwrap() {
|
||||
match get_impl() {
|
||||
RootImpl::KernelSU => kernelsu::uid_on_allowlist(uid),
|
||||
RootImpl::Magisk => magisk::uid_on_allowlist(uid),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn uid_on_denylist(uid: i32) -> bool {
|
||||
match ROOT_IMPL.get().unwrap() {
|
||||
match get_impl() {
|
||||
RootImpl::KernelSU => kernelsu::uid_on_denylist(uid),
|
||||
RootImpl::Magisk => magisk::uid_on_denylist(uid),
|
||||
_ => unreachable!(),
|
||||
|
||||
Reference in New Issue
Block a user