Changeset

709:8bb83563cb21

Automated merge with http://waqas.ath.cx:8000/
author Matthew Wild <mwild1@gmail.com>
date Tue, 13 Jan 2009 15:29:00 +0000
parents 708:b72d408f5f15 (diff) 701:dc67e3cffff4 (current diff)
children 710:56f6c115bc69
files core/modulemanager.lua
diffstat 8 files changed, 37 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/core/componentmanager.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/core/componentmanager.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -58,7 +58,7 @@
 	end
 end
 
-function deregister_component(host, component)
+function deregister_component(host)
 	if components[host] then
 		module_unload(host, "dialback");
 		components[host] = nil;
--- a/core/modulemanager.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/core/modulemanager.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -149,10 +149,12 @@
 	modulemap[host][name] = nil;
 	features_table:remove(host, name);
 	local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns}
-	for _, param in pairs(params) do
+	for _, param in pairs(params or NULL) do
 		local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]);
-		handler_info[handlers[1]] = nil;
-		stanza_handlers:remove(param[1], param[2], param[3], param[4]);
+		if handlers then
+			handler_info[handlers[1]] = nil;
+			stanza_handlers:remove(param[1], param[2], param[3], param[4]);
+		end
 	end
 	event_hooks:remove(host, name);
 	return true;
--- a/plugins/mod_muc.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/plugins/mod_muc.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -1,6 +1,7 @@
 
 
 local register_component = require "core.componentmanager".register_component;
+local deregister_component = require "core.componentmanager".deregister_component;
 local jid_split = require "util.jid".split;
 local jid_bare = require "util.jid".bare;
 local st = require "util.stanza";
@@ -272,3 +273,8 @@
 		handle_to_domain(origin, stanza);
 	end
 end);
+
+function unload()
+	deregister_component(muc_domain);
+end
+
--- a/plugins/mod_saslauth.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/plugins/mod_saslauth.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -21,7 +21,6 @@
 
 local st = require "util.stanza";
 local sm_bind_resource = require "core.sessionmanager".bind_resource;
-local jid
 local base64 = require "util.encodings".base64;
 
 local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
@@ -80,7 +79,7 @@
 	return func, nil;
 end
 
-function sasl_handler(session, stanza)
+local function sasl_handler(session, stanza)
 	if stanza.name == "auth" then
 		-- FIXME ignoring duplicates because ejabberd does
 		session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback);
@@ -112,18 +111,18 @@
 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' };
 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' };
 module:add_event_hook("stream-features", 
-					function (session, features)												
-						if not session.username then
-							features:tag("mechanisms", mechanisms_attr);
-							-- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so.
-								features:tag("mechanism"):text("PLAIN"):up();
-								features:tag("mechanism"):text("DIGEST-MD5"):up();
-							features:up();
-						else
-							features:tag("bind", bind_attr):tag("required"):up():up();
-							features:tag("session", xmpp_session_attr):up();
-						end
-					end);
+		function (session, features)												
+			if not session.username then
+				features:tag("mechanisms", mechanisms_attr);
+				-- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so.
+					features:tag("mechanism"):text("PLAIN"):up();
+					features:tag("mechanism"):text("DIGEST-MD5"):up();
+				features:up();
+			else
+				features:tag("bind", bind_attr):tag("required"):up():up();
+				features:tag("session", xmpp_session_attr):up();
+			end
+		end);
 					
 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", 
 		function (session, stanza)
--- a/plugins/mod_tls.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/plugins/mod_tls.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -21,12 +21,6 @@
 
 local st = require "util.stanza";
 
---local sessions = sessions;
-
-local t_insert = table.insert;
-
-local log = require "util.logger".init("mod_starttls");
-
 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
 
 module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
@@ -44,8 +38,8 @@
 		
 local starttls_attr = { xmlns = xmlns_starttls };
 module:add_event_hook("stream-features", 
-					function (session, features)												
-						if session.conn.starttls then
-							features:tag("starttls", starttls_attr):up();
-						end
-					end);
+		function (session, features)												
+			if session.conn.starttls then
+				features:tag("starttls", starttls_attr):up();
+			end
+		end);
--- a/plugins/mod_version.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/plugins/mod_version.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -21,20 +21,15 @@
 
 local st = require "util.stanza";
 
-local log = require "util.logger".init("mod_version");
-
 local xmlns_version = "jabber:iq:version"
 
 module:add_feature(xmlns_version);
 
-local function handle_version_request(session, stanza)
+module:add_iq_handler({"c2s", "s2sin"}, xmlns_version, function(session, stanza)
 	if stanza.attr.type == "get" then
 		session.send(st.reply(stanza):query(xmlns_version)
 			:tag("name"):text("Prosody"):up()
 			:tag("version"):text("0.2"):up()
 			:tag("os"):text("the best operating system ever!"));
 	end
-end
-
-module:add_iq_handler("c2s", xmlns_version, handle_version_request);
-module:add_iq_handler("s2sin", xmlns_version, handle_version_request);
+end);
--- a/util/datamanager.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/util/datamanager.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -88,7 +88,7 @@
 function load(username, host, datastore)
 	local data, ret = loadfile(getpath(username, host, datastore));
 	if not data then
-		log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+		log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
 		return nil;
 	end
 	setfenv(data, {});
@@ -163,7 +163,7 @@
 function list_load(username, host, datastore)
 	local data, ret = loadfile(getpath(username, host, datastore, "list"));
 	if not data then
-		log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+		log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
 		return nil;
 	end
 	local items = {};
--- a/util/sasl.lua	Tue Jan 13 05:55:31 2009 +0000
+++ b/util/sasl.lua	Tue Jan 13 15:29:00 2009 +0000
@@ -176,9 +176,9 @@
 			if not response["cnonce"] then return "failure", "malformed-request", "Missing entry for cnonce in SASL message." end
 			if not response["qop"] then response["qop"] = "auth" end
 			
-			if response["realm"] == nil then
-				response["realm"] = "";
-			elseif response["realm"] ~= self.realm and response["realm"] ~= "" then
+			if response["realm"] == nil or response["realm"] == "" then
+				response["realm"] = self.realm;
+			elseif response["realm"] ~= self.realm then
 				return "failure", "not-authorized", "Incorrect realm value";
 			end