diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
commit | d49b9bc2abb50b22ae3d6739d96423e9dadfeda8 (patch) | |
tree | 28c1bcbab960b28cc27f30e8ab0c04e30f11da2d /core/configmanager.lua | |
parent | 217e6d011c8d8ae2c44034fc9138925d77c3c10b (diff) | |
download | prosody-d49b9bc2abb50b22ae3d6739d96423e9dadfeda8.tar.gz prosody-d49b9bc2abb50b22ae3d6739d96423e9dadfeda8.zip |
Eliminate direct setfenv usage
Diffstat (limited to 'core/configmanager.lua')
-rw-r--r-- | core/configmanager.lua | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua index e2253171..8fea3be5 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -13,6 +13,7 @@ local format, math_max = string.format, math.max; local fire_event = prosody and prosody.events.fire_event or function () end; +local envload = require"util.envload".envload; local lfs = require "lfs"; local path_sep = package.config:sub(1,1); @@ -164,8 +165,8 @@ end -- Built-in Lua parser do - local loadstring, pcall, setmetatable = _G.loadstring, _G.pcall, _G.setmetatable; - local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring; + local pcall, setmetatable = _G.pcall, _G.setmetatable; + local rawget, tostring = _G.rawget, _G.tostring; parsers.lua = {}; function parsers.lua.load(data, config_file, config) local env; @@ -263,14 +264,12 @@ do return dofile(resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file)); end - local chunk, err = loadstring(data, "@"..config_file); + local chunk, err = envload(data, "@"..config_file, env); if not chunk then return nil, err; end - setfenv(chunk, env); - local ok, err = pcall(chunk); if not ok then |