treewide: remove ucode module preloading
authorJo-Philipp Wich <jo@mein.io>
Tue, 30 Mar 2021 13:10:00 +0000 (15:10 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 30 Mar 2021 13:10:00 +0000 (15:10 +0200)
Instead of preloading ucode modules via the cmdline, require the modules
as needed. This simplifies test case constructions since mock modules
can be injected by modifying the search path.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
root/usr/sbin/fw4
root/usr/share/firewall4/main.uc
root/usr/share/ucode/fw4.uc

index ac95473918bb3ac62b989001be40e9d73731e8a0..3e7388ba332984201808b9eabf17b65fdea35ae4 100755 (executable)
@@ -31,13 +31,13 @@ start() {
                esac
 
                ACTION=start \
-                       ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0
+                       ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0
        } 1000>$LOCK
 }
 
 print() {
        ACTION=print \
-               ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN
+               ucode -S -i $MAIN
 }
 
 stop() {
@@ -68,12 +68,12 @@ flush() {
 
 reload_sets() {
        ACTION=reload-sets \
-               flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0
+               flock -x $LOCK ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0
 }
 
 lookup() {
        ACTION=$1 OBJECT=$2 DEVICE=$3 \
-               flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN
+               flock -x $LOCK ucode -S -i $MAIN
 }
 
 while [ -n "$1" ]; do
index d71e876467972af18c46580c458023089bf5f1f6..6012bd1f6a5fc11ea04184acd2c354bd8e9d0028 100644 (file)
@@ -1,5 +1,7 @@
 {%
 
+let fw4 = require("fw4");
+
 /* Find existing sets.
  *
  * Unfortunately, terse mode (-t) is incompatible with JSON output so
index 1d98f6151fdea59799e28a2b3daa1c89c31da0a0..25df7a68a3221aad5dcd05a74e58a366dcd550c1 100644 (file)
@@ -1,5 +1,9 @@
 {%
 
+let fs = require("fs");
+let uci = require("uci");
+let ubus = require("ubus");
+
 let STATEFILE = "/var/run/fw4.state";
 
 let PARSE_LIST   = 0x01;