From 80705b85af7f8cf4ee9da254175fee78cfb93293 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 8 Aug 2025 13:04:34 -0700 Subject: [PATCH] actions: Raise a proper exception if privileged module is not found Without the change FileNotFound exception is raised. Tests: - Send request using 'nc' to privileged daemon that has invalid 'module' parameter. SyntaxError exception is raised. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/actions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plinth/actions.py b/plinth/actions.py index 095ccc4f9..06a25c283 100644 --- a/plinth/actions.py +++ b/plinth/actions.py @@ -547,7 +547,10 @@ def _privileged_call(module_name, action_name, arguments): if module_name == 'plinth': import_path = 'plinth' else: - import_path = module_loader.get_module_import_path(module_name) + try: + import_path = module_loader.get_module_import_path(module_name) + except FileNotFoundError as exception: + raise SyntaxError('Specified module not found') from exception try: module = importlib.import_module(import_path + '.privileged')