Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Wed, 07 Sep 2011 17:37:01
Message-Id: 37d9c3df6b25f10a78ff216875bb481e0171fae0.zmedico@gentoo
1 commit: 37d9c3df6b25f10a78ff216875bb481e0171fae0
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 7 17:36:37 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 7 17:36:37 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=37d9c3df
7
8 pordbapi: add unshared cache mode for egencache
9
10 ---
11 pym/portage/dbapi/porttree.py | 33 +++++++++++++++++++++++++++------
12 1 files changed, 27 insertions(+), 6 deletions(-)
13
14 diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
15 index bf8ecd9..ac972c4 100644
16 --- a/pym/portage/dbapi/porttree.py
17 +++ b/pym/portage/dbapi/porttree.py
18 @@ -154,11 +154,32 @@ class portdbapi(dbapi):
19 self.auxdb = {}
20 self._pregen_auxdb = {}
21 self._init_cache_dirs()
22 - depcachedir_w_ok = os.access(self.depcachedir, os.W_OK)
23 - cache_kwargs = {
24 - 'gid' : portage_gid,
25 - 'perms' : 0o664
26 - }
27 + try:
28 + depcachedir_st = os.stat(self.depcachedir)
29 + depcachedir_w_ok = os.access(self.depcachedir, os.W_OK)
30 + except OSError:
31 + depcachedir_st = None
32 + depcachedir_w_ok = False
33 +
34 + cache_kwargs = {}
35 +
36 + depcachedir_unshared = False
37 + if portage.data.secpass < 1 and \
38 + depcachedir_w_ok and \
39 + depcachedir_st is not None and \
40 + os.getuid() == depcachedir_st.st_uid and \
41 + os.getgid() == depcachedir_st.st_gid:
42 + # If this user owns depcachedir and is not in the
43 + # portage group, then don't bother to set permissions
44 + # on cache entries. This makes it possible to run
45 + # egencache without any need to be a member of the
46 + # portage group.
47 + depcachedir_unshared = True
48 + else:
49 + cache_kwargs.update({
50 + 'gid' : portage_gid,
51 + 'perms' : 0o664
52 + })
53
54 # XXX: REMOVE THIS ONCE UNUSED_0 IS YANKED FROM auxdbkeys
55 # ~harring
56 @@ -167,7 +188,7 @@ class portdbapi(dbapi):
57 # If secpass < 1, we don't want to write to the cache
58 # since then we won't be able to apply group permissions
59 # to the cache entries/directories.
60 - if secpass < 1 or not depcachedir_w_ok:
61 + if (secpass < 1 and not depcachedir_unshared) or not depcachedir_w_ok:
62 for x in self.porttrees:
63 try:
64 db_ro = self.auxdbmodule(self.depcachedir, x,