From f77c1fc2d0378297e4d31ff2f7420515291d9988 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 22 May 2010 05:52:24 +0500 Subject: sessionmanager: If roster loading fails during resource bind, kick the user with an internal-server-error. --- core/sessionmanager.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'core/sessionmanager.lua') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 6e771a84..3537d2d2 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -174,7 +174,19 @@ function bind_resource(session, resource) hosts[session.host].sessions[session.username].sessions[resource] = session; full_sessions[session.full_jid] = session; - session.roster = rm_load_roster(session.username, session.host); + local err; + session.roster, err = rm_load_roster(session.username, session.host); + if err then + full_sessions[session.full_jid] = nil; + hosts[session.host].sessions[session.username].sessions[resource] = nil; + session.full_jid = nil; + session.resource = nil; + if next(bare_sessions[session.username..'@'..session.host]) == nil then + bare_sessions[session.username..'@'..session.host] = nil; + hosts[session.host].sessions[session.username] = nil; + end + return nil, "cancel", "internal-server-error", "Error loading roster"; + end hosts[session.host].events.fire_event("resource-bind", {session=session}); -- cgit v1.2.3 From c1257c7435697f4ed47c823ac0ebc8f676f1c773 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 22 May 2010 05:53:27 +0500 Subject: sessionmanager: Change error for reaching resource limit from 'conflict' to 'resource-constraint' during session bind. --- core/sessionmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/sessionmanager.lua') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 3537d2d2..48990de3 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -136,7 +136,7 @@ function bind_resource(session, resource) local sessions = hosts[session.host].sessions[session.username].sessions; local limit = config_get(session.host, "core", "max_resources") or 10; if #sessions >= limit then - return nil, "cancel", "conflict", "Resource limit reached; only "..limit.." resources allowed"; + return nil, "cancel", "resource-constraint", "Resource limit reached; only "..limit.." resources allowed"; end if sessions[resource] then -- Resource conflict -- cgit v1.2.3 From 8abd2f2c24bd83acb36e9c8ace40ac3751f09663 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 23 May 2010 05:46:52 +0500 Subject: rostermanager: Correctly clear the bare_sessions table on roster load errors during bind. --- core/sessionmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/sessionmanager.lua') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 48990de3..fd6ed96e 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -181,7 +181,7 @@ function bind_resource(session, resource) hosts[session.host].sessions[session.username].sessions[resource] = nil; session.full_jid = nil; session.resource = nil; - if next(bare_sessions[session.username..'@'..session.host]) == nil then + if next(bare_sessions[session.username..'@'..session.host].sessions) == nil then bare_sessions[session.username..'@'..session.host] = nil; hosts[session.host].sessions[session.username] = nil; end -- cgit v1.2.3