From dda71bf6d36d1395833a369eebf52fb011cc075f Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Wed, 9 May 2012 02:56:22 +0000 Subject: mod_dialback: COMPAT reset session.send function for servers (e.g. ejabberd) which don't include a from attr when opening the stream. --- plugins/mod_dialback.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 35186c5e..cc076db5 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -78,6 +78,9 @@ module:hook("stanza/jabber:server:dialback:result", function(event) if not origin.from_host then -- Just used for friendlier logging origin.from_host = attr.from; + -- COMPAT: Fix ejabberd chopness by resetting the send function + origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); + origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end end if not origin.to_host then -- Just used for friendlier logging -- cgit v1.2.3 From b2c4645fefc6412c1dd5625c463cd58980e31569 Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Wed, 9 May 2012 11:25:22 +0000 Subject: mod_dialback: add better safe then sorry nameprepping to the from attribute. --- plugins/mod_dialback.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index cc076db5..5d32fdb2 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -15,6 +15,7 @@ local log = module._log; local st = require "util.stanza"; local sha256_hash = require "util.hashes".sha256; +local nameprep = require "util.encodings".stringprep.nameprep; local xmlns_stream = "http://etherx.jabber.org/streams"; @@ -77,10 +78,15 @@ module:hook("stanza/jabber:server:dialback:result", function(event) if not origin.from_host then -- Just used for friendlier logging - origin.from_host = attr.from; + origin.from_host = nameprep(attr.from); -- COMPAT: Fix ejabberd chopness by resetting the send function - origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); - origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + if not origin.from_host then + origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection."); + origin:close("invalid-from"); + else + origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); + origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + end end if not origin.to_host then -- Just used for friendlier logging -- cgit v1.2.3 From a773a23715f2c60b566ddf290f123fcd9c3d1bae Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Wed, 9 May 2012 23:09:06 +0000 Subject: mod_dialback: make change a bit more wide, encompass to and from and reject with proper addressing when neither are there. --- plugins/mod_dialback.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 5d32fdb2..f3b9e3cf 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -76,21 +76,27 @@ module:hook("stanza/jabber:server:dialback:result", function(event) dialback_requests[attr.from.."/"..origin.streamid] = origin; + local compat_check; if not origin.from_host then -- Just used for friendlier logging origin.from_host = nameprep(attr.from); - -- COMPAT: Fix ejabberd chopness by resetting the send function - if not origin.from_host then - origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection."); - origin:close("invalid-from"); - else - origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); - origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end - end + -- COMPAT: Fix server's chopness by not including from + compat_check = true; end if not origin.to_host then -- Just used for friendlier logging - origin.to_host = attr.to; + origin.to_host = nameprep(attr.to); + -- COMPAT: Fix server's chopness by not including to + compat_check = true; + end + + if not origin.from_host and not origin.to_host then + origin.log("debug", "Improper addressing supplied, no to or from?"); + origin:close("improper-addressing"); + end + -- COMPAT: reset session.send + if compat_check then + origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end end origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); -- cgit v1.2.3 From 0fcfca7201b03c3a494df53baee718ebbe3776dd Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Thu, 10 May 2012 12:54:37 +0000 Subject: mod_auth_anonymous: add disallow_s2s to the host object if s2s communication is disallowed. --- plugins/mod_auth_anonymous.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/mod_auth_anonymous.lua b/plugins/mod_auth_anonymous.lua index 55398d8a..5df81f24 100644 --- a/plugins/mod_auth_anonymous.lua +++ b/plugins/mod_auth_anonymous.lua @@ -52,6 +52,7 @@ local function dm_callback(username, host, datastore, data) end if module:get_option_boolean("disallow_s2s", true) then + hosts[module.host].disallow_s2s = true; module:hook("route/remote", function (event) return false; -- Block outgoing s2s from anonymous users end, 300); -- cgit v1.2.3 From bd53859e5720ca585724a410c2af28b2156be206 Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Thu, 10 May 2012 23:37:36 +0000 Subject: muc.lib: return feature-not-implemented when a foregoing discovery node is specified in a disco#info request. --- plugins/muc/muc.lib.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 9be1736f..0203df26 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -744,7 +744,11 @@ function room_mt:handle_to_room(origin, stanza) -- presence changes and groupcha local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; if stanza.name == "iq" then if xmlns == "http://jabber.org/protocol/disco#info" and type == "get" then - origin.send(self:get_disco_info(stanza)); + if stanza.tags[1].attr.node then + origin.send(st.error_reply(stanza, "cancel", "feature-not-implemented")); + else + origin.send(self:get_disco_info(stanza)); + end elseif xmlns == "http://jabber.org/protocol/disco#items" and type == "get" then origin.send(self:get_disco_items(stanza)); elseif xmlns == "http://jabber.org/protocol/muc#admin" then -- cgit v1.2.3 From 04bfcc280a54656435168beac16f65fc9e71acfc Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 11 May 2012 01:29:30 +0100 Subject: Backed out changeset 751510cd558d - obsoleted by 5ef05f32bc42. --- plugins/mod_dialback.lua | 3 --- 1 file changed, 3 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index cc076db5..35186c5e 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -78,9 +78,6 @@ module:hook("stanza/jabber:server:dialback:result", function(event) if not origin.from_host then -- Just used for friendlier logging origin.from_host = attr.from; - -- COMPAT: Fix ejabberd chopness by resetting the send function - origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); - origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end end if not origin.to_host then -- Just used for friendlier logging -- cgit v1.2.3 From 5a95f10b210e59072916230230ee260eca3dd551 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 11 May 2012 01:39:52 +0100 Subject: Backed out changeset 9f1fb34cd7f8 - obsoleted by 5ef05f32bc42. --- plugins/mod_dialback.lua | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index f3b9e3cf..5d32fdb2 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -76,27 +76,21 @@ module:hook("stanza/jabber:server:dialback:result", function(event) dialback_requests[attr.from.."/"..origin.streamid] = origin; - local compat_check; if not origin.from_host then -- Just used for friendlier logging origin.from_host = nameprep(attr.from); - -- COMPAT: Fix server's chopness by not including from - compat_check = true; + -- COMPAT: Fix ejabberd chopness by resetting the send function + if not origin.from_host then + origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection."); + origin:close("invalid-from"); + else + origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); + origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + end end if not origin.to_host then -- Just used for friendlier logging - origin.to_host = nameprep(attr.to); - -- COMPAT: Fix server's chopness by not including to - compat_check = true; - end - - if not origin.from_host and not origin.to_host then - origin.log("debug", "Improper addressing supplied, no to or from?"); - origin:close("improper-addressing"); - end - -- COMPAT: reset session.send - if compat_check then - origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + origin.to_host = attr.to; end origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); -- cgit v1.2.3 From ac1d04c961f8b675c8bc6af9fe5760fd737f4c67 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 11 May 2012 01:46:35 +0100 Subject: Backed out changeset 661752889535 - obsoleted by 878f75ccc4fb. --- plugins/mod_auth_anonymous.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_auth_anonymous.lua b/plugins/mod_auth_anonymous.lua index 5df81f24..55398d8a 100644 --- a/plugins/mod_auth_anonymous.lua +++ b/plugins/mod_auth_anonymous.lua @@ -52,7 +52,6 @@ local function dm_callback(username, host, datastore, data) end if module:get_option_boolean("disallow_s2s", true) then - hosts[module.host].disallow_s2s = true; module:hook("route/remote", function (event) return false; -- Block outgoing s2s from anonymous users end, 300); -- cgit v1.2.3