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

Collapse All | Expand All

(-)pym/portage/locks.py.back (-8 / +11 lines)
Lines 111-116 Link Here
111
		raise InvalidData(_("Empty path given"))
111
		raise InvalidData(_("Empty path given"))
112
112
113
	# Since Python 3.4, chown requires int type (no proxies).
113
	# Since Python 3.4, chown requires int type (no proxies).
114
	portage_uid = int(portage.data.portage_uid)
114
	portage_gid = int(portage.data.portage_gid)
115
	portage_gid = int(portage.data.portage_gid)
115
116
116
	# Support for file object or integer file descriptor parameters is
117
	# Support for file object or integer file descriptor parameters is
Lines 163-170 Link Here
163
164
164
			if not preexisting:
165
			if not preexisting:
165
				try:
166
				try:
166
					if os.stat(lockfilename).st_gid != portage_gid:
167
					stat_obj = os.stat(lockfilename)
167
						os.chown(lockfilename, -1, portage_gid)
168
					if (stat_obj.st_uid != portage_uid) or (stat_obj.st_gid != portage_gid):
169
						os.chown(lockfilename, portage_uid, portage_gid)
168
				except OSError as e:
170
				except OSError as e:
169
					if e.errno in (errno.ENOENT, errno.ESTALE):
171
					if e.errno in (errno.ENOENT, errno.ESTALE):
170
						return lockfile(mypath,
172
						return lockfile(mypath,
Lines 172-179 Link Here
172
							unlinkfile=unlinkfile, waiting_msg=waiting_msg,
174
							unlinkfile=unlinkfile, waiting_msg=waiting_msg,
173
							flags=flags)
175
							flags=flags)
174
					else:
176
					else:
175
						writemsg("%s: chown('%s', -1, %d)\n" % \
177
						writemsg("%s: chown('%s', %d, %d)\n" % \
176
							(e, lockfilename, portage_gid), noiselevel=-1)
178
							(e, lockfilename, portage_uid, portage_gid), noiselevel=-1)
177
						writemsg(_("Cannot chown a lockfile: '%s'\n") % \
179
						writemsg(_("Cannot chown a lockfile: '%s'\n") % \
178
							lockfilename, noiselevel=-1)
180
							lockfilename, noiselevel=-1)
179
						writemsg(_("Group IDs of current user: %s\n") % \
181
						writemsg(_("Group IDs of current user: %s\n") % \
Lines 424-429 Link Here
424
	myhardlock = hardlock_name(lockfilename)
426
	myhardlock = hardlock_name(lockfilename)
425
427
426
	# Since Python 3.4, chown requires int type (no proxies).
428
	# Since Python 3.4, chown requires int type (no proxies).
429
	portage_uid = int(portage.data.portage_uid)
427
	portage_gid = int(portage.data.portage_gid)
430
	portage_gid = int(portage.data.portage_gid)
428
431
429
	# myhardlock must not exist prior to our link() call, and we can
432
	# myhardlock must not exist prior to our link() call, and we can
Lines 463-474 Link Here
463
				if not preexisting:
466
				if not preexisting:
464
					# Don't chown the file if it is preexisting, since we
467
					# Don't chown the file if it is preexisting, since we
465
					# want to preserve existing permissions in that case.
468
					# want to preserve existing permissions in that case.
466
					if myfd_st.st_gid != portage_gid:
469
					if (myfd_st.st_uid != portage_uid) or (myfd_st.st_gid != portage_gid):
467
						os.fchown(myfd, -1, portage_gid)
470
						os.fchown(myfd, portage_uid, portage_gid)
468
			except OSError as e:
471
			except OSError as e:
469
				if e.errno not in (errno.ENOENT, errno.ESTALE):
472
				if e.errno not in (errno.ENOENT, errno.ESTALE):
470
					writemsg("%s: fchown('%s', -1, %d)\n" % \
473
					writemsg("%s: fchown('%s', %d, %d)\n" % \
471
						(e, lockfilename, portage_gid), noiselevel=-1)
474
						(e, lockfilename, portage_uid, portage_gid), noiselevel=-1)
472
					writemsg(_("Cannot chown a lockfile: '%s'\n") % \
475
					writemsg(_("Cannot chown a lockfile: '%s'\n") % \
473
						lockfilename, noiselevel=-1)
476
						lockfilename, noiselevel=-1)
474
					writemsg(_("Group IDs of current user: %s\n") % \
477
					writemsg(_("Group IDs of current user: %s\n") % \

Return to bug 611114