diff options
author | tarek <none@none> | 2009-12-04 11:20:36 +0100 |
---|---|---|
committer | tarek <none@none> | 2009-12-04 11:20:36 +0100 |
commit | f7279ede282b895e789b05ababb65ba4f6436160 (patch) | |
tree | 0714be9fb1fb446659d29843e2a5ccebfc9888b7 /setuptools/sandbox.py | |
parent | ca0105cf105e6d8a6c3e552c82650de93dbe13b1 (diff) | |
download | external_python_setuptools-f7279ede282b895e789b05ababb65ba4f6436160.tar.gz external_python_setuptools-f7279ede282b895e789b05ababb65ba4f6436160.tar.bz2 external_python_setuptools-f7279ede282b895e789b05ababb65ba4f6436160.zip |
Allowing 'os.devnull' in Sandbox, fixes #101
--HG--
branch : distribute
extra : rebase_source : d6f63794621874eb637139f353314256e02e02df
Diffstat (limited to 'setuptools/sandbox.py')
-rwxr-xr-x | setuptools/sandbox.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 7b487833..502598ca 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -152,6 +152,8 @@ class AbstractSandbox: ) +_EXCEPTIONS = [os.devnull,] + class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" @@ -160,9 +162,10 @@ class DirectorySandbox(AbstractSandbox): "utime", "lchown", "chroot", "mkfifo", "mknod", "tempnam", ]) - def __init__(self,sandbox): + 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 AbstractSandbox.__init__(self) def _violation(self, operation, *args, **kw): @@ -187,7 +190,8 @@ class DirectorySandbox(AbstractSandbox): try: self._active = False realpath = os.path.normcase(os.path.realpath(path)) - if realpath==self._sandbox or realpath.startswith(self._prefix): + if (realpath in self._exceptions or realpath == self._sandbox + or realpath.startswith(self._prefix)): return True finally: self._active = active |