From: Rishabh Dave Date: Fri, 12 Apr 2019 11:56:45 +0000 (+0530) Subject: qa: command to be ran as a different user should be a single string X-Git-Tag: v15.1.0~2911^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5462ba5d9deebaf178ab363ce010447a4b99f7c3;p=ceph-ci.git qa: command to be ran as a different user should be a single string Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 4991ef24729..58fadbbbea3 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"]