mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-19 02:32:43 -08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d7686da33 | ||
|
|
65e455ef0b | ||
|
|
ac05e2f2e2 | ||
|
|
787f7b3035 | ||
|
|
31bd642b80 | ||
|
|
f0bac6b154 | ||
|
|
cc7e74ca11 |
2
app
2
app
Submodule app updated: 0c782edf21...e79d764148
@@ -7,7 +7,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
@@ -19,9 +19,16 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
compileSdkVersion = 27
|
||||||
|
buildToolsVersion = "27.0.3"
|
||||||
|
supportLibVersion = "27.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Mon Dec 04 11:24:34 CST 2017
|
#Tue Mar 27 21:17:43 CST 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
ndkBuild {
|
ndkBuild {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ void daemon_init() {
|
|||||||
rm_rf("/data/magisk");
|
rm_rf("/data/magisk");
|
||||||
unlink("/data/magisk.img");
|
unlink("/data/magisk.img");
|
||||||
unlink("/data/magisk_debug.log");
|
unlink("/data/magisk_debug.log");
|
||||||
|
xmkdir("/data/adb", 0700);
|
||||||
chmod("/data/adb", 0700);
|
chmod("/data/adb", 0700);
|
||||||
|
|
||||||
LOGI("* Creating /sbin overlay");
|
LOGI("* Creating /sbin overlay");
|
||||||
@@ -178,11 +179,6 @@ void daemon_init() {
|
|||||||
|
|
||||||
close(root);
|
close(root);
|
||||||
|
|
||||||
// Backward compatibility
|
|
||||||
xsymlink(DATABIN, "/data/magisk");
|
|
||||||
xsymlink(MAINIMG, "/data/magisk.img");
|
|
||||||
xsymlink(MOUNTPOINT, "/magisk");
|
|
||||||
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
||||||
|
|
||||||
LOGI("* Mounting mirrors");
|
LOGI("* Mounting mirrors");
|
||||||
|
|||||||
2
native/jni/external/busybox
vendored
2
native/jni/external/busybox
vendored
Submodule native/jni/external/busybox updated: 183821743b...4a9bb0541b
@@ -168,7 +168,7 @@ int parse_img(const char *image, boot_img *boot) {
|
|||||||
|
|
||||||
if (pos < boot->map_size) {
|
if (pos < boot->map_size) {
|
||||||
boot->tail = head + pos;
|
boot->tail = head + pos;
|
||||||
boot->tail_size = boot->map_size - pos;
|
boot->tail_size = boot->map_size - (boot->tail - boot->map_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check tail info, currently only for LG Bump and Samsung SEANDROIDENFORCE
|
// Check tail info, currently only for LG Bump and Samsung SEANDROIDENFORCE
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define TERM_THREAD SIGUSR1
|
#define TERM_THREAD SIGUSR1
|
||||||
#define HIDE_DONE SIGUSR2
|
|
||||||
|
|
||||||
// Kill process
|
// Kill process
|
||||||
void kill_proc(int pid);
|
void kill_proc(int pid);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "magiskhide.h"
|
#include "magiskhide.h"
|
||||||
|
|
||||||
static char init_ns[32], zygote_ns[2][32], cache_block[256];
|
static char init_ns[32], zygote_ns[2][32], cache_block[256];
|
||||||
static int hide_queue = 0, zygote_num, has_cache = 1, pipefd[2] = { -1, -1 };
|
static int zygote_num, has_cache = 1, pipefd[2] = { -1, -1 };
|
||||||
|
|
||||||
// Workaround for the lack of pthread_cancel
|
// Workaround for the lack of pthread_cancel
|
||||||
static void term_thread(int sig) {
|
static void term_thread(int sig) {
|
||||||
@@ -38,17 +38,6 @@ static void term_thread(int sig) {
|
|||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hide_done(int sig) {
|
|
||||||
--hide_queue;
|
|
||||||
if (hide_queue == 0) {
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
|
|
||||||
xsymlink(DATABIN, "/data/magisk");
|
|
||||||
xsymlink(MAINIMG, "/data/magisk.img");
|
|
||||||
xsymlink(MOUNTPOINT, "/magisk");
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int read_namespace(const int pid, char* target, const size_t size) {
|
static int read_namespace(const int pid, char* target, const size_t size) {
|
||||||
char path[32];
|
char path[32];
|
||||||
snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid);
|
snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid);
|
||||||
@@ -140,9 +129,6 @@ exit:
|
|||||||
kill(pid, SIGCONT);
|
kill(pid, SIGCONT);
|
||||||
// Free up memory
|
// Free up memory
|
||||||
vec_destroy(&mount_list);
|
vec_destroy(&mount_list);
|
||||||
// Wait a while and link it back
|
|
||||||
sleep(10);
|
|
||||||
kill(ppid, HIDE_DONE);
|
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +137,6 @@ void proc_monitor() {
|
|||||||
sigset_t block_set;
|
sigset_t block_set;
|
||||||
sigemptyset(&block_set);
|
sigemptyset(&block_set);
|
||||||
sigaddset(&block_set, TERM_THREAD);
|
sigaddset(&block_set, TERM_THREAD);
|
||||||
sigaddset(&block_set, HIDE_DONE);
|
|
||||||
pthread_sigmask(SIG_UNBLOCK, &block_set, NULL);
|
pthread_sigmask(SIG_UNBLOCK, &block_set, NULL);
|
||||||
|
|
||||||
// Register the cancel signal
|
// Register the cancel signal
|
||||||
@@ -159,8 +144,6 @@ void proc_monitor() {
|
|||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = term_thread;
|
act.sa_handler = term_thread;
|
||||||
sigaction(TERM_THREAD, &act, NULL);
|
sigaction(TERM_THREAD, &act, NULL);
|
||||||
act.sa_handler = hide_done;
|
|
||||||
sigaction(HIDE_DONE, &act, NULL);
|
|
||||||
|
|
||||||
cache_block[0] = '\0';
|
cache_block[0] = '\0';
|
||||||
|
|
||||||
@@ -241,14 +224,6 @@ void proc_monitor() {
|
|||||||
|
|
||||||
LOGI("proc_monitor: %s (PID=%d ns=%s)\n", processName, pid, ns);
|
LOGI("proc_monitor: %s (PID=%d ns=%s)\n", processName, pid, ns);
|
||||||
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
|
|
||||||
unlink("/magisk");
|
|
||||||
unlink("/data/magisk");
|
|
||||||
unlink("/data/magisk.img");
|
|
||||||
unlink(MAGISKRC);
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
|
||||||
++hide_queue;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The setns system call do not support multithread processes
|
* The setns system call do not support multithread processes
|
||||||
* We have to fork a new process, setns, then do the unmounts
|
* We have to fork a new process, setns, then do the unmounts
|
||||||
|
|||||||
@@ -2,52 +2,6 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2016 nkk71 <nkk71x@gmail.com>
|
* Copyright 2016 nkk71 <nkk71x@gmail.com>
|
||||||
* Copyright 2016 topjohnwu <topjohnwu@gmail.com>
|
* Copyright 2016 topjohnwu <topjohnwu@gmail.com>
|
||||||
*
|
|
||||||
* Info:
|
|
||||||
*
|
|
||||||
* all changes are in
|
|
||||||
*
|
|
||||||
* bionic/libc/bionic/system_properties.cpp
|
|
||||||
*
|
|
||||||
* Functions that need to be patched/added in system_properties.cpp
|
|
||||||
*
|
|
||||||
* int __system_properties_init2()
|
|
||||||
* on android 7, first tear down the everything then let it initialize again:
|
|
||||||
* if (initialized) {
|
|
||||||
* //list_foreach(contexts, [](context_node* l) { l->reset_access(); });
|
|
||||||
* //return 0;
|
|
||||||
* free_and_unmap_contexts();
|
|
||||||
* initialized = false;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* static prop_area* map_prop_area(const char* filename, bool is_legacy)
|
|
||||||
* we dont want this read only so change: 'O_RDONLY' to 'O_RDWR'
|
|
||||||
*
|
|
||||||
* static prop_area* map_fd_ro(const int fd)
|
|
||||||
* we dont want this read only so change: 'PROT_READ' to 'PROT_READ | PROT_WRITE'
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copy the code of prop_info *prop_area::find_property, and modify to delete props
|
|
||||||
* const prop_info *prop_area::find_property_and_del(prop_bt *const trie, const char *name)
|
|
||||||
* {
|
|
||||||
* ...
|
|
||||||
* ... Do not alloc a new prop_bt here, remove all code involve alloc_if_needed
|
|
||||||
* ...
|
|
||||||
*
|
|
||||||
* if (prop_offset != 0) {
|
|
||||||
* atomic_store_explicit(¤t->prop, 0, memory_order_release); // Add this line to nullify the prop entry
|
|
||||||
* return to_prop_info(¤t->prop);
|
|
||||||
* } else {
|
|
||||||
*
|
|
||||||
* ....
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* by patching just those functions directly, all other functions should be ok
|
|
||||||
* as is.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class prop_area {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const prop_info* find(const char* name);
|
const prop_info* find(const char* name);
|
||||||
bool del(const char *name); // resetprop add
|
bool del(const char *name); /* resetprop add */
|
||||||
bool add(const char* name, unsigned int namelen, const char* value, unsigned int valuelen);
|
bool add(const char* name, unsigned int namelen, const char* value, unsigned int valuelen);
|
||||||
|
|
||||||
bool foreach (void (*propfn)(const prop_info* pi, void* cookie), void* cookie);
|
bool foreach (void (*propfn)(const prop_info* pi, void* cookie), void* cookie);
|
||||||
@@ -184,7 +184,7 @@ class prop_area {
|
|||||||
const prop_info* find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
const prop_info* find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
||||||
const char* value, uint32_t valuelen, bool alloc_if_needed);
|
const char* value, uint32_t valuelen, bool alloc_if_needed);
|
||||||
|
|
||||||
bool find_property_and_del(prop_bt *const trie, const char *name); // resetprop add
|
bool find_property_and_del(prop_bt *const trie, const char *name); /* resetprop add */
|
||||||
|
|
||||||
bool foreach_property(prop_bt* const trie, void (*propfn)(const prop_info* pi, void* cookie),
|
bool foreach_property(prop_bt* const trie, void (*propfn)(const prop_info* pi, void* cookie),
|
||||||
void* cookie);
|
void* cookie);
|
||||||
@@ -283,7 +283,8 @@ static prop_area* map_prop_area_rw(const char* filename, const char* context,
|
|||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
static prop_area* map_fd_ro(const int fd) {
|
// resetprop: map the memory as rw
|
||||||
|
static prop_area* map_fd_rw(const int fd) {
|
||||||
struct stat fd_stat;
|
struct stat fd_stat;
|
||||||
if (fstat(fd, &fd_stat) < 0) {
|
if (fstat(fd, &fd_stat) < 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -298,7 +299,7 @@ static prop_area* map_fd_ro(const int fd) {
|
|||||||
pa_size = fd_stat.st_size;
|
pa_size = fd_stat.st_size;
|
||||||
pa_data_size = pa_size - sizeof(prop_area);
|
pa_data_size = pa_size - sizeof(prop_area);
|
||||||
|
|
||||||
void* const map_result = mmap(nullptr, pa_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); // resetprop: add PROT_WRITE
|
void* const map_result = mmap(nullptr, pa_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); /* resetprop: add PROT_WRITE */
|
||||||
if (map_result == MAP_FAILED) {
|
if (map_result == MAP_FAILED) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -313,10 +314,10 @@ static prop_area* map_fd_ro(const int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static prop_area* map_prop_area(const char* filename) {
|
static prop_area* map_prop_area(const char* filename) {
|
||||||
int fd = open(filename, O_CLOEXEC | O_NOFOLLOW | O_RDWR); // resetprop: O_RDONLY -> O_RDWR
|
int fd = open(filename, O_CLOEXEC | O_NOFOLLOW | O_RDWR); /* resetprop: O_RDONLY -> O_RDWR */
|
||||||
if (fd == -1) return nullptr;
|
if (fd == -1) return nullptr;
|
||||||
|
|
||||||
prop_area* map_result = map_fd_ro(fd);
|
prop_area* map_result = map_fd_rw(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return map_result;
|
return map_result;
|
||||||
@@ -530,7 +531,7 @@ bool prop_area::find_property_and_del(prop_bt* const trie, const char* name) {
|
|||||||
|
|
||||||
uint_least32_t prop_offset = atomic_load_explicit(¤t->prop, memory_order_relaxed);
|
uint_least32_t prop_offset = atomic_load_explicit(¤t->prop, memory_order_relaxed);
|
||||||
if (prop_offset != 0) {
|
if (prop_offset != 0) {
|
||||||
atomic_store_explicit(¤t->prop, 0, memory_order_release); // resetprop: nullify the offset to delete the prop
|
atomic_store_explicit(¤t->prop, 0, memory_order_release);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -1116,17 +1117,16 @@ static bool initialize_properties() {
|
|||||||
if (!initialize_properties_from_file("/system/etc/selinux/plat_property_contexts")) {
|
if (!initialize_properties_from_file("/system/etc/selinux/plat_property_contexts")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!initialize_properties_from_file("/vendor/etc/selinux/nonplat_property_contexts")
|
// Don't check for failure here, so we always have a sane list of properties.
|
||||||
&& !initialize_properties_from_file("/vendor/etc/selinux/vendor_property_contexts")) {
|
// E.g. In case of recovery, the vendor partition will not have mounted and we
|
||||||
return false;
|
// still need the system / platform properties to function.
|
||||||
}
|
initialize_properties_from_file("/vendor/etc/selinux/nonplat_property_contexts") ||
|
||||||
|
initialize_properties_from_file("/vendor/etc/selinux/vendor_property_contexts");
|
||||||
} else {
|
} else {
|
||||||
if (!initialize_properties_from_file("/plat_property_contexts")) {
|
if (!initialize_properties_from_file("/plat_property_contexts")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!initialize_properties_from_file("/nonplat_property_contexts")) {
|
initialize_properties_from_file("/nonplat_property_contexts");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
buildToolsVersion "27.0.3"
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.topjohnwu.snet"
|
applicationId "com.topjohnwu.snet"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion rootProject.ext.compileSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
}
|
}
|
||||||
@@ -20,10 +20,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.google.android.gms:play-services-safetynet:7.0.0' /* The oldest version */
|
implementation 'com.google.android.gms:play-services-safetynet:7.0.0' /* The oldest version */
|
||||||
|
|||||||
Reference in New Issue
Block a user