commit:     597987aac1677e132b80ed2404697acf0188af7a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  6 20:14:54 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct  6 20:23:07 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=597987aa

apply_secpass_permissions: avoid accessing portage.data.secpass when possible

This fixes PermissionDenied errors triggered when portage config files
and repos have restricted access permissions.

Fixes: b7baeeec3ab6 ("unpack: use chmod-lite helper for bug 554084")

 pym/portage/util/__init__.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 2b7ff8d..b739257 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1241,7 +1241,9 @@ def apply_secpass_permissions(filename, uid=-1, gid=-1, 
mode=-1, mask=-1,
 
        all_applied = True
 
-       if portage.data.secpass < 2:
+       # Avoid accessing portage.data.secpass when possible, since
+       # it triggers config loading (undesirable for chmod-lite).
+       if (uid != -1 or gid != -1) and portage.data.secpass < 2:
 
                if uid != -1 and \
                uid != stat_cached.st_uid:

Reply via email to