Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 344307 | Differences between
and this patch

Collapse All | Expand All

(-)a/pym/portage/data.py (-9 / +16 lines)
Lines 92-112 def _get_global(k): Link Here
92
		#Discover the uid and gid of the portage user/group
92
		#Discover the uid and gid of the portage user/group
93
		keyerror = False
93
		keyerror = False
94
		try:
94
		try:
95
			portage_uid = pwd.getpwnam(_get_global('_portage_username')).pw_uid
95
			username = _get_global('_portage_username')
96
			portage_uid = pwd.getpwnam(username).pw_uid
96
		except KeyError:
97
		except KeyError:
97
			# PREFIX LOCAL: some sysadmins are insane, bug #344307
98
			# PREFIX LOCAL: some sysadmins are insane, bug #344307
98
			if _portage_grpname.isdigit():
99
			if username.isdigit():
99
				portage_gid = int(_portage_grpname)
100
				portage_uid = int(username)
100
			else:
101
			else:
101
				keyerror = True
102
				keyerror = True
103
				portage_uid = 0
102
			# END PREFIX LOCAL
104
			# END PREFIX LOCAL
103
			portage_uid = 0
104
105
105
		try:
106
		try:
106
			portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
107
			grpname = _get_global('_portage_grpname')
108
			portage_gid = grp.getgrnam(grpname).gr_gid
107
		except KeyError:
109
		except KeyError:
108
			keyerror = True
110
			# PREFIX LOCAL: some sysadmins are insane, bug #344307
109
			portage_gid = 0
111
			if grpname.isdigit():
112
				portage_gid = int(grpname)
113
			else:
114
				keyerror = True
115
				portage_gid = 0
116
			# END PREFIX LOCAL
110
117
111
		if secpass < 1 and portage_gid in os.getgroups():
118
		if secpass < 1 and portage_gid in os.getgroups():
112
			secpass = 1
119
			secpass = 1
Lines 204-217 def _get_global(k): Link Here
204
					try:
211
					try:
205
						grp_struct = grp.getgrgid(eroot_st.st_gid)
212
						grp_struct = grp.getgrgid(eroot_st.st_gid)
206
					except KeyError:
213
					except KeyError:
207
						pass
214
						v = eroot_st.st_gid
208
					else:
215
					else:
209
						v = grp_struct.gr_name
216
						v = grp_struct.gr_name
210
				else:
217
				else:
211
					try:
218
					try:
212
						pwd_struct = pwd.getpwuid(eroot_st.st_uid)
219
						pwd_struct = pwd.getpwuid(eroot_st.st_uid)
213
					except KeyError:
220
					except KeyError:
214
						pass
221
						v = eroot_st.st_uid
215
					else:
222
					else:
216
						v = pwd_struct.pw_name
223
						v = pwd_struct.pw_name
217
224
(-)a/pym/portage/package/ebuild/doebuild.py (+4 lines)
Lines 1528-1533 def spawn(mystring, mysettings, debug=False, free=False, droppriv=False, Link Here
1528
				user = "root"
1528
				user = "root"
1529
			elif portage_build_uid == portage_uid:
1529
			elif portage_build_uid == portage_uid:
1530
				user = portage.data._portage_username
1530
				user = portage.data._portage_username
1531
			else:
1532
				user = portage_uid
1531
		if user is not None:
1533
		if user is not None:
1532
			mysettings["PORTAGE_BUILD_USER"] = user
1534
			mysettings["PORTAGE_BUILD_USER"] = user
1533
1535
Lines 1540-1545 def spawn(mystring, mysettings, debug=False, free=False, droppriv=False, Link Here
1540
				group = "root"
1542
				group = "root"
1541
			elif portage_build_gid == portage_gid:
1543
			elif portage_build_gid == portage_gid:
1542
				group = portage.data._portage_grpname
1544
				group = portage.data._portage_grpname
1545
			else:
1546
				group = portage_gid
1543
		if group is not None:
1547
		if group is not None:
1544
			mysettings["PORTAGE_BUILD_GROUP"] = group
1548
			mysettings["PORTAGE_BUILD_GROUP"] = group
1545
1549
(-)a/pym/portage/tests/runTests (-2 / +8 lines)
Lines 24-31 signal.signal(debug_signum, debug_signal) Link Here
24
# Pretend that the current user's uid/gid are the 'portage' uid/gid,
24
# Pretend that the current user's uid/gid are the 'portage' uid/gid,
25
# so things go smoothly regardless of the current user and global
25
# so things go smoothly regardless of the current user and global
26
# user/group configuration.
26
# user/group configuration.
27
os.environ["PORTAGE_USERNAME"] = pwd.getpwuid(os.getuid()).pw_name
27
try:
28
os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name
28
	os.environ["PORTAGE_USERNAME"] = pwd.getpwuid(os.getuid()).pw_name
29
except KeyError:
30
	os.environ["PORTAGE_USERNAME"] = str(os.getuid())
31
try:
32
	os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name
33
except KeyError:
34
	os.environ["PORTAGE_GRPNAME"] = str(os.getgid())
29
35
30
# Insert our parent dir so we can do shiny import "tests"
36
# Insert our parent dir so we can do shiny import "tests"
31
# This line courtesy of Marienz and Pkgcore ;)
37
# This line courtesy of Marienz and Pkgcore ;)

Return to bug 344307