mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 23:14:03 -05:00
Move MagiskInit::patch_sepolicy to rust
This commit is contained in:
@@ -7,29 +7,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void MagiskInit::patch_sepolicy(const char *in, const char *out) const noexcept {
|
||||
LOGD("Patching monolithic policy\n");
|
||||
auto sepol = SePolicy::from_file(in);
|
||||
|
||||
sepol.magisk_rules();
|
||||
|
||||
// Custom rules
|
||||
auto rule = "/data/" PREINITMIRR "/sepolicy.rule";
|
||||
if (xaccess(rule, R_OK) == 0) {
|
||||
LOGD("Loading custom sepolicy patch: [%s]\n", rule);
|
||||
sepol.load_rule_file(rule);
|
||||
}
|
||||
|
||||
LOGD("Dumping sepolicy to: [%s]\n", out);
|
||||
sepol.to_file(out);
|
||||
|
||||
// Remove OnePlus stupid debug sepolicy and use our own
|
||||
if (access("/sepolicy_debug", F_OK) == 0) {
|
||||
unlink("/sepolicy_debug");
|
||||
link("/sepolicy", "/sepolicy_debug");
|
||||
}
|
||||
}
|
||||
|
||||
#define MOCK_COMPAT SELINUXMOCK "/compatible"
|
||||
#define MOCK_LOAD SELINUXMOCK "/load"
|
||||
#define MOCK_ENFORCE SELINUXMOCK "/enforce"
|
||||
|
||||
Reference in New Issue
Block a user