actions: Allow actions to be called by other users

There is not much additional risk by doing this. This is needed in case of some
exceptional cases such as storage.validate_directory() which need to run as a
different user other than root.

Tests:

- Directory validation works in transmission and deluge.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-09-20 10:26:00 -07:00 committed by James Valleroy
parent 0dff0fc293
commit 5a1f4b6647
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 0 additions and 8 deletions

View File

@ -62,9 +62,6 @@ def main():
def _call(module_name, action_name, arguments):
"""Import the module and run action as superuser"""
if os.getuid() != 0:
raise PermissionError('This action is reserved for root')
if '.' in module_name:
raise SyntaxError('Invalid module name')

View File

@ -22,11 +22,6 @@ def test_call_syntax_checks(getuid, get_module_import_path, import_module,
"""Test that calling a method results in proper syntax checks."""
call = actions_module._call
# Test for root permissions
getuid.return_value = 1000
with pytest.raises(PermissionError):
call('x-module', 'x-action', {})
# Module name validation
getuid.return_value = 0
with pytest.raises(SyntaxError, match='Invalid module name'):