]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: command to be ran as a different user should be a single string
authorRishabh Dave <ridave@redhat.com>
Fri, 12 Apr 2019 11:56:45 +0000 (17:26 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 17 Apr 2019 18:28:19 +0000 (23:58 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index 4991ef24729fc9e92ee50230dbd5e1fc251da525..58fadbbbea355b8ccf23e57cbf5bf3de183e7cd6 100644 (file)
@@ -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"]