nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
################################################################################
#
# __restricted_builtin_funcs__.py
#
# This contains functions used by __restricted_builtin__ to do certain
# potentially dangerous actions in a safe mode
#
################################################################################
import __builtin__

def r_import(name, globals = {}, locals = {}, fromlist = []):
    '''Restricted __import__ only allows importing of specific modules'''

    ok_modules = ("mud", "obj", "char", "room", "exit", "account", "mudsock",
                  "event", "action", "random", "traceback", "utils",
                  "__restricted_builtin__")
    if name not in ok_modules:
        raise ImportError, "Untrusted module, %s" % name
    return __builtin__.__import__(name, globals, locals, fromlist)

def r_open(file, mode = "r", buf = -1):
    if mode not in ('r', 'rb'):
        raise IOError, "can't open files for writing in restricted mode"
    return open(file, mode, buf)

def r_exec(code):
    """exec is disabled in restricted mode"""
    raise NotImplementedError,"execution of code is disabled"

def r_eval(code):
    """eval is disabled in restricted mode"""
    raise NotImplementedError,"evaluating code is disabled"

def r_execfile(file):
    """executing files is disabled in restricted mode"""
    raise NotImplementedError,"executing files is disabled"

def r_reload(module):
    """reloading modules is disabled in restricted mode"""
    raise NotImplementedError, "reloading modules is disabled"

def r_unload(module):
    """unloading modules is disabled in restricted mode"""
    raise NotImplementedError, "unloading modules is disabled"