Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/rsync/
Date: Thu, 03 Jan 2019 07:11:21
Message-Id: 1546496502.8ddc902ba8cb4712a2a8b49f46951c8ec326a678.zmedico@gentoo
1 commit: 8ddc902ba8cb4712a2a8b49f46951c8ec326a678
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 3 02:48:32 2019 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 3 06:21:42 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8ddc902b
7
8 rsync: use ${PORTAGE_TMPDIR}/portage (bug 671808)
9
10 Write temporary timestamp files in ${PORTAGE_TMPDIR}/portage,
11 since writing files directly in ${PORTAGE_TMPDIR} is generally
12 unexpected. Also, use the rsync --inplace option, since it's
13 writing to a temp file created in advance and the usersync
14 user does not necessarily have write access to the parent
15 directory.
16
17 Bug: https://bugs.gentoo.org/671808
18 Bug: https://bugs.gentoo.org/336503
19 Fixes: 3f7f72cf339d ("Bug #336503 - Use PORTAGE_TMPDIR for the emerge --sync server timestamp")
20 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
21
22 lib/portage/sync/modules/rsync/rsync.py | 11 +++++++++--
23 1 file changed, 9 insertions(+), 2 deletions(-)
24
25 diff --git a/lib/portage/sync/modules/rsync/rsync.py b/lib/portage/sync/modules/rsync/rsync.py
26 index 0f8221776..e6f2688f8 100644
27 --- a/lib/portage/sync/modules/rsync/rsync.py
28 +++ b/lib/portage/sync/modules/rsync/rsync.py
29 @@ -583,11 +583,17 @@ class RsyncSync(NewBase):
30 # Temporary file for remote server timestamp comparison.
31 # NOTE: If FEATURES=usersync is enabled then the tempfile
32 # needs to be in a directory that's readable by the usersync
33 - # user. We assume that PORTAGE_TMPDIR will satisfy this
34 + # user. We assume that ${PORTAGE_TMPDIR}/portage will satisfy this
35 # requirement, since that's not necessarily true for the
36 # default directory used by the tempfile module.
37 if self.usersync_uid is not None:
38 - tmpdir = self.settings['PORTAGE_TMPDIR']
39 + tmpdir = os.path.join(self.settings['PORTAGE_TMPDIR'], 'portage')
40 + ensure_dirs_kwargs = {}
41 + if portage.secpass >= 1:
42 + ensure_dirs_kwargs['gid'] = portage.portage_gid
43 + ensure_dirs_kwargs['mode'] = 0o70
44 + ensure_dirs_kwargs['mask'] = 0
45 + portage.util.ensure_dirs(tmpdir, **ensure_dirs_kwargs)
46 else:
47 # use default dir from tempfile module
48 tmpdir = None
49 @@ -598,6 +604,7 @@ class RsyncSync(NewBase):
50 portage.util.apply_permissions(tmpservertimestampfile,
51 uid=self.usersync_uid)
52 command = rsynccommand[:]
53 + command.append('--inplace')
54 command.append(syncuri.rstrip("/") + \
55 "/metadata/timestamp.chk")
56 command.append(tmpservertimestampfile)