From de62e44b9620150092331c31752fe8e381e3a841 Mon Sep 17 00:00:00 2001 From: azerom960 Date: Wed, 30 Sep 2026 00:00:31 -0400 Subject: [PATCH 1/4] RDKEMW-26152: Serialize application registry updates --- server/gdialservice.cpp | 35 ++++++++++++++++++-- tests/test_security_registration_dispatch.py | 18 ++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/test_security_registration_dispatch.py diff --git a/server/gdialservice.cpp b/server/gdialservice.cpp index 97606bf2..0527f346 100644 --- a/server/gdialservice.cpp +++ b/server/gdialservice.cpp @@ -122,6 +122,7 @@ static void signal_handler_rest_server_gmainloop_quit(GDialRestServer *dial_rest //g_main_loop_quit(m_gdialServiceImpl->m_main_loop); } static GDialRestServer *dial_rest_server = NULL; +static GMainContext *server_main_context = NULL; static void server_activation_handler(gboolean status, const gchar *friendlyname) { @@ -133,9 +134,18 @@ static void server_activation_handler(gboolean status, const gchar *friendlyname } } -static void server_register_application(gpointer data) +struct RegisterApplicationsDispatch { + explicit RegisterApplicationsDispatch(gpointer value) : data(value) {} + gpointer data; + std::mutex mutex; + std::condition_variable condition; + bool complete{false}; +}; + +static gboolean server_register_application_on_main(gpointer data) { - GList* g_app_list = (GList*) data; + RegisterApplicationsDispatch *dispatch = static_cast(data); + GList* g_app_list = static_cast(dispatch->data); GDIAL_LOGTRACE("Entering ..."); GDIAL_LOGINFO("server_register_application callback "); if(g_app_list) { @@ -164,6 +174,25 @@ static void server_register_application(gpointer data) } } GDIAL_LOGTRACE("Exiting ..."); + { + std::lock_guard lock(dispatch->mutex); + dispatch->complete = true; + } + dispatch->condition.notify_one(); + return G_SOURCE_REMOVE; +} + +static void server_register_application(gpointer data) +{ + if (!server_main_context || g_main_context_is_owner(server_main_context)) { + RegisterApplicationsDispatch dispatch{data}; + server_register_application_on_main(&dispatch); + return; + } + RegisterApplicationsDispatch dispatch{data}; + g_main_context_invoke(server_main_context, server_register_application_on_main, &dispatch); + std::unique_lock lock(dispatch.mutex); + dispatch.condition.wait(lock, [&dispatch]{ return dispatch.complete; }); } static void server_friendlyname_handler(const gchar * friendlyname) @@ -272,6 +301,7 @@ int gdialServiceImpl::start_GDialServer(int argc, char *argv[]) //m_main_loop_context = g_main_context_default(); m_main_loop_context = g_main_context_new(); + server_main_context = m_main_loop_context; g_main_context_push_thread_default(m_main_loop_context); m_main_loop = g_main_loop_new(m_main_loop_context, FALSE); gdial_plat_init(m_main_loop_context); @@ -597,6 +627,7 @@ bool gdialServiceImpl::stop_GDialServer() if (m_main_loop_context) { + server_main_context = NULL; g_main_context_unref(m_main_loop_context); m_main_loop_context = NULL; } diff --git a/tests/test_security_registration_dispatch.py b/tests/test_security_registration_dispatch.py new file mode 100644 index 00000000..cb3a49f2 --- /dev/null +++ b/tests/test_security_registration_dispatch.py @@ -0,0 +1,18 @@ +import pathlib +import unittest + + +class RegistrationDispatchGuardrail(unittest.TestCase): + def test_registry_mutation_runs_on_main_context(self): + source = (pathlib.Path(__file__).parents[1] / "server/gdialservice.cpp").read_text() + callback = source.index("server_register_application_on_main") + unregister = source.index("gdial_rest_server_unregister_all_apps", callback) + invoke = source.index("g_main_context_invoke(server_main_context", unregister) + wait = source.index("dispatch.condition.wait", invoke) + self.assertLess(callback, unregister) + self.assertLess(invoke, wait) + self.assertIn("g_main_context_is_owner(server_main_context)", source) + + +if __name__ == "__main__": + unittest.main() From c95a6974984a6a2d9f4e3df6128be5378c2686bf Mon Sep 17 00:00:00 2001 From: azerom960 Date: Wed, 30 Sep 2026 00:12:37 -0400 Subject: [PATCH 2/4] RDKEMW-26152: Enforce main-context registry dispatch --- server/gdialservice.cpp | 5 ++++- tests/test_security_registration_dispatch.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/gdialservice.cpp b/server/gdialservice.cpp index 0527f346..1ebd102f 100644 --- a/server/gdialservice.cpp +++ b/server/gdialservice.cpp @@ -190,7 +190,10 @@ static void server_register_application(gpointer data) return; } RegisterApplicationsDispatch dispatch{data}; - g_main_context_invoke(server_main_context, server_register_application_on_main, &dispatch); + GSource *source = g_idle_source_new(); + g_source_set_callback(source, server_register_application_on_main, &dispatch, NULL); + g_source_attach(source, server_main_context); + g_source_unref(source); std::unique_lock lock(dispatch.mutex); dispatch.condition.wait(lock, [&dispatch]{ return dispatch.complete; }); } diff --git a/tests/test_security_registration_dispatch.py b/tests/test_security_registration_dispatch.py index cb3a49f2..79f019ef 100644 --- a/tests/test_security_registration_dispatch.py +++ b/tests/test_security_registration_dispatch.py @@ -7,10 +7,10 @@ def test_registry_mutation_runs_on_main_context(self): source = (pathlib.Path(__file__).parents[1] / "server/gdialservice.cpp").read_text() callback = source.index("server_register_application_on_main") unregister = source.index("gdial_rest_server_unregister_all_apps", callback) - invoke = source.index("g_main_context_invoke(server_main_context", unregister) - wait = source.index("dispatch.condition.wait", invoke) + attach = source.index("g_source_attach(source, server_main_context)", unregister) + wait = source.index("dispatch.condition.wait", attach) self.assertLess(callback, unregister) - self.assertLess(invoke, wait) + self.assertLess(attach, wait) self.assertIn("g_main_context_is_owner(server_main_context)", source) From caa3f60e05deb69e4a381d90363f61fd147f3b7b Mon Sep 17 00:00:00 2001 From: azerom960 Date: Wed, 30 Sep 2026 00:31:00 -0400 Subject: [PATCH 3/4] RDKEMW-26152: Use compatible entservices APIs --- build_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_dependencies.sh b/build_dependencies.sh index 86d6c353..af4f8403 100755 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -36,7 +36,7 @@ git clone --branch R4.4.3 https://github.com/rdkcentral/ThunderTools.git git clone --branch R4.4.1 https://github.com/rdkcentral/Thunder.git -git clone --branch main https://github.com/rdkcentral/entservices-apis.git +git clone --branch topic/RDKEMW-26132 https://github.com/rdkcentral/entservices-apis.git git clone https://$GITHUB_TOKEN@github.com/rdkcentral/entservices-testframework.git From 40d186b4eab232698a010f3cbc7d4b8551c50a39 Mon Sep 17 00:00:00 2001 From: azerom960 Date: Wed, 30 Sep 2026 02:09:48 -0400 Subject: [PATCH 4/4] RDKEMW-26152: Align native build dependencies --- build_dependencies.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/build_dependencies.sh b/build_dependencies.sh index af4f8403..b890ec13 100755 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -10,7 +10,7 @@ cd ${GITHUB_WORKSPACE} #1. Install Dependencies and packages apt update -apt install -y ninja-build meson curl libsoup2.4-dev libxml2-dev libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev valac pandoc +apt install -y git python3 python3-pip cmake ninja-build meson curl libsoup2.4-dev libxml2-dev libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev libcurl4-openssl-dev libcunit1-dev valac pandoc pip install jsonref ############################ @@ -28,17 +28,25 @@ cd .. rm -rf iarmbus ThunderTools Thunder entservices-apis entservices-testframework gssdp +THUNDER_TOOLS_COMMIT_SHA="d5dd83c7c19c49c7f25c558c126500bd2d64f7a4" +THUNDER_COMMIT_SHA="2c0fcc5529e7da734be558ca6efa05d934dcce31" git clone https://github.com/rdkcentral/iarmbus.git export IARMBUS_PATH=$GITHUB_WORKSPACE/iarmbus -git clone --branch R4.4.3 https://github.com/rdkcentral/ThunderTools.git +git clone --branch R4_4-RDK https://github.com/rdkcentral/ThunderTools.git +cd ThunderTools +git checkout $THUNDER_TOOLS_COMMIT_SHA +cd .. -git clone --branch R4.4.1 https://github.com/rdkcentral/Thunder.git +git clone --branch R4_4-RDK https://github.com/rdkcentral/Thunder.git +cd Thunder +git checkout $THUNDER_COMMIT_SHA +cd .. -git clone --branch topic/RDKEMW-26132 https://github.com/rdkcentral/entservices-apis.git +git clone --branch develop https://github.com/rdkcentral/entservices-apis.git -git clone https://$GITHUB_TOKEN@github.com/rdkcentral/entservices-testframework.git +git clone --branch 2.0.0 https://github.com/rdkcentral/entservices-testframework.git git clone --branch gssdp-1.2.3 https://gitlab.gnome.org/GNOME/gssdp.git @@ -60,7 +68,6 @@ cd - echo "======================================================================================" echo "buliding thunderTools" cd ThunderTools -patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch cd - @@ -79,10 +86,6 @@ echo "========================================================================== echo "buliding thunder" cd Thunder -patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch -patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/error_code_R4_4.patch -patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/1004-Add-support-for-project-dir.patch -patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-733-Add-ENTOS-IDS.patch cd - cmake -G Ninja -S Thunder -B build/Thunder \