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:
Sunil Mohan Adapa authored and James Valleroy committed 2015-07-19 19:54:13 -04:00
1 parent 3b6af2f29c
commit 07e2c0ce14
13 files changed
+16 -71

No files matched your search

-8
View File
@@ -34,9 +34,6 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
# Get whether Tor is running
subparsers.add_parser('is-running', help='Get whether Tor is running')
# Enable and start the service
subparsers.add_parser('enable', help='Enable and start Tor service')
@@ -55,11 +52,6 @@ def parse_arguments():
return parser.parse_args()
def subcommand_is_running(_):
"""Get whether Tor is running"""
print('yes' if action_utils.service_is_running('tor') else 'no')
def subcommand_enable(_):
"""Enable and start the service."""
action_utils.service_enable('tor')