From 01b985eded8aa94e5a042c15065209fb3a372c7c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 9 Apr 2021 21:29:42 -0700 Subject: [PATCH] Remove more pre SDK 21 stuffs --- README.MD | 15 ++++----------- native/jni/core/applets.cpp | 2 +- native/jni/core/bootstages.cpp | 6 ------ native/jni/magiskhide/hide_utils.cpp | 5 +---- native/jni/utils/include/selinux.hpp | 3 +-- native/jni/utils/selinux.cpp | 12 +----------- scripts/emulator.sh | 16 +++++----------- scripts/flash_script.sh | 2 +- scripts/util_functions.sh | 2 +- 9 files changed, 15 insertions(+), 48 deletions(-) diff --git a/README.MD b/README.MD index 05185b287..d5b3c58b8 100644 --- a/README.MD +++ b/README.MD @@ -4,17 +4,17 @@ ## Introduction -Magisk is a suite of open source tools for customizing Android, supporting devices higher than Android 4.2. It covers fundamental parts of Android customization: root, boot scripts, SELinux patches, AVB2.0 / dm-verity / forceencrypt removals etc. - +Magisk is a suite of open source software for customizing Android, supporting devices higher than Android 5.0.
Here are some feature highlights: -- **MagiskSU**: Provide root access to your device +- **MagiskSU**: Provide root access for applications - **Magisk Modules**: Modify read-only partitions by installing modules - **MagiskHide**: Hide Magisk from root detections / system integrity checks +- **MagiskBoot**: The most complete tool for unpacking and repacking Android boot images ## Downloads -Please note that the only source of official Magisk information and downloads is [Github](https://github.com/topjohnwu/Magisk/). Beware of any other websites. +[Github](https://github.com/topjohnwu/Magisk/) is the only source where you can get official Magisk information and downloads. [![](https://img.shields.io/badge/Magisk-v22.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v22.1) [![](https://img.shields.io/badge/Magisk%20Beta-v22.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v22.1) @@ -27,13 +27,6 @@ Please note that the only source of official Magisk information and downloads is - [Magisk Documentation](https://topjohnwu.github.io/Magisk/) - [Magisk Troubleshoot Wiki](https://www.didgeridoohan.com/magisk/HomePage) (by [@Didgeridoohan](https://github.com/Didgeridoohan)) -## Android Version Support - -- Android 4.2+: MagiskSU and Magisk Modules Only -- Android 4.4+: All core features available -- Android 6.0+: Guaranteed MagiskHide support -- Android 7.0+: Full MagiskHide protection - ## Bug Reports **Only bug reports from Canary builds will be accepted.** diff --git a/native/jni/core/applets.cpp b/native/jni/core/applets.cpp index cbecf8df8..28b5f004c 100644 --- a/native/jni/core/applets.cpp +++ b/native/jni/core/applets.cpp @@ -31,7 +31,7 @@ static int call_applet(int argc, char *argv[]) { int main(int argc, char *argv[]) { umask(0); - dload_selinux(); + enable_selinux(); cmdline_logging(); init_argv0(argc, argv); diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index b930e1d9d..336a4b0ea 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -140,12 +140,6 @@ static bool magisk_env() { xmkdir(SECURE_DIR "/post-fs-data.d", 0755); xmkdir(SECURE_DIR "/service.d", 0755); - // Disable/remove magiskhide, resetprop - if (SDK_INT < 19) { - unlink("/sbin/resetprop"); - unlink("/sbin/magiskhide"); - } - if (access(DATABIN "/busybox", X_OK)) return false; diff --git a/native/jni/magiskhide/hide_utils.cpp b/native/jni/magiskhide/hide_utils.cpp index da1747ab3..566b5a50e 100644 --- a/native/jni/magiskhide/hide_utils.cpp +++ b/native/jni/magiskhide/hide_utils.cpp @@ -264,9 +264,6 @@ static void update_hide_config() { int launch_magiskhide(bool late_props) { mutex_guard lock(hide_state_lock); - if (SDK_INT < 19) - return DAEMON_ERROR; - if (hide_state) return HIDE_IS_ENABLED; @@ -325,7 +322,7 @@ void auto_start_magiskhide(bool late_props) { pthread_kill(monitor_thread, SIGALRM); #endif hide_late_sensitive_props(); - } else if (SDK_INT >= 19) { + } else { db_settings dbs; get_db_settings(dbs, HIDE_CONFIG); if (dbs[HIDE_CONFIG]) diff --git a/native/jni/utils/include/selinux.hpp b/native/jni/utils/include/selinux.hpp index 1ea472538..01fff1d6c 100644 --- a/native/jni/utils/include/selinux.hpp +++ b/native/jni/utils/include/selinux.hpp @@ -36,7 +36,6 @@ extern int (*fsetfilecon)(int fd, const char *con); void getfilecon_at(int dirfd, const char *name, char **con); void setfilecon_at(int dirfd, const char *name, const char *con); -void selinux_builtin_impl(); -void dload_selinux(); +void enable_selinux(); void restorecon(); void restore_tmpcon(); diff --git a/native/jni/utils/selinux.cpp b/native/jni/utils/selinux.cpp index 57329b3e8..a5c035674 100644 --- a/native/jni/utils/selinux.cpp +++ b/native/jni/utils/selinux.cpp @@ -99,7 +99,7 @@ void setfilecon_at(int dirfd, const char *name, const char *con) { lsetfilecon(path, con); } -void selinux_builtin_impl() { +void enable_selinux() { setcon = __setcon; getfilecon = __getfilecon; lgetfilecon = __lgetfilecon; @@ -108,13 +108,3 @@ void selinux_builtin_impl() { lsetfilecon = __lsetfilecon; fsetfilecon = __fsetfilecon; } - -void dload_selinux() { - if (access("/system/lib/libselinux.so", F_OK) && access("/system/lib64/libselinux.so", F_OK)) - return; - /* We only check whether libselinux.so exists but don't dlopen. - * For some reason calling symbols returned from dlsym - * will result to SEGV_ACCERR on some devices. - * Always use builtin implementations for SELinux stuffs. */ - selinux_builtin_impl(); -} diff --git a/scripts/emulator.sh b/scripts/emulator.sh index 374346547..d46311547 100755 --- a/scripts/emulator.sh +++ b/scripts/emulator.sh @@ -11,7 +11,7 @@ # in the emulator. The constructed Magisk environment is not a # fully functional one as if it is running on an actual device. # -# The script assumes you are using x86/x64 emulator images. +# The script assumes you are using x64 emulator images. # Build binaries with `./build.py binary` before running this script. # ##################################################################### @@ -29,14 +29,8 @@ mount_sbin() { if [ ! -f /system/build.prop ]; then # Running on PC cd "$(dirname "$0")/.." - tmp="/data/local/tmp" - adb push native/out/x86/busybox native/out/x86/magiskinit scripts/emulator.sh $tmp - emu_arch=$(adb shell "chmod 777 $tmp/busybox; $tmp/busybox uname -m") - if [ "$emu_arch" = "x86_64" ]; then - adb push native/out/x86_64/magisk /data/local/tmp - else - adb push native/out/x86/magisk /data/local/tmp - fi + adb push native/out/x86/busybox native/out/x86/magiskinit \ + native/out/x86_64/magisk scripts/emulator.sh /data/local/tmp adb shell sh /data/local/tmp/emulator.sh exit 0 fi @@ -89,7 +83,7 @@ elif [ -e /sbin ]; then mount_sbin if ! grep -q '/sbin/.magisk/mirror/system_root' /proc/mounts; then mkdir -p /sbin/.magisk/mirror/system_root - block=`mount | grep ' / ' | awk '{ print $1 }'` + block=$(mount | grep ' / ' | awk '{ print $1 }') [ $block = "/dev/root" ] && block=/dev/block/dm-0 mount -o ro $block /sbin/.magisk/mirror/system_root fi @@ -98,7 +92,7 @@ elif [ -e /sbin ]; then if [ -L $file ]; then cp -af $file /sbin else - sfile=/sbin/`basename $file` + sfile=/sbin/$(basename $file) touch $sfile mount -o bind $file $sfile fi diff --git a/scripts/flash_script.sh b/scripts/flash_script.sh index a386575e8..268d929f6 100644 --- a/scripts/flash_script.sh +++ b/scripts/flash_script.sh @@ -48,7 +48,7 @@ ui_print "- Target image: $BOOTIMAGE" # Detect version and architecture api_level_arch_detect -[ $API -lt 17 ] && abort "! Magisk only support Android 4.2 and above" +[ $API -lt 21 ] && abort "! Magisk only support Android 5.0 and above" ui_print "- Device platform: $ARCH" diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 6eabf2009..53e3387a5 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -448,7 +448,7 @@ flash_image() { install_magisk() { cd $MAGISKBIN - if [ $API -ge 21 -a ! -c $BOOTIMAGE ]; then + if [ ! -c $BOOTIMAGE ]; then eval $BOOTSIGNER -verify < $BOOTIMAGE && BOOTSIGNED=true $BOOTSIGNED && ui_print "- Boot image is signed with AVB 1.0" fi