284 end |
284 end |
285 |
285 |
286 function init_global_protection() |
286 function init_global_protection() |
287 -- Catch global accesses |
287 -- Catch global accesses |
288 local locked_globals_mt = { |
288 local locked_globals_mt = { |
289 __index = function (t, k) log("warn", "%s", debug.traceback("Attempt to read a non-existent global '"..k.."'", 2)); end; |
289 __index = function (t, k) log("warn", "%s", debug.traceback("Attempt to read a non-existent global '"..tostring(k).."'", 2)); end; |
290 __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end; |
290 __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end; |
291 }; |
291 }; |
292 |
292 |
293 function prosody.unlock_globals() |
293 function prosody.unlock_globals() |
294 setmetatable(_G, nil); |
294 setmetatable(_G, nil); |