obuspa: split up OBUSPA_ENABLE_TEST_CONTROLLER configuration

A separate OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL configuration is added
which can be used by for example usp-js to accomplish local MQTT
broker setup but without compromising security by enabling remote
access. Appropriate dependencies are also added. In addition
unnecessary uci_load commands and misspelled and unnecessary
require_certificates mosquitto option are removed.
This commit is contained in:
Erik Karlsson 2024-06-14 14:01:41 +02:00 committed by Vivek Kumar Dutta
parent 7b4db3d325
commit 633519ac3a
4 changed files with 32 additions and 15 deletions

View file

@ -22,6 +22,11 @@ config OBUSPA_CONTROLLER_MTP_VERIFY
config OBUSPA_ENABLE_TEST_CONTROLLER config OBUSPA_ENABLE_TEST_CONTROLLER
bool "Adds a test controller by default" bool "Adds a test controller by default"
default n default n
select OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
config OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
bool "Adds a test controller by default (local access only)"
default n
config OBUSPA_MAX_CONTROLLERS_NUM config OBUSPA_MAX_CONTROLLERS_NUM
int "The maximum number of controllers to be supported" int "The maximum number of controllers to be supported"

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa PKG_NAME:=obuspa
PKG_VERSION:=8.0.1.8 PKG_VERSION:=8.0.1.9
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
@ -32,7 +32,9 @@ define Package/obuspa
SUBMENU:=TRx69 SUBMENU:=TRx69
TITLE:=USP agent TITLE:=USP agent
MENU:=1 MENU:=1
DEPENDS:=+libopenssl +libuci +libblobmsg-json +libcurl +libsqlite3 +libubox +libubus +libmosquitto-ssl +libwebsockets-openssl DEPENDS:=+libopenssl +libuci +libblobmsg-json +libcurl +libsqlite3 +libubox +libubus +libmosquitto-ssl +libwebsockets-openssl +ca-certificates \
+OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL:mosquitto-ssl +OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL:mosquitto-client-ssl \
+OBUSPA_ENABLE_TEST_CONTROLLER:mosquitto-auth-shadow
endef endef
define Package/obuspa/description define Package/obuspa/description
@ -127,6 +129,9 @@ define Package/obuspa/install
$(INSTALL_BIN) ./files/obuspa.hotplug $(1)/etc/hotplug.d/iface/21-obuspa $(INSTALL_BIN) ./files/obuspa.hotplug $(1)/etc/hotplug.d/iface/21-obuspa
$(BBFDM_INSTALL_CORE_PLUGIN) ./files/etc/bbfdm/json/USPAgent.json $(1) $(BBFDM_INSTALL_CORE_PLUGIN) ./files/etc/bbfdm/json/USPAgent.json $(1)
ifeq ($(CONFIG_OBUSPA_ENABLE_TEST_CONTROLLER),y) ifeq ($(CONFIG_OBUSPA_ENABLE_TEST_CONTROLLER),y)
$(INSTALL_BIN) ./files/etc/uci-defaults/54-test-usp-remote $(1)/etc/uci-defaults/
endif
ifeq ($(CONFIG_OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL),y)
$(INSTALL_BIN) ./files/etc/init.d/usptest $(1)/etc/init.d/ $(INSTALL_BIN) ./files/etc/init.d/usptest $(1)/etc/init.d/
$(INSTALL_BIN) ./files/etc/uci-defaults/55-test-usp-controller $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/55-test-usp-controller $(1)/etc/uci-defaults/
endif endif

View file

@ -0,0 +1,20 @@
#!/bin/sh
. /lib/functions.sh
if [ ! -f "/etc/config/mosquitto" ]; then
echo "Local mosquitto broker not available"
return 0
fi
add_usp_test()
{
uci_add mosquitto listener usptest
uci_set mosquitto usptest enabled 1
uci_set mosquitto usptest port '9001'
uci_set mosquitto usptest protocol 'websockets'
uci_set mosquitto usptest auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
}
# Install test MQTT over WS listener
add_usp_test

View file

@ -40,16 +40,6 @@ add_obuspa_test_controller()
uci_set obuspa testcontroller assigned_role_name 'full_access' uci_set obuspa testcontroller assigned_role_name 'full_access'
} }
add_usp_test()
{
uci_add mosquitto listener usptest
uci_set mosquitto usptest enabled 1
uci_set mosquitto usptest port '9001'
uci_set mosquitto usptest protocol 'websockets'
uci_set mosquitto usptest require_certificates '0'
uci_set mosquitto usptest auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
}
add_obuspa_config() add_obuspa_config()
{ {
uci_add mosquitto listener obuspa uci_add mosquitto listener obuspa
@ -60,11 +50,8 @@ add_obuspa_config()
} }
# Install test usp controller config # Install test usp controller config
uci_load mosquitto
add_usp_test
add_obuspa_config add_obuspa_config
uci_load obuspa
add_obuspa_test_mtp add_obuspa_test_mtp
add_obuspa_test_mqtt add_obuspa_test_mqtt
add_obuspa_test_controller add_obuspa_test_controller