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) { set(enable) {
if (enable) { if (enable) {
disableFile.delete() disableFile.delete()
Shell.cmd("copy_sepolicy_rules").submit() Shell.cmd("copy_rules").submit()
} else { } else {
!disableFile.createNewFile() !disableFile.createNewFile()
Shell.cmd("copy_sepolicy_rules").submit() Shell.cmd("copy_rules").submit()
} }
} }
@ -56,10 +56,10 @@ data class LocalModule(
if (remove) { if (remove) {
if (updateFile.exists()) return if (updateFile.exists()) return
removeFile.createNewFile() removeFile.createNewFile()
Shell.cmd("copy_sepolicy_rules").submit() Shell.cmd("copy_rules").submit()
} else { } else {
removeFile.delete() 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 rm -f $1/new-boot.img
fix_env $1 fix_env $1
run_migrations run_migrations
copy_sepolicy_rules copy_rules
return 0 return 0
} }

View File

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

View File

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

View File

@ -133,15 +133,15 @@ static void mount_rules_dir(string path, dev_t rules_dev) {
// Create bind mount // Create bind mount
xmkdirs(RULESDIR, 0); xmkdirs(RULESDIR, 0);
if (access(custom_rules_dir.data(), F_OK)) { 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 { } 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); xmount(custom_rules_dir.data(), RULESDIR, nullptr, MS_BIND, nullptr);
mount_list.emplace_back(path += "/" RULESDIR); mount_list.emplace_back(path += "/" RULESDIR);
} }
xumount2(MIRRDIR "/rules", MNT_DETACH); xumount2(MIRRDIR "/rules", MNT_DETACH);
} else { } 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"); unlink(BLOCKDIR "/rules");
} }
} }

View File

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