From 16aeb4e6fe0711583ad0bde78639900c06a561dc Mon Sep 17 00:00:00 2001 From: suvendhu Date: Tue, 23 Jan 2024 02:54:22 +0530 Subject: [PATCH] obuspa: Option to set max controllers --- obuspa/Config.in | 8 +++++ obuspa/Makefile | 8 +++-- obuspa/files/etc/init.d/obuspa | 14 ++++---- obuspa/patches/0011-max_controllers.patch | 42 +++++++++++++++++++++++ 4 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 obuspa/patches/0011-max_controllers.patch diff --git a/obuspa/Config.in b/obuspa/Config.in index 3e5e85de9..7882cdbc9 100644 --- a/obuspa/Config.in +++ b/obuspa/Config.in @@ -22,4 +22,12 @@ config OBUSPA_CONTROLLER_MTP_VERIFY config OBUSPA_ENABLE_TEST_CONTROLLER bool "Adds a test controller by default" default n + +config OBUSPA_MAX_CONTROLLERS_NUM + int "The maximum number of controllers to be supported" + range 1 10 + default 5 + help + This value must be in range of 1 to 10. (default 5) + endif diff --git a/obuspa/Makefile b/obuspa/Makefile index e7f3a21a8..6cba5d466 100644 --- a/obuspa/Makefile +++ b/obuspa/Makefile @@ -5,13 +5,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=obuspa -PKG_VERSION:=7.0.5.8 +PKG_VERSION:=7.0.5.9 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git -PKG_SOURCE_VERSION:=d11c8505ffddb4c840d630632b0bb7dda04ca5b2 +PKG_SOURCE_VERSION:=810536113fc431e8f6385bb3fde52d240b5ad19d PKG_MAINTAINER:=Vivek Dutta PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip @@ -81,6 +81,10 @@ else CMAKE_OPTIONS += -DENABLE_WEBSOCKETS=OFF endif +ifdef $(CONFIG_OBUSPA_MAX_CONTROLLERS_NUM) +TARGET_CFLAGS += -DOBUSPA_MAX_CONTROLLERS_NUM=$(CONFIG_OBUSPA_MAX_CONTROLLERS_NUM) +endif + ifeq ($(LOCAL_DEV),1) define Build/Prepare $(CP) -rf ~/git/obuspa/* $(PKG_BUILD_DIR)/ diff --git a/obuspa/files/etc/init.d/obuspa b/obuspa/files/etc/init.d/obuspa index db5f30727..1242fd536 100755 --- a/obuspa/files/etc/init.d/obuspa +++ b/obuspa/files/etc/init.d/obuspa @@ -92,10 +92,10 @@ get_base_path() count=0 if [ -f "${DB_DUMP}" ]; then - path=$(grep "${refpath}\d.Alias \"${value}\"" ${DB_DUMP}) + path=$(grep -E "${refpath}\d+.Alias \"${value}\"" ${DB_DUMP}) path=${path%.*} if [ -z "${path}" ]; then - path=$(grep -o "${refpath}\d" ${DB_DUMP} |sort -r|head -n 1) + path=$(grep -oE "${refpath}\d+" ${DB_DUMP} |sort -r|head -n 1) if [ -n "${path}" ]; then count=${path##*.} count=$(( count + 1 )) @@ -122,9 +122,9 @@ get_refrence_path() path="" if [ -f "${DB_DUMP}" ]; then - path=$(grep "${dmref}\d.Alias " ${DB_DUMP}|grep -w "${value}") + path=$(grep -E "${dmref}\d+.Alias " ${DB_DUMP}|grep -w "${value}") elif [ -f "${RESET_FILE}" ]; then - path=$(grep "${dmref}\d.Alias " ${RESET_FILE}|grep -w "${value}") + path=$(grep -E "${dmref}\d+.Alias " ${RESET_FILE}|grep -w "${value}") fi path=${path%.*} echo "${path}" @@ -728,13 +728,13 @@ get_instances_from_db_dump() { local obj inst - obj="${1}\d" + obj="${1}\d+" if [ ! -f "${DB_DUMP}" ]; then echo "" return 0; fi - inst="$(grep -oe "${obj}" "${DB_DUMP}"|uniq)" + inst="$(grep -oE "${obj}" "${DB_DUMP}"|uniq)" echo "$inst" } @@ -942,7 +942,7 @@ check_n_delete_db() r="${3}" sec="${sec/${t}_/cpe-}" - path=$(grep "${r}\d.Alias \"${sec}\"" ${DB_DUMP}) + path=$(grep -E "${r}\d+.Alias \"${sec}\"" ${DB_DUMP}) path=${path%.*} delete_sql_db_entry_with_pattern "${path}" diff --git a/obuspa/patches/0011-max_controllers.patch b/obuspa/patches/0011-max_controllers.patch new file mode 100644 index 000000000..b3ccf3745 --- /dev/null +++ b/obuspa/patches/0011-max_controllers.patch @@ -0,0 +1,42 @@ +diff --git a/src/core/mqtt.c b/src/core/mqtt.c +index 04a1a9c..8cb2ad7 100644 +--- a/src/core/mqtt.c ++++ b/src/core/mqtt.c +@@ -234,6 +234,8 @@ void HandleMqttDisconnect(mqtt_client_t *client); + #define DEFINE_MQTT_TrustCertVerifyCallbackIndex(index) \ + int MQTT_TrustCertVerifyCallback_##index (int preverify_ok, X509_STORE_CTX *x509_ctx) \ + {\ ++ if (index >= MAX_MQTT_CLIENTS) \ ++ return 0; \ + return DEVICE_SECURITY_TrustCertVerifyCallbackWithCertChain(preverify_ok, x509_ctx, &mqtt_clients[index].cert_chain);\ + } + +@@ -244,6 +246,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex(1); + DEFINE_MQTT_TrustCertVerifyCallbackIndex(2); + DEFINE_MQTT_TrustCertVerifyCallbackIndex(3); + DEFINE_MQTT_TrustCertVerifyCallbackIndex(4); ++DEFINE_MQTT_TrustCertVerifyCallbackIndex(5); ++DEFINE_MQTT_TrustCertVerifyCallbackIndex(6); ++DEFINE_MQTT_TrustCertVerifyCallbackIndex(7); ++DEFINE_MQTT_TrustCertVerifyCallbackIndex(8); ++DEFINE_MQTT_TrustCertVerifyCallbackIndex(9); + // Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS + + //------------------------------------------------------------------------------------ +@@ -254,10 +261,15 @@ ssl_verify_callback_t* mqtt_verify_callbacks[] = { + MQTT_TrustCertVerifyCallbackIndex(2), + MQTT_TrustCertVerifyCallbackIndex(3), + MQTT_TrustCertVerifyCallbackIndex(4), ++ MQTT_TrustCertVerifyCallbackIndex(5), ++ MQTT_TrustCertVerifyCallbackIndex(6), ++ MQTT_TrustCertVerifyCallbackIndex(7), ++ MQTT_TrustCertVerifyCallbackIndex(8), ++ MQTT_TrustCertVerifyCallbackIndex(9), + // Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS + }; + +-USP_COMPILEASSERT( ((sizeof(mqtt_verify_callbacks)/sizeof(ssl_verify_callback_t*)) == MAX_MQTT_CLIENTS), ++USP_COMPILEASSERT( ((sizeof(mqtt_verify_callbacks)/sizeof(ssl_verify_callback_t*)) >= MAX_MQTT_CLIENTS), + "There must be MAX_MQTT_CLIENTS callbacks defined"); + + /*********************************************************************//**