~logan/ubuntu/raring/distribute/0.6.34

« back to all changes in this revision

Viewing changes to setuptools/sandbox.py

Tags: upstream-0.6.10
ImportĀ upstreamĀ versionĀ 0.6.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
        )
153
153
 
154
154
 
 
155
_EXCEPTIONS = [os.devnull,]
 
156
 
155
157
class DirectorySandbox(AbstractSandbox):
156
158
    """Restrict operations to a single subdirectory - pseudo-chroot"""
157
159
 
160
162
        "utime", "lchown", "chroot", "mkfifo", "mknod", "tempnam",
161
163
    ])
162
164
 
163
 
    def __init__(self,sandbox):
 
165
    def __init__(self, sandbox, exceptions=_EXCEPTIONS):
164
166
        self._sandbox = os.path.normcase(os.path.realpath(sandbox))
165
167
        self._prefix = os.path.join(self._sandbox,'')
 
168
        self._exceptions = exceptions
166
169
        AbstractSandbox.__init__(self)
167
170
 
168
171
    def _violation(self, operation, *args, **kw):
187
190
        try:
188
191
            self._active = False
189
192
            realpath = os.path.normcase(os.path.realpath(path))
190
 
            if realpath==self._sandbox or realpath.startswith(self._prefix):
 
193
            if (realpath in self._exceptions or realpath == self._sandbox
 
194
                or realpath.startswith(self._prefix)):
191
195
                return True
192
196
        finally:
193
197
            self._active = active