diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2010-03-02 18:02:00 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2010-03-02 18:02:00 -0500 |
commit | 2cb36ad98366b3cad72f2be6b7a55fb51b43677c (patch) | |
tree | ad7eb8bf8d9beedcaff1488595b12dce2cefe1b3 /setuptools/sandbox.py | |
parent | b9da3bd8418678235816f840f4cd86c68527097a (diff) | |
download | external_python_setuptools-2cb36ad98366b3cad72f2be6b7a55fb51b43677c.tar.gz external_python_setuptools-2cb36ad98366b3cad72f2be6b7a55fb51b43677c.tar.bz2 external_python_setuptools-2cb36ad98366b3cad72f2be6b7a55fb51b43677c.zip |
Worked out a fix for failing sandbox errors in Windows. Fixes #118.
--HG--
branch : distribute
extra : rebase_source : 69c8e59604f9d711cd29bb55e9edd3caab2b36a0
Diffstat (limited to 'setuptools/sandbox.py')
-rwxr-xr-x | setuptools/sandbox.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 502598ca..630d5792 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -154,6 +154,12 @@ class AbstractSandbox: _EXCEPTIONS = [os.devnull,] +try: + gen_py = os.path.dirname(__import__('win32com.gen_py', fromlist=['__name__']).__file__) + _EXCEPTIONS.append(gen_py) +except ImportError: + pass + class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" @@ -165,7 +171,7 @@ class DirectorySandbox(AbstractSandbox): def __init__(self, sandbox, exceptions=_EXCEPTIONS): self._sandbox = os.path.normcase(os.path.realpath(sandbox)) self._prefix = os.path.join(self._sandbox,'') - self._exceptions = exceptions + self._exceptions = [os.path.normcase(os.path.realpath(path)) for path in exceptions] AbstractSandbox.__init__(self) def _violation(self, operation, *args, **kw): @@ -190,12 +196,16 @@ class DirectorySandbox(AbstractSandbox): try: self._active = False realpath = os.path.normcase(os.path.realpath(path)) - if (realpath in self._exceptions or realpath == self._sandbox + if (self._exempted(realpath) or realpath == self._sandbox or realpath.startswith(self._prefix)): return True finally: self._active = active + def _exempted(self, filepath): + exception_matches = map(filepath.startswith, self._exceptions) + return any(exception_matches) + def _remap_input(self,operation,path,*args,**kw): """Called for path inputs""" if operation in self.write_ops and not self._ok(path): |