/
usr
/
lib
/
python2.6
/
site-packages
/
setuptools
/
/usr/lib/python2.6/site-packages/setuptools
mkdir
upload
Name
Size
Mode
Actions
command/
-
0755
rm
extern/
-
0755
rm
archive_util.py
5927
0644
edit
dl
rm
archive_util.pyc
5767
0644
edit
dl
rm
archive_util.pyo
5767
0644
edit
dl
rm
cli-32.exe
65536
0644
edit
dl
rm
cli-64.exe
74752
0644
edit
dl
rm
cli-arm-32.exe
69120
0644
edit
dl
rm
cli.exe
65536
0644
edit
dl
rm
depends.py
6209
0644
edit
dl
rm
depends.pyc
6815
0644
edit
dl
rm
depends.pyo
6815
0644
edit
dl
rm
dist.py
30266
0644
edit
dl
rm
dist.pyc
30544
0644
edit
dl
rm
dist.pyo
30482
0644
edit
dl
rm
extension.py
1100
0644
edit
dl
rm
extension.pyc
1612
0644
edit
dl
rm
extension.pyo
1612
0644
edit
dl
rm
gui-32.exe
65536
0644
edit
dl
rm
gui-64.exe
75264
0644
edit
dl
rm
gui-arm-32.exe
69120
0644
edit
dl
rm
gui.exe
65536
0644
edit
dl
rm
launch.py
793
0644
edit
dl
rm
launch.pyc
1008
0644
edit
dl
rm
lib2to3_ex.py
1998
0644
edit
dl
rm
lib2to3_ex.pyc
3026
0644
edit
dl
rm
msvc9_support.py
2185
0644
edit
dl
rm
msvc9_support.pyc
2122
0644
edit
dl
rm
package_index.py
29140
0644
edit
dl
rm
package_index.pyc
27883
0644
edit
dl
rm
package_index.pyo
27883
0644
edit
dl
rm
py26compat.py
481
0644
edit
dl
rm
py26compat.pyc
987
0644
edit
dl
rm
py27compat.py
306
0644
edit
dl
rm
py27compat.pyc
745
0644
edit
dl
rm
py31compat.py
1636
0644
edit
dl
rm
py31compat.pyc
2403
0644
edit
dl
rm
sandbox.py
8186
0644
edit
dl
rm
sandbox.pyc
10929
0644
edit
dl
rm
sandbox.pyo
10929
0644
edit
dl
rm
script (dev).tmpl
201
0644
edit
dl
rm
script.tmpl
138
0644
edit
dl
rm
site-patch.py
2389
0644
edit
dl
rm
site-patch.pyc
1785
0644
edit
dl
rm
ssl_support.py
8119
0644
edit
dl
rm
ssl_support.pyc
7937
0644
edit
dl
rm
unicode_utils.py
995
0644
edit
dl
rm
unicode_utils.pyc
1485
0644
edit
dl
rm
utils.py
293
0644
edit
dl
rm
utils.pyc
545
0644
edit
dl
rm
version.py
132
0644
edit
dl
rm
version.pyc
324
0644
edit
dl
rm
windows_support.py
714
0644
edit
dl
rm
windows_support.pyc
1278
0644
edit
dl
rm
__init__.py
3434
0644
edit
dl
rm
__init__.pyc
3876
0644
edit
dl
rm
__init__.pyo
3876
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/setuptools/sandbox.py
(8186B)
import os, sys, __builtin__, tempfile, operator _os = sys.modules[os.name] try: _file = file except NameError: _file = None _open = open from distutils.errors import DistutilsError __all__ = [ "AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup", ] def run_setup(setup_script, args): """Run a distutils setup script, sandboxed in its directory""" old_dir = os.getcwd() save_argv = sys.argv[:] save_path = sys.path[:] setup_dir = os.path.abspath(os.path.dirname(setup_script)) temp_dir = os.path.join(setup_dir,'temp') if not os.path.isdir(temp_dir): os.makedirs(temp_dir) save_tmp = tempfile.tempdir save_modules = sys.modules.copy() try: tempfile.tempdir = temp_dir os.chdir(setup_dir) try: sys.argv[:] = [setup_script]+list(args) sys.path.insert(0, setup_dir) DirectorySandbox(setup_dir).run( lambda: execfile( "setup.py", {'__file__':setup_script, '__name__':'__main__'} ) ) except SystemExit, v: if v.args and v.args[0]: raise # Normal exit, just return finally: sys.modules.update(save_modules) for key in list(sys.modules): if key not in save_modules: del sys.modules[key] os.chdir(old_dir) sys.path[:] = save_path sys.argv[:] = save_argv tempfile.tempdir = save_tmp class AbstractSandbox: """Wrap 'os' module and 'open()' builtin for virtualizing setup scripts""" _active = False def __init__(self): self._attrs = [ name for name in dir(_os) if not name.startswith('_') and hasattr(self,name) ] def _copy(self, source): for name in self._attrs: setattr(os, name, getattr(source,name)) def run(self, func): """Run 'func' under os sandboxing""" try: self._copy(self) if _file: __builtin__.file = self._file __builtin__.open = self._open self._active = True return func() finally: self._active = False if _file: __builtin__.file = _file __builtin__.open = _open self._copy(_os) def _mk_dual_path_wrapper(name): original = getattr(_os,name) def wrap(self,src,dst,*args,**kw): if self._active: src,dst = self._remap_pair(name,src,dst,*args,**kw) return original(src,dst,*args,**kw) return wrap for name in ["rename", "link", "symlink"]: if hasattr(_os,name): locals()[name] = _mk_dual_path_wrapper(name) def _mk_single_path_wrapper(name, original=None): original = original or getattr(_os,name) def wrap(self,path,*args,**kw): if self._active: path = self._remap_input(name,path,*args,**kw) return original(path,*args,**kw) return wrap if _file: _file = _mk_single_path_wrapper('file', _file) _open = _mk_single_path_wrapper('open', _open) for name in [ "stat", "listdir", "chdir", "open", "chmod", "chown", "mkdir", "remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat", "startfile", "mkfifo", "mknod", "pathconf", "access" ]: if hasattr(_os,name): locals()[name] = _mk_single_path_wrapper(name) def _mk_single_with_return(name): original = getattr(_os,name) def wrap(self,path,*args,**kw): if self._active: path = self._remap_input(name,path,*args,**kw) return self._remap_output(name, original(path,*args,**kw)) return original(path,*args,**kw) return wrap for name in ['readlink', 'tempnam']: if hasattr(_os,name): locals()[name] = _mk_single_with_return(name) def _mk_query(name): original = getattr(_os,name) def wrap(self,*args,**kw): retval = original(*args,**kw) if self._active: return self._remap_output(name, retval) return retval return wrap for name in ['getcwd', 'tmpnam']: if hasattr(_os,name): locals()[name] = _mk_query(name) def _validate_path(self,path): """Called to remap or validate any path, whether input or output""" return path def _remap_input(self,operation,path,*args,**kw): """Called for path inputs""" return self._validate_path(path) def _remap_output(self,operation,path): """Called for path outputs""" return self._validate_path(path) def _remap_pair(self,operation,src,dst,*args,**kw): """Called for path pairs like rename, link, and symlink operations""" return ( self._remap_input(operation+'-from',src,*args,**kw), self._remap_input(operation+'-to',dst,*args,**kw) ) _EXCEPTIONS = [os.devnull,] class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" write_ops = dict.fromkeys([ "open", "chmod", "chown", "mkdir", "remove", "unlink", "rmdir", "utime", "lchown", "chroot", "mkfifo", "mknod", "tempnam", ]) 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): raise SandboxViolation(operation, args, kw) if _file: def _file(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("file", path, mode, *args, **kw) return _file(path,mode,*args,**kw) def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path,mode,*args,**kw) def tmpnam(self): self._violation("tmpnam") def _ok(self,path): active = self._active try: self._active = False realpath = os.path.normcase(os.path.realpath(path)) if (realpath in self._exceptions or realpath == self._sandbox or realpath.startswith(self._prefix)): return True finally: self._active = active def _remap_input(self,operation,path,*args,**kw): """Called for path inputs""" if operation in self.write_ops and not self._ok(path): self._violation(operation, os.path.realpath(path), *args, **kw) return path def _remap_pair(self,operation,src,dst,*args,**kw): """Called for path pairs like rename, link, and symlink operations""" if not self._ok(src) or not self._ok(dst): self._violation(operation, src, dst, *args, **kw) return (src,dst) def open(self, file, flags, mode=0777): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode) return _os.open(file,flags,mode) WRITE_FLAGS = reduce( operator.or_, [getattr(_os, a, 0) for a in "O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARY".split()] ) class SandboxViolation(DistutilsError): """A setup script attempted to modify the filesystem outside the sandbox""" def __str__(self): return """SandboxViolation: %s%r %s The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. This package cannot be safely installed by EasyInstall, and may not support alternate installation locations even if you run its setup script by hand. Please inform the package's author and the EasyInstall maintainers to find out if a fix or workaround is available.""" % self.args #
Save
cmd:
run