rexec
 

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
           no doc string
                                                                                                                                                                                                                     


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


 class FileWrapper(FileBase)
           no doc string
                                                                                                                                                                                                                     
__init__(self, f)
# XXX This is just like a Bastion -- should use that!
close(self)
no doc string


 class RExec(ihooks._Verbose)
           Restricted Execution environment.
 
                                                                                                                                                                                                                     
__init__(self, hooks=None, verbose=0)
no doc string
add_module(self, mname)
# Add a module -- return an existing module or create one
copy_except(self, src, exceptions)
# The copy_* methods copy existing modules with some changes
copy_none(self, src)
no doc string
copy_only(self, src, names)
no doc string
is_builtin(self, mname)
# Helpers for RHooks
load_dynamic(self, name, filename, file)
no doc string
make_builtin(self)
# The make_* methods create specific built-in modules
make_delegate_files(self)
# The s_* methods are similar but also swap std{in,out,err}
make_initial_modules(self)
no doc string
make_main(self)
no doc string
make_osname(self)
no doc string
make_sys(self)
no doc string
r_eval(self, code)
no doc string
r_exc_info(self)
# Restricted version of sys.exc_info()
r_exec(self, code)
# The r* methods are public interfaces
r_execfile(self, file)
no doc string
r_import(self, mname, globals={}, locals={}, fromlist=[])
no doc string
r_open(self, file, mode='r', buf=-1)
# Restricted open(...)
r_reload(self, m)
no doc string
r_unload(self, m)
no doc string
reset_files(self)
no doc string
restore_files(self)
no doc string
s_apply(self, func, args=(), kw=None)
no doc string
s_eval(self, *args)
no doc string
s_exec(self, *args)
no doc string
s_execfile(self, *args)
no doc string
s_import(self, *args)
no doc string
s_reload(self, *args)
no doc string
s_unload(self, *args)
no doc string
save_files(self)
no doc string
set_files(self)
no doc string
set_trusted_path(self)
no doc string


 class RHooks(ihooks.Hooks)
           no doc string
                                                                                                                                                                                                                     
__init__(self, *args)
no doc string
add_module(self, name)
no doc string
default_path(self)
no doc string
init_builtin(self, name)
no doc string
init_frozen(self, name)
no doc string
is_builtin(self, name)
no doc string
load_compiled(self, *args)
no doc string
load_dynamic(self, name, filename, file)
no doc string
load_package(self, *args)
no doc string
load_source(self, *args)
no doc string
modules_dict(self)
no doc string
set_rexec(self, rexec)
no doc string


 Functions
                                                                                                                                                                                                                               
test()
no doc string