summaryrefslogtreecommitdiffstats
path: root/pym/portage/package
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-11-16 05:35:57 +0100
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-11-16 05:35:57 +0100
commit4b22701aa7733e53778fc4d456819fc010e198b0 (patch)
treed857e70131bf9c8f4582c905a01bbc0e0260de16 /pym/portage/package
parenta6a9b6dd6342a6009097944b38163ccc66908f0e (diff)
downloadportage-4b22701aa7733e53778fc4d456819fc010e198b0.tar.gz
portage-4b22701aa7733e53778fc4d456819fc010e198b0.tar.bz2
portage-4b22701aa7733e53778fc4d456819fc010e198b0.zip
EAPI="5-progress": Add package_manager_build_user() and package_manager_build_group().
Diffstat (limited to 'pym/portage/package')
-rw-r--r--pym/portage/package/ebuild/_config/special_env_vars.py3
-rw-r--r--pym/portage/package/ebuild/doebuild.py22
2 files changed, 20 insertions, 5 deletions
diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
index 3ca9687ec..150dafeba 100644
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@ -51,7 +51,8 @@ environ_whitelist += [
"PORTAGE_BINPKG_FILE", "PORTAGE_BINPKG_TAR_OPTS",
"PORTAGE_BINPKG_TMPFILE",
"PORTAGE_BIN_PATH",
- "PORTAGE_BUILDDIR", "PORTAGE_BUNZIP2_COMMAND", "PORTAGE_BZIP2_COMMAND",
+ "PORTAGE_BUILDDIR", "PORTAGE_BUILD_GROUP", "PORTAGE_BUILD_USER",
+ "PORTAGE_BUNZIP2_COMMAND", "PORTAGE_BZIP2_COMMAND",
"PORTAGE_COLORMAP", "PORTAGE_COMPRESS",
"PORTAGE_COMPRESS_EXCLUDE_SUFFIXES",
"PORTAGE_CONFIGROOT", "PORTAGE_DEBUG", "PORTAGE_DEPCACHEDIR",
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 0a1f1df0e..5002c5bab 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -3,12 +3,14 @@
__all__ = ['doebuild', 'doebuild_environment', 'spawn', 'spawnebuild']
+import grp
import gzip
import errno
import io
from itertools import chain
import logging
import os as _os
+import pwd
import re
import signal
import stat
@@ -1419,10 +1421,22 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
# fake ownership/permissions will have to be converted to real
# permissions in the merge phase.
fakeroot = fakeroot and uid != 0 and portage.process.fakeroot_capable
- if droppriv and uid == 0 and portage_gid and portage_uid and \
- hasattr(os, "setgroups"):
- keywords.update({"uid":portage_uid,"gid":portage_gid,
- "groups":userpriv_groups,"umask":0o02})
+ portage_build_uid = os.getuid()
+ portage_build_gid = os.getgid()
+ if uid == 0 and portage_uid and portage_gid and hasattr(os, "setgroups"):
+ if droppriv:
+ keywords.update({
+ "uid": portage_uid,
+ "gid": portage_gid,
+ "groups": userpriv_groups,
+ "umask": 0o02
+ })
+ if "userpriv" in features and "userpriv" not in mysettings["PORTAGE_RESTRICT"].split() and secpass >= 2:
+ portage_build_uid = portage_uid
+ portage_build_gid = portage_gid
+ mysettings["PORTAGE_BUILD_USER"] = pwd.getpwuid(portage_build_uid).pw_name
+ mysettings["PORTAGE_BUILD_GROUP"] = grp.getgrgid(portage_build_gid).gr_name
+
if not free:
free=((droppriv and "usersandbox" not in features) or \
(not droppriv and "sandbox" not in features and \