X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosodyctl;h=2c31c641384a340d0e95916c81d4851a51829418;hb=4556683c1e90e26917a9d9994e9c609357d320d7;hp=9630a9b8089280e5e7f3f7d79989b3b0b9f7f2a6;hpb=4b94fb11b40b58b070b7b822e13cd0698ab7c4fc;p=prosody.git diff --git a/prosodyctl b/prosodyctl index 9630a9b8..2c31c641 100755 --- a/prosodyctl +++ b/prosodyctl @@ -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,14 +44,14 @@ if CFG_DATADIR then end -- Global 'prosody' object -prosody = { +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 @@ -97,13 +109,14 @@ end local original_logging_config = config.get("*", "core", "log"); config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); +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 }; + require "core.loggingmanager" dependencies.log_warnings(); -local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; -require "util.datamanager".set_data_path(data_path); - -- Switch away from root and into the prosody user -- local switched_user, current_uid;