mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
Guard against unauthorized agent deletes.
This commit is contained in:
@@ -3452,7 +3452,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
regions.Remove(RegionInfo.RegionHandle);
|
||||
|
||||
// This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours.
|
||||
m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
|
||||
m_sceneGridService.SendCloseChildAgentConnections(agentID, Util.Md5Hash(acd.Id0), regions);
|
||||
}
|
||||
|
||||
m_eventManager.TriggerClientClosed(agentID, this);
|
||||
@@ -4277,6 +4277,25 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Authenticated close (via network)
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="force"></param>
|
||||
/// <param name="auth_token"></param>
|
||||
/// <returns></returns>
|
||||
public bool IncomingCloseAgent(UUID agentID, bool force, string auth_token)
|
||||
{
|
||||
//m_log.DebugFormat("[SCENE]: Processing incoming close agent {0} in region {1} with auth_token {2}", agentID, RegionInfo.RegionName, auth_token);
|
||||
|
||||
// Check that the auth_token is valid
|
||||
AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID);
|
||||
if (acd != null && Util.Md5Hash(acd.Id0) == auth_token)
|
||||
return IncomingCloseAgent(agentID, force);
|
||||
else
|
||||
m_log.ErrorFormat("[SCENE]: Request to close agent {0} with invalid authorization token {1}", agentID, auth_token);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell a single agent to disconnect from the region.
|
||||
@@ -4292,12 +4311,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
|
||||
if (presence != null)
|
||||
{
|
||||
presence.ControllingClient.Close(force);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Agent not here
|
||||
// Agent not here
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <summary>
|
||||
/// Closes a child agent on a given region
|
||||
/// </summary>
|
||||
protected void SendCloseChildAgent(UUID agentID, ulong regionHandle)
|
||||
protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token)
|
||||
{
|
||||
// let's do our best, but there's not much we can do if the neighbour doesn't accept.
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_log.DebugFormat(
|
||||
"[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName);
|
||||
|
||||
m_scene.SimulationService.CloseAgent(destination, agentID);
|
||||
m_scene.SimulationService.CloseAgent(destination, agentID, auth_token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -219,14 +219,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="regionslst"></param>
|
||||
public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst)
|
||||
public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List<ulong> regionslst)
|
||||
{
|
||||
foreach (ulong handle in regionslst)
|
||||
{
|
||||
// We must take a copy here since handle is acts like a reference when used in an iterator.
|
||||
// This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region.
|
||||
ulong handleCopy = handle;
|
||||
Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy); });
|
||||
Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3167,7 +3167,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents");
|
||||
|
||||
m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions);
|
||||
AgentCircuitData acd = Scene.AuthenticateHandler.GetAgentCircuitData(UUID);
|
||||
string auth = string.Empty;
|
||||
if (acd != null)
|
||||
auth = Util.Md5Hash(acd.Id0);
|
||||
m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, auth, byebyeRegions);
|
||||
}
|
||||
|
||||
foreach (ulong handle in byebyeRegions)
|
||||
|
||||
Reference in New Issue
Block a user