mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-13 13:47:44 +02:00
Separate hide policies
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -11,9 +10,7 @@
|
||||
|
||||
#include <magisk.h>
|
||||
#include <utils.h>
|
||||
#include <resetprop.h>
|
||||
#include <db.h>
|
||||
#include <selinux.h>
|
||||
|
||||
#include "magiskhide.h"
|
||||
|
||||
@ -21,39 +18,6 @@ using namespace std;
|
||||
|
||||
static pthread_t proc_monitor_thread;
|
||||
|
||||
static const char *prop_key[] =
|
||||
{ "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", "ro.boot.flash.locked",
|
||||
"ro.boot.veritymode", "ro.boot.warranty_bit", "ro.warranty_bit", "ro.debuggable",
|
||||
"ro.secure", "ro.build.type", "ro.build.tags", "ro.build.selinux", nullptr };
|
||||
|
||||
static const char *prop_value[] =
|
||||
{ "locked", "green", "1",
|
||||
"enforcing", "0", "0", "0",
|
||||
"1", "user", "release-keys", "0", nullptr };
|
||||
|
||||
void manage_selinux() {
|
||||
char val;
|
||||
int fd = xopen(SELINUX_ENFORCE, O_RDONLY);
|
||||
xxread(fd, &val, sizeof(val));
|
||||
close(fd);
|
||||
// Permissive
|
||||
if (val == '0') {
|
||||
chmod(SELINUX_ENFORCE, 0640);
|
||||
chmod(SELINUX_POLICY, 0440);
|
||||
}
|
||||
}
|
||||
|
||||
static void hide_sensitive_props() {
|
||||
LOGI("hide_utils: Hiding sensitive props\n");
|
||||
|
||||
// Hide all sensitive props
|
||||
for (int i = 0; prop_key[i]; ++i) {
|
||||
auto value = getprop(prop_key[i]);
|
||||
if (!value.empty() && value != prop_value[i])
|
||||
setprop(prop_key[i], prop_value[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
// Leave /proc fd opened as we're going to read from it repeatedly
|
||||
static DIR *procfp;
|
||||
void crawl_procfs(const function<bool (int)> &fn) {
|
||||
@ -117,13 +81,6 @@ static void kill_process(const char *name) {
|
||||
});
|
||||
}
|
||||
|
||||
void clean_magisk_props() {
|
||||
getprop([](const char *name, auto, auto) -> void {
|
||||
if (strstr(name, "magisk"))
|
||||
deleteprop(name);
|
||||
}, nullptr, false);
|
||||
}
|
||||
|
||||
static int add_list(const char *pkg, const char *proc = "") {
|
||||
if (proc[0] == '\0')
|
||||
proc = pkg;
|
||||
|
Reference in New Issue
Block a user