summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2019-01-02 18:48:32 -0800
committerZac Medico <zmedico@gentoo.org>2019-01-02 22:21:42 -0800
commit8ddc902ba8cb4712a2a8b49f46951c8ec326a678 (patch)
treefc64497bc3ec8e41c093a2e6e4b7b68a948777c6
parent_check_temp_dir: fix message to refer to correct bug 378403 (diff)
downloadportage-8ddc902ba8cb4712a2a8b49f46951c8ec326a678.tar.gz
portage-8ddc902ba8cb4712a2a8b49f46951c8ec326a678.tar.bz2
portage-8ddc902ba8cb4712a2a8b49f46951c8ec326a678.zip
rsync: use ${PORTAGE_TMPDIR}/portage (bug 671808)
Write temporary timestamp files in ${PORTAGE_TMPDIR}/portage, since writing files directly in ${PORTAGE_TMPDIR} is generally unexpected. Also, use the rsync --inplace option, since it's writing to a temp file created in advance and the usersync user does not necessarily have write access to the parent directory. Bug: https://bugs.gentoo.org/671808 Bug: https://bugs.gentoo.org/336503 Fixes: 3f7f72cf339d ("Bug #336503 - Use PORTAGE_TMPDIR for the emerge --sync server timestamp") Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/portage/sync/modules/rsync/rsync.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/portage/sync/modules/rsync/rsync.py b/lib/portage/sync/modules/rsync/rsync.py
index 0f8221776..e6f2688f8 100644
--- a/lib/portage/sync/modules/rsync/rsync.py
+++ b/lib/portage/sync/modules/rsync/rsync.py
@@ -583,11 +583,17 @@ class RsyncSync(NewBase):
# Temporary file for remote server timestamp comparison.
# 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
+ # user. We assume that ${PORTAGE_TMPDIR}/portage will satisfy this
# requirement, since that's not necessarily true for the
# default directory used by the tempfile module.
if self.usersync_uid is not None:
- tmpdir = self.settings['PORTAGE_TMPDIR']
+ tmpdir = os.path.join(self.settings['PORTAGE_TMPDIR'], 'portage')
+ ensure_dirs_kwargs = {}
+ if portage.secpass >= 1:
+ ensure_dirs_kwargs['gid'] = portage.portage_gid
+ ensure_dirs_kwargs['mode'] = 0o70
+ ensure_dirs_kwargs['mask'] = 0
+ portage.util.ensure_dirs(tmpdir, **ensure_dirs_kwargs)
else:
# use default dir from tempfile module
tmpdir = None
@@ -598,6 +604,7 @@ class RsyncSync(NewBase):
portage.util.apply_permissions(tmpservertimestampfile,
uid=self.usersync_uid)
command = rsynccommand[:]
+ command.append('--inplace')
command.append(syncuri.rstrip("/") + \
"/metadata/timestamp.chk")
command.append(tmpservertimestampfile)