util.signal: Make kill() available on Solaris; really fixes #136.
[prosody.git] / prosody
diff --git a/prosody b/prosody
index 7f69e085bdcb8408536b9961fdab455e5f92b3a3..90ac3adb47817b0ad90c5930e0a0480246e328c2 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -16,6 +16,7 @@ CFG_DATADIR=os.getenv("PROSODY_DATADIR");
 
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 
+-- Tell Lua where to find our libraries
 if CFG_SOURCEDIR then
        package.path = CFG_SOURCEDIR.."/?.lua;"..package.path;
        package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath;
@@ -24,6 +25,7 @@ end
 package.path = package.path..";"..(CFG_SOURCEDIR or ".").."/fallbacks/?.lua";
 package.cpath = package.cpath..";"..(CFG_SOURCEDIR or ".").."/fallbacks/?.so";
 
+-- Substitute ~ with path to home directory in data path
 if CFG_DATADIR then
        if os.getenv("HOME") then
                CFG_DATADIR = CFG_DATADIR:gsub("^~", os.getenv("HOME"));
@@ -31,9 +33,10 @@ if CFG_DATADIR then
 end
 
 -- Required to be able to find packages installed with luarocks
-pcall(require, "luarocks.require")
+pcall(require, "luarocks.require");
 
--- Replace require with one that doesn't pollute _G
+-- Replace require() with one that doesn't pollute _G, required
+-- for neat sandboxing of modules
 do
        local _realG = _G;
        local _real_require = require;
@@ -52,9 +55,14 @@ do
        end
 end
 
-
+-- Load the config-parsing module
 config = require "core.configmanager"
 
+-- -- -- --
+-- Define the functions we call during startup, the 
+-- actual startup happens right at the end, where these
+-- functions get called
+
 function read_config()
        -- TODO: Check for other formats when we add support for them
        -- Use lfs? Make a new conf/ dir?
@@ -177,8 +185,9 @@ function init_global_state()
        -- Load SSL settings from config, and create a ctx table
        local global_ssl_ctx = rawget(_G, "ssl") and config.get("*", "core", "ssl");
        if global_ssl_ctx then
-               local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
+               local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none", options = "no_sslv2"; };
                setmetatable(global_ssl_ctx, { __index = default_ssl_ctx });
+               prosody.global_ssl_ctx = global_ssl_ctx;
        end
 
        local cl = require "net.connlisteners";
@@ -270,6 +279,7 @@ function init_data_store()
 end
 
 function prepare_to_start()
+       log("debug", "Prosody is using the %s backend for connection handling", server.get_backend());
        -- Signal to modules that we are ready to start
        eventmanager.fire_event("server-starting");
        prosody.events.fire_event("server-starting");
@@ -302,7 +312,7 @@ end
 function loop()
        -- Error handler for errors that make it this far
        local function catch_uncaught_error(err)
-               if type(err) == "string" and err:match("%d*: interrupted!$") then
+               if type(err) == "string" and err:match("interrupted!$") then
                        return "quitting";
                end
                
@@ -362,6 +372,7 @@ function cleanup()
        server.setquitting(true);
 end
 
+-- Are you ready? :)
 read_config();
 load_libraries();
 init_global_state();