From 4a6160e7ad6284de8eef48892c6a6e133d4ddc2f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Oct 2011 18:22:36 +0200 Subject: Fake an AgentCircuitData if none is available rather than crashing out --- OpenSim/Region/Framework/Scenes/Scene.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 80d7871..98bc44f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5360,16 +5360,38 @@ namespace OpenSim.Region.Framework.Scenes } } + ScenePresence presence = GetScenePresence(agentID); + IClientAPI client = null; + AgentCircuitData aCircuit = null; + + if (presence != null) + { + client = presence.ControllingClient; + if (client != null) + aCircuit = client.RequestClientInfo(); + } + + // We may be called before there is a presence or a client. + // Fake AgentCircuitData to keep IAuthorizationModule smiling + if (client == null) + { + aCircuit = new AgentCircuitData(); + aCircuit.AgentID = agentID; + aCircuit.firstname = String.Empty; + aCircuit.lastname = String.Empty; + } + try { - if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) + if (!AuthorizeUser(aCircuit, out reason)) { // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } } - catch + catch (Exception e) { + m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); return false; } -- cgit v1.1