#1082 koji_wrapper: Change owner of runroot output
Merged 5 years ago by lsedlar. Opened 5 years ago by lsedlar.
lsedlar/pungi runroot-owner  into  master

@@ -114,7 +114,10 @@ 

          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

file modified
+2 -1
@@ -430,6 +430,7 @@ 

                                 '--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 @@ 

          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',

The files created in runroot task are owned by root by default (because that's who is running the processes to create them). Making the results world readable allows the compose to work, but it still can be difficult to clean up old composes if they contain random files owned by root.

Fixes: https://pagure.io/pungi/issue/1039

I'll try to test this in stage before merging.

I tested it with koji stage: the actual buildinstall task is failing given package set that is present, so I modified it to only create a single file and then append the chmod command as pungi would generate it. The file was owned by the correct user.

rebased onto 07d0862

5 years ago

Problems? None were found.

Pull-Request has been merged by lsedlar

5 years ago