[openwrt/openwrt] hostapd: add wpa_supplicant ubus function guard exception handler
LEDE Commits
lede-commits at lists.infradead.org
Wed Sep 24 04:49:31 PDT 2025
nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6834c19e418bcbd9419631bd9c1693e88d0672bc
commit 6834c19e418bcbd9419631bd9c1693e88d0672bc
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Sat Sep 6 16:47:42 2025 +0200
hostapd: add wpa_supplicant ubus function guard exception handler
Improves logging when something goes wrong
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
.../services/hostapd/files/wpa_supplicant.uc | 40 +++++++++++-----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc
index f288121e9d..dd371154e1 100644
--- a/package/network/services/hostapd/files/wpa_supplicant.uc
+++ b/package/network/services/hostapd/files/wpa_supplicant.uc
@@ -4,6 +4,15 @@ import { wdev_create, wdev_set_mesh_params, wdev_remove, is_equal, wdev_set_up,
let ubus = libubus.connect();
+function ex_handler(e)
+{
+ e = split(`${e}\n${e.stacktrace[0].context}`, '\n');
+ for (let line in e)
+ wpas.printf(line);
+ return libubus.STATUS_UNKNOWN_ERROR;
+}
+libubus.guard(ex_handler);
+
wpas.data.config = {};
wpas.data.iface_phy = {};
wpas.data.macaddr_list = {};
@@ -143,17 +152,13 @@ let main_obj = {
if (!phy)
return libubus.STATUS_NOT_FOUND;
- try {
- if (req.args.stop) {
- for (let ifname in phy.data)
- iface_stop(phy.data[ifname]);
- } else {
- start_pending(name);
- }
- } catch (e) {
- wpas.printf(`Error chaging state: ${e}\n${e.stacktrace[0].context}`);
- return libubus.STATUS_INVALID_ARGUMENT;
+ if (req.args.stop) {
+ for (let ifname in phy.data)
+ iface_stop(phy.data[ifname]);
+ } else {
+ start_pending(name);
}
+
return 0;
}
},
@@ -224,16 +229,11 @@ let main_obj = {
return libubus.STATUS_INVALID_ARGUMENT;
wpas.printf(`Set new config for phy ${phy}`);
- try {
- if (req.args.config)
- set_config(phy, req.args.phy, req.args.radio, req.args.num_global_macaddr, req.args.macaddr_base, req.args.config);
-
- if (!req.args.defer)
- start_pending(phy);
- } catch (e) {
- wpas.printf(`Error loading config: ${e}\n${e.stacktrace[0].context}`);
- return libubus.STATUS_INVALID_ARGUMENT;
- }
+ if (req.args.config)
+ set_config(phy, req.args.phy, req.args.radio, req.args.num_global_macaddr, req.args.macaddr_base, req.args.config);
+
+ if (!req.args.defer)
+ start_pending(phy);
return {
pid: wpas.getpid()
More information about the lede-commits
mailing list