183 end |
183 end |
184 |
184 |
185 -- Load SSL settings from config, and create a ctx table |
185 -- Load SSL settings from config, and create a ctx table |
186 local global_ssl_ctx = rawget(_G, "ssl") and config.get("*", "core", "ssl"); |
186 local global_ssl_ctx = rawget(_G, "ssl") and config.get("*", "core", "ssl"); |
187 if global_ssl_ctx then |
187 if global_ssl_ctx then |
188 local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none", options = "no_sslv2"; }; |
188 local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none", options = "no_sslv2" }; |
189 setmetatable(global_ssl_ctx, { __index = default_ssl_ctx }); |
189 setmetatable(global_ssl_ctx, { __index = default_ssl_ctx }); |
190 prosody.global_ssl_ctx = global_ssl_ctx; |
190 prosody.global_ssl_ctx = global_ssl_ctx; |
191 end |
191 end |
192 |
192 |
193 local cl = require "net.connlisteners"; |
193 local cl = require "net.connlisteners"; |
292 |
292 |
293 prosody.start_time = os.time(); |
293 prosody.start_time = os.time(); |
294 end |
294 end |
295 |
295 |
296 function init_global_protection() |
296 function init_global_protection() |
297 -- Catch global accesses -- |
297 -- Catch global accesses |
298 local locked_globals_mt = { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end } |
298 local locked_globals_mt = { |
|
299 __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end; |
|
300 __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end; |
|
301 }; |
299 |
302 |
300 function prosody.unlock_globals() |
303 function prosody.unlock_globals() |
301 setmetatable(_G, nil); |
304 setmetatable(_G, nil); |
302 end |
305 end |
303 |
306 |