Commit 1fbd79a6 authored by Marco Mariani's avatar Marco Mariani

refuse to run 'slapos node' commands as non root

parent d83b4de8
...@@ -55,6 +55,9 @@ USER_SLAPOS_CONFIGURATION = os.environ.get( ...@@ -55,6 +55,9 @@ USER_SLAPOS_CONFIGURATION = os.environ.get(
'SLAPOS_CLIENT_CONFIGURATION', 'SLAPOS_CLIENT_CONFIGURATION',
os.environ.get('SLAPOS_CONFIGURATION', '~/.slapos/slapos.cfg')) os.environ.get('SLAPOS_CONFIGURATION', '~/.slapos/slapos.cfg'))
class UsageError(Exception):
pass
class EntryPointNotImplementedError(NotImplementedError): class EntryPointNotImplementedError(NotImplementedError):
def __init__(self, *args, **kw_args): def __init__(self, *args, **kw_args):
NotImplementedError.__init__(self, *args, **kw_args) NotImplementedError.__init__(self, *args, **kw_args)
...@@ -115,7 +118,11 @@ def dispatch(command, is_node_command): ...@@ -115,7 +118,11 @@ def dispatch(command, is_node_command):
If configuration file is not given: define it arbitrarily, and so on. If configuration file is not given: define it arbitrarily, and so on.
""" """
if is_node_command: if is_node_command:
# XXX-Cedric: should we check if we are root?
# check root
if os.getuid() != 0:
raise UsageError('Root rights are needed')
if command == 'register': if command == 'register':
call(register) call(register)
elif command == 'software': elif command == 'software':
...@@ -221,3 +228,4 @@ Node subcommands usage: ...@@ -221,3 +228,4 @@ Node subcommands usage:
'forum. Please also make sure that SlapOS Node is up to ' 'forum. Please also make sure that SlapOS Node is up to '
'date.' % exception) 'date.' % exception)
sys.exit(1) sys.exit(1)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment