secpass = 2
#Discover the uid and gid of the portage user/group
try:
++<<<<<<< HEAD
++=======
+ portage_uid = pwd.getpwnam(_get_global('_portage_username')).pw_uid
++>>>>>>> overlays-gentoo-org/master
portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
+ except KeyError:
+ # PREFIX LOCAL: some sysadmins are insane, bug #344307
+ if _get_global('_portage_grpname').isdigit():
+ portage_gid = int(_get_global('_portage_grpname'))
+ else:
+ portage_gid = None
+ # END PREFIX LOCAL
+ try:
+ portage_uid = pwd.getpwnam(_get_global('_portage_uname')).pw_uid
if secpass < 1 and portage_gid in os.getgroups():
secpass = 1
except KeyError:
pass
v = sorted(set(v))
+ # Avoid instantiating portage.settings when the desired
+ # variable is set in os.environ.
elif k == '_portage_grpname':
- env = getattr(portage, 'settings', os.environ)
- # PREFIX LOCAL: use var iso hardwired 'portage'
- v = env.get('PORTAGE_GRPNAME', PORTAGE_GROUPNAME)
- # END PREFIX LOCAL
- elif k == '_portage_uname':
- env = getattr(portage, 'settings', os.environ)
- # PREFIX LOCAL: use var iso hardwired 'portage'
- v = env.get('PORTAGE_USERNAME', PORTAGE_USERNAME)
- # END PREFIX LOCAL
+ v = None
+ if 'PORTAGE_GRPNAME' in os.environ:
+ v = os.environ['PORTAGE_GRPNAME']
+ elif hasattr(portage, 'settings'):
+ v = portage.settings.get('PORTAGE_GRPNAME')
+ if v is None:
- v = 'portage'
++ # PREFIX LOCAL: use var iso hardwired 'portage'
++ v = PORTAGE_GROUPNAME
++ # END PREFIX LOCAL
+ elif k == '_portage_username':
+ v = None
+ if 'PORTAGE_USERNAME' in os.environ:
+ v = os.environ['PORTAGE_USERNAME']
+ elif hasattr(portage, 'settings'):
+ v = portage.settings.get('PORTAGE_USERNAME')
+ if v is None:
- v = 'portage'
++ # PREFIX LOCAL: use var iso hardwired 'portage'
++ v = PORTAGE_USERNAME
++ # END PREFIX LOCAL
else:
raise AssertionError('unknown name: %s' % k)
initialize global variables. This allows settings to come from make.conf
instead of requiring them to be set in the calling environment.
"""
- if '_portage_grpname' not in _initialized_globals:
- v = settings.get('PORTAGE_GRPNAME')
- if v is not None:
- globals()['_portage_grpname'] = v
- _initialized_globals.add('_portage_grpname')
-
- if '_portage_uname' not in _initialized_globals:
- v = settings.get('PORTAGE_USERNAME')
- if v is not None:
- globals()['_portage_uname'] = v
- _initialized_globals.add('_portage_uname')
+ if '_portage_grpname' not in _initialized_globals and \
+ '_portage_username' not in _initialized_globals:
+
- v = settings.get('PORTAGE_GRPNAME', 'portage')
++ # PREFIX LOCAL: use var iso hardwired 'portage'
++ v = settings.get('PORTAGE_GRPNAME', PORTAGE_GROUPNAME)
++ # END PREFIX LOCAL
+ globals()['_portage_grpname'] = v
+ _initialized_globals.add('_portage_grpname')
+
- v = settings.get('PORTAGE_USERNAME', 'portage')
++ # PREFIX LOCAL: use var iso hardwired 'portage'
++ v = settings.get('PORTAGE_USERNAME', PORTAGE_USERNAME)
++ # END PREFIX LOCAL
+ globals()['_portage_username'] = v
+ _initialized_globals.add('_portage_username')
'portage.util.digraph:digraph',
'portage.util.env_update:env_update',
'portage.util.listdir:dircache,listdir',
+ 'portage.util.movefile:movefile',
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry',
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap',
+ 'portage.util._dyn_libs.LinkageMapMachO:LinkageMapMachO',
+ 'portage.util._dyn_libs.LinkageMapPeCoff:LinkageMapPeCoff',
+ 'portage.util._dyn_libs.LinkageMapXCoff:LinkageMapXCoff',
'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,pkgcmp,' + \
'_pkgsplit@pkgsplit',
'tarfile',