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
@@ -41,8 +41,6 @@ def parse_arguments():
|
||||
help='Get whether Privoxy service is enabled')
|
||||
subparsers.add_parser('enable', help='Enable Privoxy service')
|
||||
subparsers.add_parser('disable', help='Disable Privoxy service')
|
||||
subparsers.add_parser('is-running',
|
||||
help='Get whether Privoxy daemon is running')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -83,12 +81,6 @@ def subcommand_disable(_):
|
||||
action_utils.service_disable('privoxy')
|
||||
|
||||
|
||||
def subcommand_is_running(_):
|
||||
"""Get whether server is running."""
|
||||
running = action_utils.service_is_running('privoxy')
|
||||
print('yes' if running else 'no')
|
||||
|
||||
|
||||
def main():
|
||||
"""Parse arguments and perform all duties."""
|
||||
arguments = parse_arguments()
|
||||
|
||||
Reference in new issue
Block a user