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 <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa authored and Joseph Nuthalapati committed 2025-08-16 22:42:33 +05:30
1 parent a70611a2e9
commit 80705b85af
1 file changed
+4 -1
+4 -1
View File
@@ -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')