Browse Source

Allow sudo to non-root

Bertrand Chenal 7 years ago
parent
commit
2ad75dd8ee
1 changed files with 2 additions and 1 deletions
  1. 2 1
      baker.py

+ 2 - 1
baker.py

@@ -433,7 +433,8 @@ def run_python(task, env, cli):
     logger.debug(TAB + TAB.join(code.splitlines()))
     cmd = 'python -c "import sys;exec(sys.stdin.read())"'
     if task.sudo:
-        cmd = 'sudo -- ' + cmd
+        user = 'root' if task.sudo is True else task.sudo
+        cmd = 'sudo -u {} -- {}'.format(user, cmd)
     process = subprocess.Popen(
         cmd,
         stdout=subprocess.PIPE,