The DNS manager used to apply a selection by writing system/etc/hosts into the live module directory and asking for a reboot, so the root manager would pick it up while assembling /system. That put the module's own tree in the path of whatever the manager does between boots: KernelSU v3 moved that assembly into a separate metamodule, a second hosts module publishing the same path raced it silently, and an upgrade replaced the tree and discarded the user's selection with it. The published file now lives in /data/adb/zapret2-hosts and the module bind-mounts it over /system/etc/hosts from post-fs-data.sh, which is the same mechanism on Magisk, KernelSU and APatch. hosts-overlay.sh owns that mount: it snapshots the untouched system file before covering it, carries a pre-2.3.0 in-tree overlay over and takes it out of the tree, relabels the source so netd can still read it, and yields to another enabled hosts module instead of fighting it for the path. Because the module publishes the mount itself, an edit now takes effect immediately: publication is still an atomic rename, and --apply republishes the mount rather than waiting for a reboot. A rename leaves the live mount on the replaced inode, so the mount identity is recorded when it is published and consulted only against a live mount — a foreign mount is never released. Rollback, uninstall and purge follow the file to its new home, and the installer carries an existing selection across the upgrade that would otherwise drop it. Also releases the tethering runtime key and owner state v9, and lifts the packaged lifecycle contract to 9.
20 lines
930 B
Shell
Executable file
20 lines
930 B
Shell
Executable file
#!/system/bin/sh
|
|
##########################################################################################
|
|
# Zapret2 root module - post-fs-data script (runs before the framework starts)
|
|
##########################################################################################
|
|
# The DNS manager's hosts file is published from /data by a bind mount this
|
|
# module owns, so it has to be mounted before anything resolves a name. Nothing
|
|
# else belongs here: the firewall lifecycle needs a completed boot and stays in
|
|
# service.sh.
|
|
|
|
MODDIR="${0%/*}"
|
|
HOSTS_SCRIPT="$MODDIR/zapret2/scripts/hosts-overlay.sh"
|
|
|
|
[ -f "$HOSTS_SCRIPT" ] && [ ! -L "$HOSTS_SCRIPT" ] || {
|
|
/system/bin/log -p e -t "Zapret2" "Hosts publication helper is unavailable; DNS entries were not mounted" 2>/dev/null
|
|
exit 0
|
|
}
|
|
|
|
# A hosts failure must never hold up the boot: this stage blocks the framework.
|
|
/system/bin/sh "$HOSTS_SCRIPT" --boot || exit 0
|
|
exit 0
|