diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-01-23 01:04:15 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-01-23 01:04:15 +0000 |
commit | 8f2788502ce4f0351ed411d41d8a5ea34904bfee (patch) | |
tree | b95030b1dc52fd27d156447b90ba1a3946660fc6 /prosody | |
parent | b14f0af41d94b5ee137d48e269ad29b45ee765d9 (diff) | |
download | prosody-8f2788502ce4f0351ed411d41d8a5ea34904bfee.tar.gz prosody-8f2788502ce4f0351ed411d41d8a5ea34904bfee.zip |
prosody: sandboxed require(): Point __index of _G at current env for modules that need to reference globals they already set
Diffstat (limited to 'prosody')
-rwxr-xr-x | prosody | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -150,10 +150,14 @@ function sandbox_require() local curr_env_mt = getmetatable(getfenv(2)); local _realG_mt = getmetatable(_realG); if curr_env_mt and curr_env_mt.__index and not curr_env_mt.__newindex and _realG_mt then - local old_newindex + local old_newindex, old_index; old_newindex, _realG_mt.__newindex = _realG_mt.__newindex, curr_env; + old_index, _realG_mt.__index = _realG_mt.__index, function (_G, k) + return rawget(curr_env, k); + end; local ret = _real_require(...); _realG_mt.__newindex = old_newindex; + _realG_mt.__index = old_index; return ret; end return _real_require(...); |