Fix userfetch so that it works regardless of whether or not userpriv is enabled for...
authorZac Medico <zmedico@gentoo.org>
Mon, 22 May 2006 05:59:02 +0000 (05:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 22 May 2006 05:59:02 +0000 (05:59 -0000)
svn path=/main/trunk/; revision=3387

pym/portage.py

index 7522dc18a571c125dde97388dee0b0e798c7da31..e46e3b62df7b2d7e5a45e042efa8a3d838b7bdbc 100644 (file)
@@ -2144,15 +2144,29 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        writemsg(">>> Downloading "+str(loc)+"\n")
                                        myfetch=string.replace(locfetch,"${URI}",loc)
                                        myfetch=string.replace(myfetch,"${FILE}",myfile)
+
+                                       spawn_keywords = {}
+                                       if "userfetch" in mysettings.features and \
+                                               os.getuid() == 0 and portage_gid and portage_uid:
+                                               spawn_keywords.update({
+                                                       "uid"    : portage_uid,
+                                                       "gid"    : portage_gid,
+                                                       "groups" : [portage_gid],
+                                                       "umask"  : 002})
+
                                        try:
+
                                                if mysettings.selinux_enabled():
                                                        con = selinux.getcontext()
                                                        con = string.replace(con, mysettings["PORTAGE_T"], mysettings["PORTAGE_FETCH_T"])
                                                        selinux.setexec(con)
-                                                       myret = spawn(myfetch, mysettings, free=1, droppriv=("userfetch" in mysettings.features))
+
+                                               myret = portage_exec.spawn_bash(myfetch,
+                                                       env=mysettings.environ(), **spawn_keywords)
+
+                                               if mysettings.selinux_enabled():
                                                        selinux.setexec(None)
-                                               else:
-                                                       myret = spawn(myfetch, mysettings, free=1, droppriv=("userfetch" in mysettings.features))
+
                                        finally:
                                                #if root, -always- set the perms.
                                                if os.path.exists(mysettings["DISTDIR"]+"/"+myfile) and (fetched != 1 or os.getuid() == 0) \