From 33e101b58840555ef49eeed122ac57f1ef90ae40 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 7 Jul 2016 22:39:04 +0200 Subject: [PATCH] [mod] change behavior, admin by default, as to explicitly set root as user --- src/yunohost/hook.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/yunohost/hook.py b/src/yunohost/hook.py index 6bf515931..0ce09b924 100644 --- a/src/yunohost/hook.py +++ b/src/yunohost/hook.py @@ -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}'