2 Commits

Author SHA1 Message Date
Nullptr
e69aa5c527 Bump to 0.4.1 2023-02-17 21:38:55 +08:00
Nullptr
9b5eb1bac7 Support Magisk out of box 2023-02-17 21:08:19 +08:00
6 changed files with 72 additions and 35 deletions

View File

@@ -2,7 +2,7 @@
Zygisk loader for KernelSU, allowing Zygisk modules to run without Magisk environment. Zygisk loader for KernelSU, allowing Zygisk modules to run without Magisk environment.
Also works as standalone loader for Magisk on purpose of getting rid of LD_PRELOAD. (Coming soon) Also works as standalone loader for Magisk on purpose of getting rid of LD_PRELOAD.
## Requirements ## Requirements
@@ -13,14 +13,3 @@ Also works as standalone loader for Magisk on purpose of getting rid of LD_PRELO
## Compatibility ## Compatibility
Should work with everything except those rely on Magisk internal behaviors. Should work with everything except those rely on Magisk internal behaviors.
## Development road map
- [x] [Inject] Basic Zygisk loader
- [x] [Inject] Stabilize injector
- [x] [Inject] Unload
- [x] [Daemon] Linker namespace
- [x] [Daemon] Separate zygiskd process
- [x] [Daemon] Handle 64 bit only devices
- [x] [Daemon] Handle zygote death
- [ ] [ Misc ] Support Magisk out of box

View File

@@ -31,7 +31,7 @@ val gitCommitHash = "git rev-parse --verify --short HEAD".execute()
val moduleId by extra("zygisksu") val moduleId by extra("zygisksu")
val moduleName by extra("Zygisk on KernelSU") val moduleName by extra("Zygisk on KernelSU")
val verName by extra("v4-0.4.0") val verName by extra("v4-0.4.1")
val verCode by extra(gitCommitCount) val verCode by extra(gitCommitCount)
val androidMinSdkVersion by extra(29) val androidMinSdkVersion by extra(29)

View File

@@ -106,7 +106,7 @@ androidComponents.onVariants { variant ->
val installMagiskTask = task<Exec>("installMagisk$variantCapped") { val installMagiskTask = task<Exec>("installMagisk$variantCapped") {
group = "module" group = "module"
dependsOn(pushTask) dependsOn(pushTask)
commandLine("adb", "shell", "su", "-c", "KSU=true magisk --install-module /data/local/tmp/$zipFileName") commandLine("adb", "shell", "su", "-c", "magisk --install-module /data/local/tmp/$zipFileName")
} }
task<Exec>("installKsuAndReboot$variantCapped") { task<Exec>("installKsuAndReboot$variantCapped") {

View File

@@ -3,27 +3,33 @@ SKIPUNZIP=1
DEBUG=@DEBUG@ DEBUG=@DEBUG@
if [ $BOOTMODE ] && [ "$KSU" == "true" ]; then if [ "$BOOTMODE" ] && [ "$KSU" ]; then
ui_print "- Installing from KernelSU app" ui_print "- Installing from KernelSU app"
ui_print "- KernelSU version: $KSU_KERNEL_VER_CODE (kernel) + $KSU_VER_CODE (ksud)"
if [ "$KSU_KERNEL_VER_CODE" ] && [ "$KSU_KERNEL_VER_CODE" -lt 10575 ]; then
ui_print "*********************************************************"
ui_print "! KernelSU version is too old!"
ui_print "! Please update KernelSU to latest version"
abort "*********************************************************"
fi
elif [ "$BOOTMODE" ] && [ "$MAGISK_VER_CODE" ]; then
ui_print "- Installing from Magisk app"
if [ "$MAGISK_VER_CODE" -lt 25000 ]; then
ui_print "*********************************************************"
ui_print "! Magisk version is too old!"
ui_print "! Please update Magisk to latest version"
abort "*********************************************************"
fi
else else
ui_print "*********************************************************" ui_print "*********************************************************"
ui_print "! Install from recovery or Magisk is NOT supported" ui_print "! Install from recovery is not supported"
ui_print "! Please install from KernelSU app" ui_print "! Please install from KernelSU or Magisk app"
abort "*********************************************************" abort "*********************************************************"
fi fi
VERSION=$(grep_prop version "${TMPDIR}/module.prop") VERSION=$(grep_prop version "${TMPDIR}/module.prop")
ui_print "- Installing Zygisksu $VERSION" ui_print "- Installing Zygisksu $VERSION"
# check KernelSU
ui_print "- KernelSU version: $KSU_KERNEL_VER_CODE (kernel) + $KSU_VER_CODE (ksud)"
if [ "$KSU_KERNEL_VER_CODE" -lt 10575 ]; then
ui_print "*********************************************************"
ui_print "! KernelSU version is too old!"
ui_print "! Please update KernelSU to latest version"
abort "*********************************************************"
fi
# check android # check android
if [ "$API" -lt 29 ]; then if [ "$API" -lt 29 ]; then
ui_print "! Unsupported sdk: $API" ui_print "! Unsupported sdk: $API"
@@ -52,19 +58,24 @@ extract "$ZIPFILE" 'customize.sh' "$TMPDIR/.vunzip"
extract "$ZIPFILE" 'verify.sh' "$TMPDIR/.vunzip" extract "$ZIPFILE" 'verify.sh' "$TMPDIR/.vunzip"
extract "$ZIPFILE" 'sepolicy.rule' "$TMPDIR" extract "$ZIPFILE" 'sepolicy.rule' "$TMPDIR"
ui_print "- Checking SELinux patches" if [ "$KSU" ]; then
if ! check_sepolicy "$TMPDIR/sepolicy.rule"; then ui_print "- Checking SELinux patches"
if ! check_sepolicy "$TMPDIR/sepolicy.rule"; then
ui_print "*********************************************************" ui_print "*********************************************************"
ui_print "! Unable to apply SELinux patches!" ui_print "! Unable to apply SELinux patches!"
ui_print "! Your kernel may not support SELinux patch fully" ui_print "! Your kernel may not support SELinux patch fully"
abort "*********************************************************" abort "*********************************************************"
fi
fi fi
ui_print "- Extracting module files" ui_print "- Extracting module files"
extract "$ZIPFILE" 'daemon.sh' "$MODPATH" extract "$ZIPFILE" 'daemon.sh' "$MODPATH"
extract "$ZIPFILE" 'module.prop' "$MODPATH" extract "$ZIPFILE" 'module.prop' "$MODPATH"
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH" extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH" extract "$ZIPFILE" 'service.sh' "$MODPATH"
if [ "$KSU" ]; then
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"
fi
HAS32BIT=false && [ -d "/system/lib" ] && HAS32BIT=true HAS32BIT=false && [ -d "/system/lib" ] && HAS32BIT=true
HAS64BIT=false && [ -d "/system/lib64" ] && HAS64BIT=true HAS64BIT=false && [ -d "/system/lib64" ] && HAS64BIT=true

View File

@@ -1,8 +1,24 @@
#!/system/bin/sh #!/system/bin/sh
MODDIR=${0%/*} MODDIR=${0%/*}
if [ "$ZYGISK_ENABLED" ]; then
exit 0
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
for file in ../*; do
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
if [ -f "$file/post-fs-data.sh" ]; then
cd "$file"
log -p i -t "zygisksu" "Manually trigger post-fs-data.sh for $file"
sh "$(realpath ./post-fs-data.sh)"
cd "$MODDIR"
fi
fi
done
fi
unshare -m sh -c "./daemon.sh $@&" unshare -m sh -c "./daemon.sh $@&"

21
module/src/service.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/system/bin/sh
MODDIR=${0%/*}
if [ "$ZYGISK_ENABLED" ]; then
exit 0
fi
cd "$MODDIR"
if [ $(which magisk) ] && [ ".." -ef "/data/adb/modules" ]; then
for file in ../*; do
if [ -d "$file" ] && [ -d "$file/zygisk" ] && ! [ -f "$file/disable" ]; then
if [ -f "$file/service.sh" ]; then
cd "$file"
log -p i -t "zygisksu" "Manually trigger service.sh for $file"
sh "$(realpath ./service.sh)"
cd "$MODDIR"
fi
fi
done
fi