clean code

This commit is contained in:
vvb2060 2024-07-18 18:40:45 +08:00 committed by John Wu
parent 9a00b7b942
commit 2282365cf8
2 changed files with 5 additions and 12 deletions

View File

@ -15,17 +15,10 @@ void MagiskInit::patch_sepolicy(const char *in, const char *out) {
sepol->magisk_rules(); sepol->magisk_rules();
// Custom rules // Custom rules
if (auto dir = xopen_dir("/data/" PREINITMIRR)) { auto rule = "/data/" PREINITMIRR "/sepolicy.rule";
for (dirent *entry; (entry = xreaddir(dir.get()));) { if (xaccess(rule, R_OK) == 0) {
auto name = "/data/" PREINITMIRR "/"s + entry->d_name; LOGD("Loading custom sepolicy patch: [%s]\n", rule);
auto rule = name + "/sepolicy.rule"; sepol->load_rule_file(rule);
if (xaccess(rule.data(), R_OK) == 0 &&
access((name + "/disable").data(), F_OK) != 0 &&
access((name + "/remove").data(), F_OK) != 0) {
LOGD("Loading custom sepolicy patch: [%s]\n", rule.data());
sepol->load_rule_file(rule.data());
}
}
} }
LOGD("Dumping sepolicy to: [%s]\n", out); LOGD("Dumping sepolicy to: [%s]\n", out);

View File

@ -583,7 +583,7 @@ copy_preinit_files() {
[ -f $MODDIR/update ] && continue [ -f $MODDIR/update ] && continue
cat $r cat $r
echo echo
done > $PREINITDIR/0/sepolicy.rule done > $PREINITDIR/sepolicy.rule
} }
################# #################