From f488e9df8f9c03b2fc3034fa760d7a7a749265b5 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Wed, 24 Jul 2024 17:55:24 +0800 Subject: [PATCH] Fix sepolicy rule path --- native/src/init/selinux.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/native/src/init/selinux.cpp b/native/src/init/selinux.cpp index 9740c0928..880e1cc76 100644 --- a/native/src/init/selinux.cpp +++ b/native/src/init/selinux.cpp @@ -100,18 +100,10 @@ bool MagiskInit::hijack_sepolicy() { // Read all custom rules into memory string rules; - if (auto dir = xopen_dir("/data/" PREINITMIRR)) { - for (dirent *entry; (entry = xreaddir(dir.get()));) { - auto name = "/data/" PREINITMIRR "/"s + entry->d_name; - auto rule_file = name + "/sepolicy.rule"; - if (xaccess(rule_file.data(), R_OK) == 0 && - access((name + "/disable").data(), F_OK) != 0 && - access((name + "/remove").data(), F_OK) != 0) { - LOGD("Load custom sepolicy patch: [%s]\n", rule_file.data()); - full_read(rule_file.data(), rules); - rules += '\n'; - } - } + auto rule = "/data/" PREINITMIRR "/sepolicy.rule"; + if (xaccess(rule, R_OK) == 0) { + LOGD("Loading custom sepolicy patch: [%s]\n", rule); + rules = full_read(rule); } // Create a new process waiting for init operations if (xfork()) {