X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosodyctl;h=2c31c641384a340d0e95916c81d4851a51829418;hb=3f922cb7cc5fd112a5bef01e09805cb14fed020e;hp=cfc5ca77a979d74268a5483455984ec2da170462;hpb=9a3943500dedbdbcf7a58a057665704327d3d7d6;p=prosody.git diff --git a/prosodyctl b/prosodyctl index cfc5ca77..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,19 @@ 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 + os.exit(1); +end config = require "core.configmanager" @@ -92,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;