From 6e3bb4857461af32dd10dd1005721e9e6f0c86ee Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 6 Dec 2016 04:47:26 +0800 Subject: [PATCH] Add su binary into Magisk --- .gitmodules | 3 +++ jni/Android.mk | 14 ++++++++++++-- jni/Application.mk | 1 + jni/selinux | 2 +- jni/su | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) create mode 160000 jni/su diff --git a/.gitmodules b/.gitmodules index ef6b59806..483f82e26 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "jni/selinux"] path = jni/selinux url = https://github.com/topjohnwu/selinux.git +[submodule "jni/su"] + path = jni/su + url = https://github.com/topjohnwu/Superuser.git diff --git a/jni/Android.mk b/jni/Android.mk index d52c713d6..229074c52 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -21,7 +21,7 @@ LOCAL_MODULE := sepolicy-inject LOCAL_MODULE_TAGS := optional LOCAL_STATIC_LIBRARIES := libsepol LOCAL_SRC_FILES := sepolicy-inject/sepolicy-inject.c sepolicy-inject/builtin_rules.c -LOCAL_C_INCLUDES := $(my_path)/selinux/libsepol/include/ +LOCAL_C_INCLUDES := jni/selinux/libsepol/include/ LOCAL_CFLAGS += -std=gnu11 include $(BUILD_EXECUTABLE) @@ -32,4 +32,14 @@ LOCAL_SRC_FILES := resetprop/resetprop.cpp resetprop/system_properties.cpp reset LOCAL_LDLIBS += -latomic include $(BUILD_EXECUTABLE) -include $(my_path)/selinux/libsepol/Android.mk +include $(CLEAR_VARS) +LOCAL_MODULE := su +LOCAL_MODULE_TAGS := eng debug optional +LOCAL_STATIC_LIBRARIES := libselinux +LOCAL_C_INCLUDES := jni/selinux/libselinux/include/ jni/selinux/libsepol/include/ jni/su/sqlite3/ +LOCAL_SRC_FILES := su/su.c su/daemon.c su/activity.c su/db.c su/utils.c su/pts.c su/hacks.c su/binds.c su/sqlite3/sqlite3.c +LOCAL_CFLAGS := -DSQLITE_OMIT_LOAD_EXTENSION -std=gnu11 +include $(BUILD_EXECUTABLE) + +include jni/selinux/libsepol/Android.mk +include jni/selinux/libselinux/Android.mk diff --git a/jni/Application.mk b/jni/Application.mk index 4d8c58092..139340d3b 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,3 +1,4 @@ +NDK_TOOLCHAIN_VERSION=4.9 APP_ABI := x86 x86_64 armeabi arm64-v8a APP_PIE = true APP_PLATFORM := android-21 diff --git a/jni/selinux b/jni/selinux index df7346cd5..91e9179a2 160000 --- a/jni/selinux +++ b/jni/selinux @@ -1 +1 @@ -Subproject commit df7346cd5b27f8a66f84669a9ed1d9c272692b17 +Subproject commit 91e9179a23435bbadada5474ce09a2aea3dadcd6 diff --git a/jni/su b/jni/su new file mode 160000 index 000000000..1d2eb13ca --- /dev/null +++ b/jni/su @@ -0,0 +1 @@ +Subproject commit 1d2eb13cae13380bbccff4b0ba77c14140158ea8