luci-mod-status: Fix legacy rule detection false positive
authorTokisaki-Galaxy <[email protected]>
Tue, 7 Oct 2025 06:40:03 +0000 (14:40 +0800)
committerPaul Donald <[email protected]>
Tue, 25 Nov 2025 20:55:25 +0000 (21:55 +0100)
Refine legacy rule detection to avoid false positives generated by the
iptables-nft compatibility layer on fw4 systems.

The logic now prioritizes `iptables-legacy-save` for accuracy, while
retaining `iptables-save` as a fallback to ensure backward
compatibility with fw3.

Signed-off-by: Tokisaki-Galaxy <[email protected]>
modules/luci-mod-status/Makefile
modules/luci-mod-status/htdocs/luci-static/resources/view/status/nftables.js

index 26b7c6c6b1022562e5d46ee46ea2b7c8fbd3057c..ee00c1d763487c9cb128c3c6c3c9c572b25cc9bd 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 LUCI_TITLE:=LuCI Status Pages
 LUCI_DEPENDS:=+luci-base +libiwinfo +rpcd-mod-iwinfo
 
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_BUILD_DEPENDS:=iwinfo
 PKG_LICENSE:=Apache-2.0
 
index e619c3e744235d29523aa0a313e19ea77e4e6c1f..40f7f714beca9c7396d14a22ef75c6192eccef03 100644 (file)
@@ -146,8 +146,16 @@ return view.extend({
        load: function() {
                return Promise.all([
                        L.resolveDefault(fs.exec_direct('/usr/sbin/nft', [ '--terse', '--json', 'list', 'ruleset' ], 'json'), {}),
-                       L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-save'), ''),
-                       L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-save'), '')
+                       fs.stat('/usr/sbin/iptables-legacy-save').then(function(stat) {
+                return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-legacy-save'), '');
+            }).catch(function(err) {
+                return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-save'), '');
+            }),
+            fs.stat('/usr/sbin/ip6tables-legacy-save').then(function(stat) {
+                return L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-legacy-save'), '');
+            }).catch(function(err) {
+                return L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-save'), '');
+            })
                ]);
        },