summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2021-03-30 13:10:00 +0000
committerJo-Philipp Wich2021-03-30 13:10:00 +0000
commit25287af31cf7a4f9b64a1e0e32b5ec2f4cb28b77 (patch)
tree40118e7a5e7dfdf46f87ab8a0f23f4c54e8890d9
parent802b685d01ad0103c1f72d3299d436dc6ec2685a (diff)
downloadfirewall4-25287af31cf7a4f9b64a1e0e32b5ec2f4cb28b77.tar.gz
treewide: remove ucode module preloading
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>
-rwxr-xr-xroot/usr/sbin/fw48
-rw-r--r--root/usr/share/firewall4/main.uc2
-rw-r--r--root/usr/share/ucode/fw4.uc4
3 files changed, 10 insertions, 4 deletions
diff --git a/root/usr/sbin/fw4 b/root/usr/sbin/fw4
index ac95473..3e7388b 100755
--- a/root/usr/sbin/fw4
+++ b/root/usr/sbin/fw4
@@ -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
diff --git a/root/usr/share/firewall4/main.uc b/root/usr/share/firewall4/main.uc
index d71e876..6012bd1 100644
--- a/root/usr/share/firewall4/main.uc
+++ b/root/usr/share/firewall4/main.uc
@@ -1,5 +1,7 @@
{%
+let fw4 = require("fw4");
+
/* Find existing sets.
*
* Unfortunately, terse mode (-t) is incompatible with JSON output so
diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc
index 1d98f61..25df7a6 100644
--- a/root/usr/share/ucode/fw4.uc
+++ b/root/usr/share/ucode/fw4.uc
@@ -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;