From 5462ba5d9deebaf178ab363ce010447a4b99f7c3 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Fri, 12 Apr 2019 17:26:45 +0530 Subject: [PATCH] qa: command to be ran as a different user should be a single string Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 4991ef24729fc..58fadbbbea355 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -263,6 +263,15 @@ class LocalRemote(object): raise RuntimeError("Don't surround commands by " "single/double quotes") + # ['sudo', '-u', 'user', '-s', 'path-to-shell', '-c', 'ls', 'a'] + # and ['sudo', '-u', user, '-s', path_to_shell, '-c', 'ls a'] are + # treated differently by Python's shell simulation. Only latter has + # the desired effect. + if 'sudo' in args and '-c' in args: + if args.index('-c') != len(args) - 2: + raise RuntimeError("All args after '-c' should be a single " + "string") + if omit_sudo: args = [a for a in args if a != "sudo"] -- 2.39.5