Rename sepolicy.rules -> rules

This commit is contained in:
LoveSy 2023-03-12 04:19:01 +08:00 committed by John Wu
parent 1c2fcd14b5
commit 7048aa1014
6 changed files with 16 additions and 23 deletions

View File

@ -43,10 +43,10 @@ data class LocalModule(
set(enable) {
if (enable) {
disableFile.delete()
Shell.cmd("copy_sepolicy_rules").submit()
Shell.cmd("copy_rules").submit()
} else {
!disableFile.createNewFile()
Shell.cmd("copy_sepolicy_rules").submit()
Shell.cmd("copy_rules").submit()
}
}
@ -56,10 +56,10 @@ data class LocalModule(
if (remove) {
if (updateFile.exists()) return
removeFile.createNewFile()
Shell.cmd("copy_sepolicy_rules").submit()
Shell.cmd("copy_rules").submit()
} else {
removeFile.delete()
Shell.cmd("copy_sepolicy_rules").submit()
Shell.cmd("copy_rules").submit()
}
}

View File

@ -67,7 +67,7 @@ direct_install() {
rm -f $1/new-boot.img
fix_env $1
run_migrations
copy_sepolicy_rules
copy_rules
return 0
}

View File

@ -60,7 +60,7 @@ static void mount_mirrors() {
restorecon();
}
// check and mount sepolicy.rules
// check and mount rules
if (struct stat st{}; stat((MAGISKTMP + "/" BLOCKDIR "/rules").data(), &st) == 0 && (st.st_mode & S_IFBLK)) {
dev_t rules_dev = st.st_rdev;
for (const auto &info: self_mount_info) {
@ -153,7 +153,7 @@ dev_t find_rules_device() {
}
if (!custom_rules_dir.empty()) {
auto rules_dir = getenv("MAGISKTMP") + "/sepolicy.rules"s;
auto rules_dir = getenv("MAGISKTMP") + "/rules"s;
mkdirs(custom_rules_dir.data(), 0700);
mkdirs(rules_dir.data(), 0700);
xmount(custom_rules_dir.data(), rules_dir.data(), nullptr, MS_BIND, nullptr);

View File

@ -18,7 +18,7 @@
extern std::string MAGISKTMP;
#define INTLROOT ".magisk"
#define MIRRDIR INTLROOT "/mirror"
#define RULESDIR INTLROOT "/sepolicy.rules"
#define RULESDIR INTLROOT "/rules"
#define BLOCKDIR INTLROOT "/block"
#define WORKERDIR INTLROOT "/worker"
#define MODULEMNT INTLROOT "/modules"

View File

@ -133,15 +133,15 @@ static void mount_rules_dir(string path, dev_t rules_dev) {
// Create bind mount
xmkdirs(RULESDIR, 0);
if (access(custom_rules_dir.data(), F_OK)) {
LOGW("empty sepolicy.rules: %s\n", custom_rules_dir.data());
LOGW("empty rules: %s\n", custom_rules_dir.data());
} else {
LOGD("sepolicy.rules: %s\n", custom_rules_dir.data());
LOGD("rules: %s\n", custom_rules_dir.data());
xmount(custom_rules_dir.data(), RULESDIR, nullptr, MS_BIND, nullptr);
mount_list.emplace_back(path += "/" RULESDIR);
}
xumount2(MIRRDIR "/rules", MNT_DETACH);
} else {
PLOGE("Failed to mount sepolicy.rules %u:%u", major(rules_dev), minor(rules_dev));
PLOGE("Failed to mount rules %u:%u", major(rules_dev), minor(rules_dev));
unlink(BLOCKDIR "/rules");
}
}

View File

@ -296,13 +296,6 @@ mount_partitions() {
# Allow /system/bin commands (dalvikvm) on Android 10+ in recovery
$BOOTMODE || mount_apex
# Mount sepolicy rules dir locations in recovery (best effort)
if ! $BOOTMODE; then
mount_name "cache cac" /cache
mount_name metadata /metadata
mount_name persist /persist
fi
}
# loop_setup <ext4_img>, sets LOOPDEV
@ -636,10 +629,10 @@ run_migrations() {
done
}
copy_sepolicy_rules() {
local RULESDIR=$(magisk --path)/.magisk/sepolicy.rules
copy_rules() {
local RULESDIR=$(magisk --path)/.magisk/rules
if ! grep -q " $RULESDIR " /proc/mounts; then
ui_print "- Unable to find sepolicy rules dir"
ui_print "- Unable to find rules dir"
return 1
fi
@ -792,10 +785,10 @@ install_module() {
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
fi
# Copy over custom sepolicy rules
# Copy over custom rules
if [ -f $MODPATH/sepolicy.rule ]; then
ui_print "- Installing custom sepolicy rules"
copy_sepolicy_rules
copy_rules
fi
# Remove stuff that doesn't belong to modules and clean up any empty directories