From 59c86a104ce5e4a3095dace97fe6a2635fadd874 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 13 Dec 2016 21:23:48 +0100 Subject: mod_roster: Remove unused import [luacheck] --- plugins/mod_roster.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua index 454acebb..6545e2be 100644 --- a/plugins/mod_roster.lua +++ b/plugins/mod_roster.lua @@ -19,7 +19,6 @@ local rm_load_roster = require "core.rostermanager".load_roster; local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; local rm_add_to_roster = require "core.rostermanager".add_to_roster; local rm_roster_push = require "core.rostermanager".roster_push; -local core_post_stanza = prosody.core_post_stanza; module:add_feature("jabber:iq:roster"); -- cgit v1.2.3 From 1db5cd0ec49212378f1a4a9fe0da21fcc92626b6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 13 Dec 2016 21:24:12 +0100 Subject: mod_roster: Remove unused variable [luacheck] --- plugins/mod_roster.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua index 6545e2be..443e5d4a 100644 --- a/plugins/mod_roster.lua +++ b/plugins/mod_roster.lua @@ -135,7 +135,6 @@ module:hook_global("user-deleted", function(event) local username, host = event.username, event.host; local origin = event.origin or prosody.hosts[host]; if host ~= module.host then return end - local bare = username .. "@" .. host; local roster = rm_load_roster(username, host); for jid, item in pairs(roster) do if jid then -- cgit v1.2.3 From 0f0d87f07b8d6e9109b5fb3358078c663beab4d5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 13 Dec 2016 21:25:11 +0100 Subject: mod_roster: Rename variable to silence shadowing warning [luacheck] --- plugins/mod_roster.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua index 443e5d4a..24c50678 100644 --- a/plugins/mod_roster.lua +++ b/plugins/mod_roster.lua @@ -142,9 +142,9 @@ module:hook_global("user-deleted", function(event) username = username, jid = jid, item = item, roster = roster, origin = origin, }); else - for jid in pairs(item.pending) do + for pending_jid in pairs(item.pending) do module:fire_event("roster-item-removed", { - username = username, jid = jid, roster = roster, origin = origin, + username = username, jid = pending_jid, roster = roster, origin = origin, }); end end -- cgit v1.2.3 From e701756ba976c28d2532f3d113f24429c457dec5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 13 Dec 2016 18:15:17 +0100 Subject: core.sessionmanager, mod_saslauth: Introduce intermediate session type for authenticated but unbound sessions so that resource binding is not treated as a normal stanza --- core/sessionmanager.lua | 5 ++++- plugins/mod_saslauth.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index c8856634..75e54b4f 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -108,7 +108,7 @@ local function make_authenticated(session, username) if not username or #username == 0 then return nil, "Invalid username"; end session.username = username; if session.type == "c2s_unauthed" then - session.type = "c2s"; + session.type = "c2s_unbound"; end session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)"); return true; @@ -176,6 +176,9 @@ local function bind_resource(session, resource) session.full_jid = session.username .. '@' .. session.host .. '/' .. resource; hosts[session.host].sessions[session.username].sessions[resource] = session; full_sessions[session.full_jid] = session; + if session.type == "c2s_unbound" then + session.type = "c2s"; + end local err; session.roster, err = rm_load_roster(session.username, session.host); diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index bb36600b..9917c303 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -273,7 +273,7 @@ module:hook("s2s-stream-features", function(event) end end); -module:hook("iq/self/urn:ietf:params:xml:ns:xmpp-bind:bind", function(event) +module:hook("stanza/iq/urn:ietf:params:xml:ns:xmpp-bind:bind", function(event) local origin, stanza = event.origin, event.stanza; local resource; if stanza.attr.type == "set" then -- cgit v1.2.3 From 2c7554d63405a862ae1681c52b24de1efe350a96 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 13 Dec 2016 18:16:20 +0100 Subject: core.stanza_router: Remove hack for allowing resource binding IQ before resource binding --- core/stanza_router.lua | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/core/stanza_router.lua b/core/stanza_router.lua index af797f08..98952faf 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -79,16 +79,6 @@ function core_process_stanza(origin, stanza) end end - if not origin.full_jid - and not(name == "iq" and st_type == "set" and stanza.tags[1] and stanza.tags[1].name == "bind" - and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then - -- authenticated client isn't bound and current stanza is not a bind request - if stanza.attr.type ~= "result" and stanza.attr.type ~= "error" then - origin.send(st.error_reply(stanza, "auth", "not-authorized")); -- FIXME maybe allow stanzas to account or server - end - return; - end - -- TODO also, stanzas should be returned to their original state before the function ends stanza.attr.from = origin.full_jid; end -- cgit v1.2.3