From f8aeff8f33eaf6b9f634a45278f9eaef11633427 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 25 Jan 2013 11:48:46 -0800 Subject: [PATCH] Handle getpwuid KeyError for bug #454060. --- pym/portage/package/ebuild/doebuild.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 71a6f156f..8c265238d 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -1420,8 +1420,30 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero 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 "PORTAGE_BUILD_USER" not in mysettings: + user = None + try: + user = pwd.getpwuid(portage_build_uid).pw_name + except KeyError: + if portage_build_uid == 0: + user = "root" + elif portage_build_uid == portage_uid: + user = portage.data._portage_username + if user is not None: + mysettings["PORTAGE_BUILD_USER"] = user + + if "PORTAGE_BUILD_GROUP" not in mysettings: + group = None + try: + group = grp.getgrgid(portage_build_gid).gr_name + except KeyError: + if portage_build_gid == 0: + group = "root" + elif portage_build_gid == portage_gid: + group = portage.data._portage_grpname + if group is not None: + mysettings["PORTAGE_BUILD_GROUP"] = group if not free: free=((droppriv and "usersandbox" not in features) or \ -- 2.26.2