File tree 2 files changed +36
-3
lines changed
2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,18 @@ static void load_overlay_rc(const char *overlay) {
203
203
}
204
204
}
205
205
206
+ static void handle_module_rc () {
207
+ if (auto dir = xopen_dir (" /data/" PREINITMIRR); dir) {
208
+ char path[PATH_MAX];
209
+ for (dirent *entry; (entry = readdir (dir.get ()));) {
210
+ if (entry->d_name == " ." sv || entry->d_name == " .." sv || entry->d_type != DT_DIR)
211
+ continue ;
212
+ sprintf (path, " /data/%s/%s" , PREINITMIRR, entry->d_name );
213
+ load_overlay_rc (path);
214
+ }
215
+ }
216
+ }
217
+
206
218
static void recreate_sbin (const char *mirror, bool use_bind_mount) {
207
219
auto dp = xopen_dir (mirror);
208
220
int src = dirfd (dp.get ());
@@ -316,6 +328,8 @@ void MagiskInit::patch_ro_root() noexcept {
316
328
mv_path (ROOTOVL " /sbin" , " ." );
317
329
}
318
330
331
+ handle_module_rc ();
332
+
319
333
// Patch init.rc
320
334
bool p;
321
335
if (access (NEW_INITRC_DIR " /" INIT_RC, F_OK) == 0 ) {
@@ -356,6 +370,8 @@ void MagiskInit::patch_rw_root() noexcept {
356
370
rm_rf (" /data/overlay.d" );
357
371
rm_rf (" /.backup" );
358
372
373
+ handle_module_rc ();
374
+
359
375
// Patch init.rc
360
376
if (patch_rc_scripts (" /" , " /sbin" , true ))
361
377
patch_fissiond (" /sbin" );
Original file line number Diff line number Diff line change @@ -584,6 +584,22 @@ copy_preinit_files() {
584
584
cat $r
585
585
echo
586
586
done > $PREINITDIR /sepolicy.rule
587
+
588
+ # Copy all enabled rc
589
+ find " $PREINITDIR " -mindepth 1 -type d 2> /dev/null | while read -r dir; do
590
+ rm -rf " ${dir:? } "
591
+ done
592
+ for d in /data/adb/modules* /* ; do
593
+ local MODDIR=${d%/* }
594
+ local MODID=$( basename " $MODDIR " )
595
+ [ -f " $MODDIR " /disable ] && continue
596
+ [ -f " $MODDIR " /remove ] && continue
597
+ [ -f " $MODDIR " /update ] && continue
598
+ find " $MODDIR " -mindepth 1 -type f -name " *.rc" | while read -r file; do
599
+ mkdir -p " $PREINITDIR /$MODID "
600
+ cp " $file " " $PREINITDIR /$MODID /"
601
+ done
602
+ done
587
603
}
588
604
589
605
# ################
@@ -719,9 +735,10 @@ install_module() {
719
735
cp -af $MODPATH /module.prop /data/adb/modules/$MODID /module.prop
720
736
fi
721
737
722
- # Copy over custom sepolicy rules
723
- if [ -f $MODPATH /sepolicy.rule ]; then
724
- ui_print " - Installing custom sepolicy rules"
738
+ rc=$( find " $MODPATH " -mindepth 1 -type f -name " *.rc" -print -quit)
739
+ # Copy over custom sepolicy rules and rc
740
+ if [ -f $MODPATH /sepolicy.rule ] || [ -n " $rc " ]; then
741
+ ui_print " - Installing custom sepolicy rules or rc script"
725
742
copy_preinit_files
726
743
fi
727
744
You can’t perform that action at this time.
0 commit comments