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 2025-08-08 13:04:34 -07:00 committed by Joseph Nuthalapati
parent a70611a2e9
commit 80705b85af
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35

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')