mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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:
parent
0dff0fc293
commit
5a1f4b6647
@ -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')
|
||||
|
||||
|
||||
@ -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'):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user