Commits

Hanno Schlichting committed ac42296

Fixed a SandboxViolation for mkdir that could occur in certain cases. This closes http://bitbucket.org/tarek/distribute/issue/13. This is a backport of a patch made by PJE on setuptools trunk.

  • Participants
  • Parent commits 98cdb73
  • Branches setuptools-0.6

Comments (0)

Files changed (2)

 pkg_resources
 -------------
 
+* Fixed a SandboxViolation for mkdir that could occur in certain cases.
+  This closes http://bitbucket.org/tarek/distribute/issue/13.
+
 * Allow to find_on_path on systems with tight permissions to fail gracefully.
   This closes http://bitbucket.org/tarek/distribute/issue/9.
 
 except NameError:
     from sets import ImmutableSet as frozenset
 
-from os import utime, rename, unlink    # capture these to bypass sandboxing
+# capture these to bypass sandboxing
+from os import utime, rename, unlink, mkdir
 from os import open as os_open
-
-
-
-
-
-
-
-
-
+from os.path import isdir, split
+
+def _bypass_ensure_directory(name, mode=0777):
+    # Sandbox-bypassing version of ensure_directory()
+    dirname, filename = split(name)
+    if dirname and filename and not isdir(dirname):
+        _bypass_ensure_directory(dirname)
+        mkdir(dirname, mode)
 
 
 
         extract_path = self.extraction_path or get_default_cache()
         target_path = os.path.join(extract_path, archive_name+'-tmp', *names)
         try:
-            ensure_directory(target_path)
+            _bypass_ensure_directory(target_path)
         except:
             self.extraction_error()