luci-base: fix ubus luci/getConntrackHelpers reporting with firewall3
authorJo-Philipp Wich <jo@mein.io>
Thu, 10 Nov 2022 21:49:07 +0000 (22:49 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 10 Nov 2022 21:49:07 +0000 (22:49 +0100)
The uci package name used to iterate the loaded configuration sections
must correspond to the file name being loaded.

Fixes: https://github.com/openwrt/openwrt/issues/11215
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/root/usr/share/rpcd/ucode/luci

index cb00ff86d41464f0862aaf0b78dc14d3f7be7c65..e2379793528b96722528dc71635ac3206e0da1f7 100644 (file)
@@ -159,20 +159,25 @@ const methods = {
                call: function() {
                        const uci = cursor();
                        let helpers = [];
-
-                       uci.load('/usr/share/firewall4/helpers');
-                       uci.load('/usr/share/fw3/helpers.conf');
-
-                       uci.foreach('helpers', 'helper', (s) => {
-                               push(helpers, {
-                                       name: s.name,
-                                       description: s.description,
-                                       module: s.module,
-                                       family: s.family,
-                                       proto: s.proto,
-                                       port: s.port
+                       let package;
+
+                       if (uci.load('/usr/share/firewall4/helpers'))
+                               package = 'helpers';
+                       else if (uci.load('/usr/share/fw3/helpers.conf'))
+                               package = 'helpers.conf';
+
+                       if (package) {
+                               uci.foreach(package, 'helper', (s) => {
+                                       push(helpers, {
+                                               name: s.name,
+                                               description: s.description,
+                                               module: s.module,
+                                               family: s.family,
+                                               proto: s.proto,
+                                               port: s.port
+                                       });
                                });
-                       });
+                       }
 
                        return { result: helpers };
                }