Disable several features in Jellybean
This commit is contained in:
parent
50b55a77de
commit
f24342f117
@ -32,7 +32,6 @@ static vector<string> module_list;
|
|||||||
static bool seperate_vendor;
|
static bool seperate_vendor;
|
||||||
|
|
||||||
char *system_block, *vendor_block, *magiskloop;
|
char *system_block, *vendor_block, *magiskloop;
|
||||||
int SDK_INT = -1;
|
|
||||||
|
|
||||||
static int bind_mount(const char *from, const char *to);
|
static int bind_mount(const char *from, const char *to);
|
||||||
extern void auto_start_magiskhide();
|
extern void auto_start_magiskhide();
|
||||||
@ -53,7 +52,7 @@ extern void auto_start_magiskhide();
|
|||||||
|
|
||||||
class node_entry {
|
class node_entry {
|
||||||
public:
|
public:
|
||||||
node_entry(const char *, uint8_t status = 0, uint8_t type = 0);
|
explicit node_entry(const char *, uint8_t status = 0, uint8_t type = 0);
|
||||||
~node_entry();
|
~node_entry();
|
||||||
void create_module_tree(const char *module);
|
void create_module_tree(const char *module);
|
||||||
void magic_mount();
|
void magic_mount();
|
||||||
@ -437,15 +436,6 @@ static bool magisk_env() {
|
|||||||
xmkdir(SECURE_DIR "/post-fs-data.d", 0755);
|
xmkdir(SECURE_DIR "/post-fs-data.d", 0755);
|
||||||
xmkdir(SECURE_DIR "/service.d", 0755);
|
xmkdir(SECURE_DIR "/service.d", 0755);
|
||||||
|
|
||||||
parse_prop_file("/system/build.prop", [](auto key, auto val) -> bool {
|
|
||||||
if (strcmp(key, "ro.build.version.sdk") == 0) {
|
|
||||||
LOGI("* Device API level: %s\n", val);
|
|
||||||
SDK_INT = atoi(val);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
LOGI("* Mounting mirrors");
|
LOGI("* Mounting mirrors");
|
||||||
auto mounts = file_to_vector("/proc/mounts");
|
auto mounts = file_to_vector("/proc/mounts");
|
||||||
bool system_as_root = false;
|
bool system_as_root = false;
|
||||||
@ -497,6 +487,13 @@ static bool magisk_env() {
|
|||||||
LOGI("* Setting up internal busybox");
|
LOGI("* Setting up internal busybox");
|
||||||
exec_command_sync(MIRRDIR "/bin/busybox", "--install", "-s", BBPATH, nullptr);
|
exec_command_sync(MIRRDIR "/bin/busybox", "--install", "-s", BBPATH, nullptr);
|
||||||
xsymlink(MIRRDIR "/bin/busybox", BBPATH "/busybox");
|
xsymlink(MIRRDIR "/bin/busybox", BBPATH "/busybox");
|
||||||
|
|
||||||
|
// Disable/remove magiskhide, resetprop, and modules
|
||||||
|
if (SDK_INT < 19) {
|
||||||
|
close(xopen(DISABLEFILE, O_RDONLY | O_CREAT, 0));
|
||||||
|
unlink("/sbin/resetprop");
|
||||||
|
unlink("/sbin/magiskhide");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,11 @@
|
|||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
#include "selinux.h"
|
#include "selinux.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
#include "resetprop.h"
|
||||||
#include "flags.h"
|
#include "flags.h"
|
||||||
|
|
||||||
|
int SDK_INT = -1;
|
||||||
|
|
||||||
static void get_client_cred(int fd, struct ucred *cred) {
|
static void get_client_cred(int fd, struct ucred *cred) {
|
||||||
socklen_t ucred_length = sizeof(*cred);
|
socklen_t ucred_length = sizeof(*cred);
|
||||||
if(getsockopt(fd, SOL_SOCKET, SO_PEERCRED, cred, &ucred_length))
|
if(getsockopt(fd, SOL_SOCKET, SO_PEERCRED, cred, &ucred_length))
|
||||||
@ -44,7 +47,7 @@ static void *request_handler(void *args) {
|
|||||||
if (credential.uid != 0) {
|
if (credential.uid != 0) {
|
||||||
write_int(client, ROOT_REQUIRED);
|
write_int(client, ROOT_REQUIRED);
|
||||||
close(client);
|
close(client);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -100,6 +103,16 @@ static void main_daemon() {
|
|||||||
xdup2(fd, STDIN_FILENO);
|
xdup2(fd, STDIN_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
// Get API level
|
||||||
|
parse_prop_file("/system/build.prop", [](auto key, auto val) -> bool {
|
||||||
|
if (strcmp(key, "ro.build.version.sdk") == 0) {
|
||||||
|
LOGI("* Device API level: %s\n", val);
|
||||||
|
SDK_INT = atoi(val);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
socklen_t len = setup_sockaddr(&sun, MAIN_SOCKET);
|
socklen_t len = setup_sockaddr(&sun, MAIN_SOCKET);
|
||||||
fd = xsocket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
fd = xsocket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||||
@ -116,20 +129,20 @@ static void main_daemon() {
|
|||||||
sigemptyset(&block_set);
|
sigemptyset(&block_set);
|
||||||
sigaddset(&block_set, SIGUSR1);
|
sigaddset(&block_set, SIGUSR1);
|
||||||
sigaddset(&block_set, SIGUSR2);
|
sigaddset(&block_set, SIGUSR2);
|
||||||
pthread_sigmask(SIG_SETMASK, &block_set, NULL);
|
pthread_sigmask(SIG_SETMASK, &block_set, nullptr);
|
||||||
|
|
||||||
// Ignore SIGPIPE
|
// Ignore SIGPIPE
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGPIPE, &act, NULL);
|
sigaction(SIGPIPE, &act, nullptr);
|
||||||
|
|
||||||
// Loop forever to listen for requests
|
// Loop forever to listen for requests
|
||||||
while(1) {
|
while(1) {
|
||||||
int *client = new int;
|
int *client = new int;
|
||||||
*client = xaccept4(fd, NULL, NULL, SOCK_CLOEXEC);
|
*client = xaccept4(fd, nullptr, nullptr, SOCK_CLOEXEC);
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
xpthread_create(&thread, NULL, request_handler, client);
|
xpthread_create(&thread, nullptr, request_handler, client);
|
||||||
// Detach the thread, we will never join it
|
// Detach the thread, we will never join it
|
||||||
pthread_detach(thread);
|
pthread_detach(thread);
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,9 @@ static void set_hide_config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int launch_magiskhide(int client) {
|
int launch_magiskhide(int client) {
|
||||||
|
if (SDK_INT < 19)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (hide_enabled)
|
if (hide_enabled)
|
||||||
return HIDE_IS_ENABLED;
|
return HIDE_IS_ENABLED;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user