aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-10-07 08:57:23 -0700
committerZac Medico <zmedico@gentoo.org>2010-10-07 08:57:23 -0700
commit59b1c6e1d2f6010ffac296aae26955437a5b3b76 (patch)
tree7e0715fd7f0bc680d7ace14debf61b1a3c426a94 /pym/_emerge/actions.py
parentReport len(ips) as max retry count for --sync. (diff)
downloadportage-59b1c6e1d2f6010ffac296aae26955437a5b3b76.tar.gz
portage-59b1c6e1d2f6010ffac296aae26955437a5b3b76.tar.bz2
portage-59b1c6e1d2f6010ffac296aae26955437a5b3b76.zip
Use PORTAGE_TMPDIR if necessary for usersync.
Bug #340046 - Don't require PORTAGE_TMPDIR access for --sync unless it's really necessary.
Diffstat (limited to 'pym/_emerge/actions.py')
-rw-r--r--pym/_emerge/actions.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index f49f455b8..d064facd1 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1894,12 +1894,6 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
os.makedirs(myportdir,0o755)
st = os.stat(myportdir)
- # PORTAGE_TMPDIR is used below, so validate it and
- # bail out if necessary.
- rval = _check_temp_dir(settings)
- if rval != os.EX_OK:
- return rval
-
usersync_uid = None
spawn_kwargs = {}
spawn_kwargs["env"] = settings.environ()
@@ -1924,6 +1918,13 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
umask = umask | 0o020
spawn_kwargs["umask"] = umask
+ if usersync_uid is not None:
+ # PORTAGE_TMPDIR is used below, so validate it and
+ # bail out if necessary.
+ rval = _check_temp_dir(settings)
+ if rval != os.EX_OK:
+ return rval
+
syncuri = settings.get("SYNC", "").strip()
if not syncuri:
writemsg_level("!!! SYNC is undefined. " + \
@@ -2183,8 +2184,13 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
# 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.
+ if usersync_uid is not None:
+ tmpdir = settings['PORTAGE_TMPDIR']
+ else:
+ # use default dir from tempfile module
+ tmpdir = None
fd, tmpservertimestampfile = \
- tempfile.mkstemp(dir=settings['PORTAGE_TMPDIR'])
+ tempfile.mkstemp(dir=tmpdir)
os.close(fd)
if usersync_uid is not None:
portage.util.apply_permissions(tmpservertimestampfile,