Bug #336503 - Use PORTAGE_TMPDIR for the emerge --sync server timestamp
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Sep 2010 03:47:34 +0000 (20:47 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Sep 2010 03:47:34 +0000 (20:47 -0700)
tempfile, since with FEATURES=usersync, the default directory used by
the tempfile module may not be readbable by the usersync user.

pym/_emerge/actions.py

index f7709f0cd1e47dd26e886d3e20167bad6e45272d..d9d0dffe5e3238b52c6595fa79308d80c735c51d 100644 (file)
@@ -2115,8 +2115,13 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                        # --timeout option does not prevent.
                        if True:
                                # Temporary file for remote server timestamp comparison.
-                               from tempfile import mkstemp
-                               fd, tmpservertimestampfile = mkstemp()
+                               # NOTE: If FEATURES=usersync is enabled then the tempfile
+                               # needs to be in a directory that's readable by the usersync
+                               # user. We assume that PORTAGE_TMPDIR will satisfy this
+                               # requirement, since that's not necessarily true for the
+                               # default directory used by the tempfile module.
+                               fd, tmpservertimestampfile = \
+                                       tempfile.mkstemp(dir=settings['PORTAGE_TMPDIR'])
                                os.close(fd)
                                if usersync_uid is not None:
                                        portage.util.apply_permissions(tmpservertimestampfile,