diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-08 20:58:32 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-08 20:58:32 +0100 |
commit | c8d90d2839fd5826b06ca5f2e5a70eae3ba04dc4 (patch) | |
tree | 1103fda4921c4da16b1da42a8f72e7a3a2d9e898 | |
parent | be74c632b7bc176b25ca1fc1e21448623dbac2e0 (diff) | |
download | supple-c8d90d2839fd5826b06ca5f2e5a70eae3ba04dc4.tar.gz |
SANDBOX: Ensure the first wrappered load is direct and the rest are wrappered
-rw-r--r-- | lib/supple/sandbox.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/supple/sandbox.lua b/lib/supple/sandbox.lua index db3532d..cc1bc6c 100644 --- a/lib/supple/sandbox.lua +++ b/lib/supple/sandbox.lua @@ -46,9 +46,13 @@ local function set_limits(ltab) return true end -local function _wrap(fn, src, globs) +local function _wrap(fn, src, globs, dont_wrap_globs) local fn_ret, msg + if not dont_wrap_globs then + globs = setmetatable({}, { __index = globs, __metatable = true }) + end + assert(fn, "No function/source provided?") assert(src, "No source name provided?") @@ -139,8 +143,11 @@ local function run() objects.set_name(("supple-sandbox[%d,%%d]"):format(luxio.getpid())) objects.set_proc_call(comms.call) + local dont_wrap_globs = true local function wrappered_load(str, name) - return _wrap(str, name, sandbox_globals) + local dwg = dont_wrap_globs + dont_wrap_globs = false + return _wrap(str, name, sandbox_globals, dwg) end -- Pretend we've "given" the host an object called 'supple:loadstring' |