rexec
index
/usr/lib/python2.1/rexec.py

Restricted execution facilities.
 
The class RExec exports methods r_exec(), r_eval(), r_execfile(), and
r_import(), which correspond roughly to the built-in operations
exec, eval(), execfile() and import, but executing the code in an
environment that only exposes those built-in operations that are
deemed safe.  To this end, a modest collection of 'fake' modules is
created which mimics the standard modules by the same names.  It is a
policy decision which built-in modules and operations are made
available; this module provides a reasonable default, but derived
classes can change the policies e.g. by overriding or extending class
variables like ok_builtin_modules or methods like make_sys().
 
XXX To do:
- r_open should allow writing tmp dir
- r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?)

 
Modules
            
__builtin__
ihooks
os
sys

 
Classes
            
FileBase
FileDelegate
FileWrapper
ihooks.Hooks(ihooks._Verbose)
RHooks
ihooks._Verbose
RExec

 
class FileBase
       
  

 
class FileDelegate(FileBase)
       
  
__init__(self, mod, name)
close(self, *args)
fileno(self, *args)
flush(self, *args)
isatty(self, *args)
read(self, *args)
readline(self, *args)
readlines(self, *args)
seek(self, *args)
tell(self, *args)
write(self, *args)
writelines(self, *args)

 
class FileWrapper(FileBase)
       
  
__init__(self, f)
close(self)

 
class RExec(ihooks._Verbose)
      Restricted Execution environment.
 
  
__init__(self, hooks=None, verbose=0)
add_module(self, mname)
copy_except(self, src, exceptions)
copy_none(self, src)
copy_only(self, src, names)
get_verbose(self) from ihooks._Verbose
is_builtin(self, mname)
load_dynamic(self, name, filename, file)
make_builtin(self)
make_delegate_files(self)
make_initial_modules(self)
make_main(self)
make_osname(self)
make_re(self)
make_sys(self)
message(self, format, *args) from ihooks._Verbose
note(self, *args) from ihooks._Verbose
r_eval(self, code)
r_exc_info(self)
r_exec(self, code)
r_execfile(self, file)
r_import(self, mname, globals={}, locals={}, fromlist=[])
r_open(self, file, mode='r', buf=-1)
r_reload(self, m)
r_unload(self, m)
reset_files(self)
restore_files(self)
s_apply(self, func, args=(), kw=None)
s_eval(self, *args)
s_exec(self, *args)
s_execfile(self, *args)
s_import(self, *args)
s_reload(self, *args)
s_unload(self, *args)
save_files(self)
set_files(self)
set_trusted_path(self)
set_verbose(self, verbose) from ihooks._Verbose

 
class RHooks(ihooks.Hooks)
       
  
__init__(self, *args)
add_module(self, name)
default_path(self)
get_frozen_object(self, name) from ihooks.Hooks
get_suffixes(self) from ihooks.Hooks
get_verbose(self) from ihooks._Verbose
init_builtin(self, name)
init_frozen(self, name)
is_builtin(self, name)
is_frozen(self, name) from ihooks.Hooks
listdir(self, x) from ihooks.Hooks
load_compiled(self, *args)
load_dynamic(self, name, filename, file)
load_package(self, *args)
load_source(self, *args)
message(self, format, *args) from ihooks._Verbose
modules_dict(self)
new_module(self, name) from ihooks.Hooks
note(self, *args) from ihooks._Verbose
openfile(self, *x) from ihooks.Hooks
path_exists(self, x) from ihooks.Hooks
path_isabs(self, x) from ihooks.Hooks
path_isdir(self, x) from ihooks.Hooks
path_isfile(self, x) from ihooks.Hooks
path_islink(self, x) from ihooks.Hooks
path_join(self, x, y) from ihooks.Hooks
path_split(self, x) from ihooks.Hooks
set_rexec(self, rexec)
set_verbose(self, verbose) from ihooks._Verbose

 
Functions
            
test()

 
Data
             TEMPLATE = '\ndef %s(self, *args):\n return apply(getattr(self.mod, self.name).%s, args)\n'
__all__ = ['RExec']
__file__ = '/usr/lib/python2.1/rexec.pyc'
__name__ = 'rexec'