Bug #218559 - Make portdbapi automatically add sandbox write access to
authorZac Medico <zmedico@gentoo.org>
Sun, 20 Apr 2008 20:53:33 +0000 (20:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 20 Apr 2008 20:53:33 +0000 (20:53 -0000)
self.depcachedir when appropriate. This makes the portageq blanket sandbox
exemption unnecessary. (trunk r9928)

svn path=/main/branches/2.1.2/; revision=9929

bin/portageq
pym/portage.py

index f0c2e19e2e78566ec2effe64b72a9a9d1c7b6442..d65abaa8f4dece923d129e244e31e93650d628e9 100755 (executable)
@@ -21,10 +21,6 @@ except KeyboardInterrupt:
 
 import os
 
-# This allows portageq to be exempt from sandbox,
-# for things like updating metadata cache.
-os.environ["SANDBOX_ON"] = "0"
-
 import types
 import portage_exception
 #-----------------------------------------------------------------------------
index 44f7e212ab1b04c03848010bcd73fae4593af84e..db1ba59fb7a0358624e450e964e704109d965e81 100644 (file)
@@ -7118,7 +7118,16 @@ class portdbapi(dbapi):
                #self.root=settings["PORTDIR"]
                self.porttree_root = os.path.realpath(porttree_root)
 
-               self.depcachedir = self.mysettings.depcachedir[:]
+               self.depcachedir = os.path.realpath(self.mysettings.depcachedir)
+
+               if os.environ.get("SANDBOX_ON") == "1":
+                       # Make api consumers exempt from sandbox violations
+                       # when doing metadata cache updates.
+                       sandbox_write = os.environ.get("SANDBOX_WRITE", "").split(":")
+                       if self.depcachedir not in sandbox_write:
+                               sandbox_write.append(self.depcachedir)
+                               os.environ["SANDBOX_WRITE"] = \
+                                       ":".join(filter(None, sandbox_write))
 
                self.tmpfs = self.mysettings["PORTAGE_TMPFS"]
                if self.tmpfs and not os.path.exists(self.tmpfs):