[eit.commands.command] add support for unprivileged commands execution

This commit is contained in:
Fabio Erculiani
2011-10-15 00:09:25 +02:00
parent 6efe20ce5a
commit d936971f6a
2 changed files with 5 additions and 2 deletions

View File

@@ -31,6 +31,8 @@ class EitCommand(object):
ALIASES = []
# Set this to True if command is a catch-all (fallback)
CATCH_ALL = False
# Allow unprivileged access ?
ALLOW_UNPRIVILEGED = False
def __init__(self, args):
self._args = args

View File

@@ -69,8 +69,9 @@ def main():
allowed = True
if os.getuid() != 0 and \
cmd_class is not catch_all:
cmd_class = catch_all
allowed = False
if not cmd_class.ALLOW_UNPRIVILEGED:
cmd_class = catch_all
allowed = False
cmd_obj = cmd_class(args)
func, func_args = cmd_obj.parse()