mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] defaulting running hook_exec as root
This commit is contained in:
parent
4b9e2ffbbc
commit
b0730d8463
1 changed files with 7 additions and 2 deletions
|
@ -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,
|
def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
chdir=None, env=None):
|
chdir=None, env=None, user=None):
|
||||||
"""
|
"""
|
||||||
Execute hook from a file with arguments
|
Execute hook from a file with arguments
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
no_trace -- Do not print each command that will be executed
|
no_trace -- Do not print each command that will be executed
|
||||||
chdir -- The directory from where the script will be executed
|
chdir -- The directory from where the script will be executed
|
||||||
env -- Dictionnary of environment variables to export
|
env -- Dictionnary of environment variables to export
|
||||||
|
user -- User with which to run the command
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from moulinette.utils.process import call_async_output
|
from moulinette.utils.process import call_async_output
|
||||||
|
@ -327,7 +328,11 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
cmd_script = path
|
cmd_script = path
|
||||||
|
|
||||||
# Construct command to execute
|
# Construct command to execute
|
||||||
command = ['sudo', '-n', '-u', 'admin', '-H', 'sh', '-c']
|
if user is not None:
|
||||||
|
command = ['sudo', '-n', '-u', user, '-H', 'sh', '-c']
|
||||||
|
else:
|
||||||
|
command = ['sh', '-c']
|
||||||
|
|
||||||
if no_trace:
|
if no_trace:
|
||||||
cmd = '/bin/bash "{script}" {args}'
|
cmd = '/bin/bash "{script}" {args}'
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue