mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Don't use actions to check if service is running
- To check whether a service is running does not require root privileges. This can directly be done from a module without any action. - Since actions are allowed to be run using sudo, introducing unnecessary sub-commands increases attack surface. - Simple functions calls are unnecessarily being converted to command line invocations and involve parsing response. - There is a lot of repeated code because of this that can be eliminated. - To generalize this, we need to make all non-root system operations directly from module instead of delegating to action commands.
This commit is contained in:
1 parent
3b6af2f29c
commit
07e2c0ce14
13 files changed
+16
-71
No files matched your search
@@ -26,6 +26,7 @@ import logging
|
||||
|
||||
from .forms import PrivoxyForm
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import package
|
||||
from plinth.modules import privoxy
|
||||
|
||||
@@ -65,11 +66,8 @@ def get_status():
|
||||
output = actions.run('privoxy', ['get-enabled'])
|
||||
enabled = (output.strip() == 'yes')
|
||||
|
||||
output = actions.superuser_run('privoxy', ['is-running'])
|
||||
is_running = (output.strip() == 'yes')
|
||||
|
||||
status = {'enabled': enabled,
|
||||
'is_running': is_running}
|
||||
'is_running': action_utils.service_is_running('privoxy')}
|
||||
|
||||
return status
|
||||
|
||||
|
||||
Reference in new issue
Block a user