aboutsummaryrefslogtreecommitdiffstats
path: root/prosody
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-10-13 21:02:04 +0200
committerKim Alvefur <zash@zash.se>2014-10-13 21:02:04 +0200
commitb72a485cdd1973461d1f49b66625e7f9ae0cc870 (patch)
treeab386a9e59163f1cc2cfa87acd44184a1f8912b3 /prosody
parentcff85755634ad9c0ae431245e835625f5c57bb82 (diff)
downloadprosody-b72a485cdd1973461d1f49b66625e7f9ae0cc870.tar.gz
prosody-b72a485cdd1973461d1f49b66625e7f9ae0cc870.zip
prosody: Make getfenv() replacement for require() sandboxing local to avoid polluting the globals table
Diffstat (limited to 'prosody')
-rwxr-xr-xprosody10
1 files changed, 4 insertions, 6 deletions
diff --git a/prosody b/prosody
index aab803c5..e8f81d5d 100755
--- a/prosody
+++ b/prosody
@@ -151,13 +151,11 @@ function sandbox_require()
-- for neat sandboxing of modules
local _realG = _G;
local _real_require = require;
- if not getfenv then
+ local getfenv = getfenv or function (f)
-- FIXME: This is a hack to replace getfenv() in Lua 5.2
- function getfenv(f)
- local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1);
- if name == "_ENV" then
- return env;
- end
+ local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1);
+ if name == "_ENV" then
+ return env;
end
end
function require(...)