diff --git a/pungi/wrappers/kojiwrapper.py b/pungi/wrappers/kojiwrapper.py index c69af800..3cd9ac97 100644 --- a/pungi/wrappers/kojiwrapper.py +++ b/pungi/wrappers/kojiwrapper.py @@ -114,7 +114,10 @@ class KojiWrapper(object): command = "rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; " + command if destdir: + # Make the files world readable command += " && chmod -R a+r %s" % shlex_quote(destdir) + # and owned by the same user that is running the process + command += " && chown -R %d %s" % (os.getuid(), shlex_quote(destdir)) cmd.append(command) return cmd diff --git a/tests/test_koji_wrapper.py b/tests/test_koji_wrapper.py index e99cc137..34d8b3a3 100644 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -430,6 +430,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase): '--task-id', '--weight=1000', '--package=some_other_package', '--package=lorax', '--mount=/tmp']) + @mock.patch("os.getuid", new=lambda: 1010) def test_with_destdir(self): cmd = self.koji.get_runroot_cmd('tgt', 's390x', ['/bin/echo', '&'], quiet=True, channel='chan', @@ -441,7 +442,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase): self.assertEqual(cmd[-2], 's390x') self.assertEqual( cmd[-1], - "rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; /bin/echo '&' && chmod -R a+r '/output dir'" + "rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; /bin/echo '&' && chmod -R a+r '/output dir' && chown -R 1010 '/output dir'" ) self.assertItemsEqual(cmd[3:-3], ['--channel-override=chan', '--quiet', '--use-shell',