Handle missing os.setgroups for PyPy.
authorZac Medico <zmedico@gentoo.org>
Mon, 13 Feb 2012 23:38:41 +0000 (15:38 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 13 Feb 2012 23:38:41 +0000 (15:38 -0800)
See https://bugs.pypy.org/issue833 for details.

pym/portage/package/ebuild/config.py
pym/portage/package/ebuild/doebuild.py
pym/portage/package/ebuild/fetch.py

index 366f548f1aaebfb64c67db1625465b02ffa8c7ea..4304e09c76fb754c05e16bdd9bb3d42a9512ae14 100644 (file)
@@ -938,6 +938,23 @@ class config(object):
                        writemsg(_("!!! FEATURES=fakeroot is enabled, but the "
                                "fakeroot binary is not installed.\n"), noiselevel=-1)
 
+               if os.getuid() == 0 and not hasattr(os, "setgroups"):
+                       warning_shown = False
+
+                       if "userpriv" in self.features:
+                               writemsg(_("!!! FEATURES=userpriv is enabled, but "
+                                       "os.setgroups is not available.\n"), noiselevel=-1)
+                               warning_shown = True
+
+                       if "userfetch" in self.features:
+                               writemsg(_("!!! FEATURES=userfetch is enabled, but "
+                                       "os.setgroups is not available.\n"), noiselevel=-1)
+                               warning_shown = True
+
+                       if warning_shown and platform.python_implementation() == 'PyPy':
+                               writemsg(_("!!! See https://bugs.pypy.org/issue833 for details.\n"),
+                                       noiselevel=-1)
+
        def load_best_module(self,property_string):
                best_mod = best_from_dict(property_string,self.modules,self.module_priority)
                mod = None
index c52ab3120fd90f0dc70d6806b4a8f4db1ef97720..c45aa030aa7810661f65612a17a146ded9ace574 100644 (file)
@@ -1388,7 +1388,8 @@ 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 not uid and portage_gid and portage_uid:
+       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})
        if not free:
index c67f3c4f410982972bce1034c7a9d7fd586328f8..8c20b71869c324aac11c868b104faa1abc3a5070 100644 (file)
@@ -66,7 +66,8 @@ def _spawn_fetch(settings, args, **kwargs):
                }
 
        if "userfetch" in settings.features and \
-               os.getuid() == 0 and portage_gid and portage_uid:
+               os.getuid() == 0 and portage_gid and portage_uid and \
+               hasattr(os, "setgroups"):
                kwargs.update(_userpriv_spawn_kwargs)
 
        spawn_func = spawn