commit:     63b509e6d2c0db4343b255455fda1aa3b666bd9c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 11 03:07:09 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 15 23:03:54 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=63b509e6

socks5: use ${PORTAGE_TMPDIR}/portage (bug 683040)

Write temporary socket files in ${PORTAGE_TMPDIR}/portage,
since writing files directly in ${PORTAGE_TMPDIR} is generally
unexpected.

Bug: https://bugs.gentoo.org/683040
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/util/socks5.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index 59e6699ec..86bb24f25 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -38,7 +38,15 @@ class ProxyManager(object):
                except ImportError:
                        raise NotImplementedError('SOCKSv5 proxy requires 
asyncio module')
 
-               self.socket_path = os.path.join(settings['PORTAGE_TMPDIR'],
+               tmpdir = os.path.join(settings['PORTAGE_TMPDIR'], 'portage')
+               ensure_dirs_kwargs = {}
+               if portage.secpass >= 1:
+                       ensure_dirs_kwargs['gid'] = portage_gid
+                       ensure_dirs_kwargs['mode'] = 0o70
+                       ensure_dirs_kwargs['mask'] = 0
+               portage.util.ensure_dirs(tmpdir, **ensure_dirs_kwargs)
+
+               self.socket_path = os.path.join(tmpdir,
                                '.portage.%d.net.sock' % os.getpid())
                server_bin = os.path.join(settings['PORTAGE_BIN_PATH'], 
'socks5-server.py')
                spawn_kwargs = {}

Reply via email to