From 94bc5e286db88d51ed3687ec1fa85ec379e4e406 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Mon, 9 Nov 2020 18:36:16 +0100 Subject: [PATCH] Do not use shlex_quote in get_pungi_buildinstall_cmd and get_pungi_ostree_cmd. These methods return command as list which is never serialized to str and never executed using bash. It is instead passed directly to `kobo.shortcuts.run`. The `shlex_quote` usage here actually breaks the code, because it adds quotes there which are needed only if this command would be serialized to string and passed to bash. But this never happens. As a result, the arguments passed to `kobo.shortcuts.run` contain those extra quotes. In this commit the shlex_quote is removed completely from this part of code. Signed-off-by: Jan Kaluza --- pungi/wrappers/kojiwrapper.py | 4 +-- tests/test_koji_wrapper.py | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/pungi/wrappers/kojiwrapper.py b/pungi/wrappers/kojiwrapper.py index aec0eaeb..1d80afd9 100644 --- a/pungi/wrappers/kojiwrapper.py +++ b/pungi/wrappers/kojiwrapper.py @@ -199,7 +199,7 @@ class KojiWrapper(object): cmd.append("%s=%d" % (k, v)) else: for arg in force_list(v): - cmd.append(shlex_quote("%s=%s" % (k, arg))) + cmd.append("%s=%s" % (k, arg)) return cmd @@ -239,7 +239,7 @@ class KojiWrapper(object): cmd.append("%s=%d" % (k, v)) else: for arg in force_list(v): - cmd.append(shlex_quote("%s=%s" % (k, arg))) + cmd.append("%s=%s" % (k, arg)) return cmd diff --git a/tests/test_koji_wrapper.py b/tests/test_koji_wrapper.py index 08daf12d..67a0a305 100644 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -990,6 +990,64 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase): ], ) + def test_get_pungi_buildinstall_cmd(self): + args = {"product": "Fedora 23"} + cmd = self.koji.get_pungi_buildinstall_cmd( + "rrt", + "x86_64", + args, + channel=None, + packages=["lorax"], + mounts=["/tmp"], + weight=123, + chown_uid=456, + ) + + expected_cmd = [ + "koji", + "--profile=custom-koji", + "pungi-buildinstall", + "--nowait", + "--task-id", + "--channel-override=runroot-local", + "--weight=123", + "--package=lorax", + "--mount=/tmp", + "--chown-uid=456", + "rrt", + "x86_64", + "product=Fedora 23", + ] + self.assertEqual(cmd, expected_cmd) + + def test_get_pungi_ostree_cmd(self): + args = {"product": "Fedora 23"} + cmd = self.koji.get_pungi_ostree_cmd( + "rrt", + "x86_64", + args, + channel=None, + packages=["lorax"], + mounts=["/tmp"], + weight=123, + ) + + expected_cmd = [ + "koji", + "--profile=custom-koji", + "pungi-ostree", + "--nowait", + "--task-id", + "--channel-override=runroot-local", + "--weight=123", + "--package=lorax", + "--mount=/tmp", + "rrt", + "x86_64", + "product=Fedora 23", + ] + self.assertEqual(cmd, expected_cmd) + RPM_QA_QF_OUTPUT = """ cjkuni-uming-fonts-0.2.20080216.1-56.fc23.noarch