net.server_select, net.server_event: Silence 'error during ssl handshake' for wantrea...
[prosody.git] / prosodyctl
index c7ef93edb385d0e7401bc5258437b19719044bdb..2c31c641384a340d0e95916c81d4851a51829418 100755 (executable)
@@ -18,10 +18,22 @@ CFG_DATADIR=os.getenv("PROSODY_DATADIR");
 
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 
+local function is_relative(path)
+       local path_sep = package.config:sub(1,1);
+        return ((path_sep == "/" and path:sub(1,1) ~= "/")
+       or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\")))
+end
+
 -- 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;
+       local function filter_relative_paths(path)
+               if is_relative(path) then return ""; end
+       end
+       local function sanitise_paths(paths)
+               return (paths:gsub("[^;]+;?", filter_relative_paths):gsub(";;+", ";"));
+       end
+       package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path);
+       package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath);
 end
 
 -- Substitute ~ with path to home directory in data path
@@ -32,12 +44,19 @@ if CFG_DATADIR then
 end
 
 -- Global 'prosody' object
-prosody = {
-       hosts = {},
-       events = require "util.events".new(),
-       platform = "posix"
+local prosody = {
+       hosts = {};
+       events = require "util.events".new();
+       platform = "posix";
+       lock_globals = function () end;
+       unlock_globals = function () end;
 };
-local prosody = prosody;
+_G.prosody = prosody;
+
+local dependencies = require "util.dependencies";
+if not dependencies.check_dependencies() then
+       os.exit(1);
+end
 
 config = require "core.configmanager"
 
@@ -90,14 +109,13 @@ end
 local original_logging_config = config.get("*", "core", "log");
 config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } });
 
-require "core.loggingmanager"
+local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
+prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, 
+                 plugins = CFG_PLUGINDIR, data = data_path };
 
-if not require "util.dependencies".check_dependencies() then
-       os.exit(1);
-end
+require "core.loggingmanager"
 
-local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
-require "util.datamanager".set_data_path(data_path);
+dependencies.log_warnings();
 
 -- Switch away from root and into the prosody user --
 local switched_user, current_uid;
@@ -329,7 +347,7 @@ function commands.adduser(arg)
        
        if ok then return 0; end
        
-       show_message(error_messages[msg])
+       show_message(msg)
        return 1;
 end