diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-04-22 21:32:23 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-04-22 21:32:23 +0100 |
commit | ca9a9eb85ebb918983c845813c22c0e6d2464aa6 (patch) | |
tree | 680b1c655c3a4b97e14f5dd996a303ff28e122cd | |
parent | a54da72215f3216f3ae28846604bba20e483b831 (diff) | |
download | prosody-ca9a9eb85ebb918983c845813c22c0e6d2464aa6.tar.gz prosody-ca9a9eb85ebb918983c845813c22c0e6d2464aa6.zip |
mod_*: Fix a load of global accesses
-rw-r--r-- | plugins/mod_bosh.lua | 1 | ||||
-rw-r--r-- | plugins/mod_component.lua | 11 | ||||
-rw-r--r-- | plugins/mod_console.lua | 1 | ||||
-rw-r--r-- | plugins/mod_dialback.lua | 2 | ||||
-rw-r--r-- | plugins/mod_legacyauth.lua | 3 | ||||
-rw-r--r-- | plugins/mod_muc.lua | 2 | ||||
-rw-r--r-- | plugins/mod_posix.lua | 24 | ||||
-rw-r--r-- | plugins/mod_register.lua | 4 | ||||
-rw-r--r-- | plugins/mod_saslauth.lua | 6 | ||||
-rw-r--r-- | plugins/mod_vcard.lua | 6 |
10 files changed, 38 insertions, 22 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index 58c2b5aa..6f61bb8d 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -1,6 +1,7 @@ module.host = "*" -- Global module +local hosts = _G.hosts; local lxp = require "lxp"; local init_xmlhandlers = require "core.xmlhandlers" local server = require "net.server"; diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index bbd49c5e..e5ea47a2 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -10,14 +10,19 @@ if module:get_host_type() ~= "component" then error("Don't load mod_component manually, it should be for a component, please see http://prosody.im/doc/components", 0); end +local hosts = _G.hosts; + local t_concat = table.concat; +local lxp = require "lxp"; +local logger = require "util.logger"; +local config = require "core.configmanager"; local connlisteners = require "net.connlisteners"; local cm_register_component = require "core.componentmanager".register_component; local cm_deregister_component = require "core.componentmanager".deregister_component; local uuid_gen = require "util.uuid".generate; local sha1 = require "util.hashes".sha1; -local st = stanza; +local st = require "util.stanza"; local init_xmlhandlers = require "core.xmlhandlers"; local sessions = {}; @@ -211,8 +216,8 @@ connlisteners.register('component', component_listener); module:add_event_hook("server-started", function () - if net_activate_ports then - net_activate_ports("component", "component", {5437}, "tcp"); + if _G.net_activate_ports then + _G.net_activate_ports("component", "component", {5437}, "tcp"); else error("No net_activate_ports: Using an incompatible version of Prosody?"); end diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index bd0095d7..502e0d06 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -8,6 +8,7 @@ module.host = "*"; +local hosts = _G.hosts; local connlisteners_register = require "net.connlisteners".register; local console_listener = { default_port = 5582; default_mode = "*l"; }; diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 042e2087..fe65d394 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -7,7 +7,7 @@ -- - +local hosts = _G.hosts; local send_s2s = require "core.s2smanager".send_to_host; local s2s_make_authenticated = require "core.s2smanager".make_authenticated; local s2s_verify_dialback = require "core.s2smanager".verify_dialback; diff --git a/plugins/mod_legacyauth.lua b/plugins/mod_legacyauth.lua index 648aa01a..fa14f5e7 100644 --- a/plugins/mod_legacyauth.lua +++ b/plugins/mod_legacyauth.lua @@ -11,6 +11,9 @@ local st = require "util.stanza"; local t_concat = table.concat; +local sessionmanager = require "core.sessionmanager"; +local usermanager = require "core.usermanager"; + module:add_feature("jabber:iq:auth"); module:add_event_hook("stream-features", function (session, features) if not session.username then features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up(); end diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua index 8fbe1e91..ca8e9cb7 100644 --- a/plugins/mod_muc.lua +++ b/plugins/mod_muc.lua @@ -6,6 +6,8 @@ -- COPYING file in the source package for more information. -- +local datamanager = require "util.datamanager"; +local datetime = require "util.datetime"; local register_component = require "core.componentmanager".register_component; local deregister_component = require "core.componentmanager".deregister_component; diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index f8fda7cd..87113aac 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -6,7 +6,7 @@ if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown versi local signal = select(2, pcall(require, "util.signal")); if type(signal) == "string" then - log("warn", "Couldn't load signal library, won't respond to SIGTERM"); + module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); end local config_get = require "core.configmanager".get; @@ -18,7 +18,7 @@ local pidfile_written; local function remove_pidfile() if pidfile_written then - os.remove(pidfile); + os.remove(pidfile_written); pidfile_written = nil; end end @@ -27,11 +27,11 @@ local function write_pidfile() if pidfile_written then remove_pidfile(); end - local pidfile = config.get("*", "core", "pidfile"); + local pidfile = config_get("*", "core", "pidfile"); if pidfile then local pf, err = io.open(pidfile, "w+"); if not pf then - log("error", "Couldn't write pidfile; %s", err); + module:log("error", "Couldn't write pidfile; %s", err); else pf:write(tostring(pposix.getpid())); pf:close(); @@ -62,11 +62,11 @@ if not config_get("*", "core", "no_daemonize") then local function daemonize_server() local ok, ret = pposix.daemonize(); if not ok then - log("error", "Failed to daemonize: %s", ret); + module:log("error", "Failed to daemonize: %s", ret); elseif ret and ret > 0 then os.exit(0); else - log("info", "Successfully daemonized to PID %d", pposix.getpid()); + module:log("info", "Successfully daemonized to PID %d", pposix.getpid()); write_pidfile(); end end @@ -81,13 +81,13 @@ module:add_event_hook("server-stopped", remove_pidfile); -- Set signal handler if signal.signal then signal.signal("SIGTERM", function () - log("warn", "Received SIGTERM..."); - unlock_globals(); - if prosody_shutdown then - prosody_shutdown("Received SIGTERM"); + module:log("warn", "Received SIGTERM..."); + _G.unlock_globals(); + if _G.prosody_shutdown then + _G.prosody_shutdown("Received SIGTERM"); else - log("warn", "...no prosody_shutdown(), ignoring."); + module:log("warn", "...no prosody_shutdown(), ignoring."); end - lock_globals(); + _G.lock_globals(); end); end diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index c04eca0a..14c00767 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -7,8 +7,10 @@ -- - +local hosts = _G.hosts; local st = require "util.stanza"; +local config = require "core.configmanager"; +local datamanager = require "util.datamanager"; local usermanager_user_exists = require "core.usermanager".user_exists; local usermanager_create_user = require "core.usermanager".create_user; local datamanager_store = require "util.datamanager".store; diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 31d62325..f7b30aab 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -10,8 +10,10 @@ local st = require "util.stanza"; local sm_bind_resource = require "core.sessionmanager".bind_resource; +local sm_make_authenticated = require "core.sessionmanager".make_authenticated; local base64 = require "util.encodings".base64; +local datamanager_load = require "util.datamanager".load; local usermanager_validate_credentials = require "core.usermanager".validate_credentials; local t_concat, t_insert = table.concat, table.insert; local tostring = tostring; @@ -49,14 +51,14 @@ local function handle_status(session, status) session.sasl_handler = nil; elseif status == "success" then if not session.sasl_handler.username then error("SASL succeeded but we didn't get a username!"); end -- TODO move this to sessionmanager - sessionmanager.make_authenticated(session, session.sasl_handler.username); + sm_make_authenticated(session, session.sasl_handler.username); session.sasl_handler = nil; session:reset_stream(); end end local function password_callback(node, host, mechanism, decoder) - local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords + local password = (datamanager_load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords local func = function(x) return x; end; if password then if mechanism == "PLAIN" then diff --git a/plugins/mod_vcard.lua b/plugins/mod_vcard.lua index c4afb128..2e8aea02 100644 --- a/plugins/mod_vcard.lua +++ b/plugins/mod_vcard.lua @@ -8,13 +8,13 @@ -require "util.datamanager" -local datamanager = datamanager; +local hosts = _G.hosts; +local datamanager = require "util.datamanager" local st = require "util.stanza" local t_concat, t_insert = table.concat, table.insert; -require "util.jid" +local jid = require "util.jid" local jid_split = jid.split; module:add_feature("vcard-temp"); |