[mod] change behavior, admin by default, as to explicitly set root as user

This commit is contained in:
Laurent Peuch 2016-07-07 22:39:04 +02:00
parent b0730d8463
commit 33e101b588

View file

@ -292,7 +292,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
chdir=None, env=None, user=None):
chdir=None, env=None, user="admin"):
"""
Execute hook from a file with arguments
@ -328,10 +328,10 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
cmd_script = path
# Construct command to execute
if user is not None:
command = ['sudo', '-n', '-u', user, '-H', 'sh', '-c']
else:
if user == "root":
command = ['sh', '-c']
else:
command = ['sudo', '-n', '-u', user, '-H', 'sh', '-c']
if no_trace:
cmd = '/bin/bash "{script}" {args}'