webmcp

changeset 231:2eda136b0394

Replace global environment as soon as possible in mcp.lua
author jbe
date Sat Feb 28 23:04:43 2015 +0100 (2015-02-28)
parents d3273921ce75
children 82cc171e8510
files framework/bin/mcp.lua
line diff
     1.1 --- a/framework/bin/mcp.lua	Fri Feb 27 22:56:58 2015 +0100
     1.2 +++ b/framework/bin/mcp.lua	Sat Feb 28 23:04:43 2015 +0100
     1.3 @@ -2,6 +2,16 @@
     1.4  
     1.5  WEBMCP_VERSION = "2.0.0_devel"
     1.6  
     1.7 +-- allow control of global environment
     1.8 +local _G = _G
     1.9 +local global_metatable = {
    1.10 +  __index = _G,
    1.11 +  __newindex = function(self, key, value)
    1.12 +    _G[key] = value
    1.13 +  end
    1.14 +}
    1.15 +_ENV = setmetatable({}, global_metatable)
    1.16 +
    1.17  -- check if interactive mode
    1.18  if listen then  -- defined by moonbridge
    1.19    WEBMCP_MODE = "listen"
    1.20 @@ -172,12 +182,9 @@
    1.21  end
    1.22  
    1.23  -- prohibit (unintended) definition of new global variables
    1.24 -_ENV = setmetatable({}, {
    1.25 -  __index = _G,
    1.26 -  __newindex = function()
    1.27 -    error("Setting of global variable prohibited")
    1.28 -  end
    1.29 -})
    1.30 +function global_metatable.__newindex()
    1.31 +  error("Setting of global variable prohibited")
    1.32 +end
    1.33  
    1.34  -- execute configurations and pre-fork initializers
    1.35  for i, config_name in ipairs(WEBMCP_CONFIG_NAMES) do

Impressum / About Us