From ee6cd884c9732b492675e043fe318ffcdfecc45d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 13 Jul 2010 23:58:19 +0100 Subject: [PATCH] implement serverside checks for media texture navigation in order to stop naughty clients --- .../World/Media/Moap/MoapModule.cs | 20 ++++++++++++------ .../World/Permissions/PermissionsModule.cs | 21 ++++++++++++++++++- .../Framework/Scenes/Scene.Permissions.cs | 19 ++++++++++++++++- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index d7aede91dd..09786ec096 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -245,12 +245,12 @@ namespace OpenSim.Region.CoreModules.Media.Moap m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); - for (int i = 0; i < omu.FaceMedia.Length; i++) - { - MediaEntry me = omu.FaceMedia[i]; - string v = (null == me ? "null": OSDParser.SerializeLLSDXmlString(me.GetOSD())); - m_log.DebugFormat("[MOAP]: Face {0} [{1}]", i, v); - } +// for (int i = 0; i < omu.FaceMedia.Length; i++) +// { +// MediaEntry me = omu.FaceMedia[i]; +// string v = (null == me ? "null": OSDParser.SerializeLLSDXmlString(me.GetOSD())); +// m_log.DebugFormat("[MOAP]: Face {0} [{1}]", i, v); +// } if (omu.FaceMedia.Length > part.GetNumberOfSides()) { @@ -322,6 +322,14 @@ namespace OpenSim.Region.CoreModules.Media.Moap return string.Empty; } + UUID agentId = default(UUID); + + lock (m_omuCapUsers) + agentId = m_omuCapUsers[path]; + + if (!m_scene.Permissions.CanInteractWithPrimMedia(agentId, part.UUID, omn.Face)) + return string.Empty; + m_log.DebugFormat( "[MOAP]: Updating media entry for face {0} on prim {1} {2} to {3}", omn.Face, part.Name, part.UUID, omn.URL); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 2344e9681f..3a690afc73 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -251,6 +251,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; + m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; m_scene.AddCommand(this, "bypass permissions", "bypass permissions ", @@ -1915,7 +1916,25 @@ namespace OpenSim.Region.CoreModules.World.Permissions return true; return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); - } + } + + private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) + { + if (null == m_moapModule) + return false; + + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (null == part) + return false; + + MediaEntry me = m_moapModule.GetMediaEntry(part, face); + + // If there is no existing media entry then it can be controlled (in this context, created). + if (null == me) + return true; + + return GenericPrimMediaPermission(part, agentID, me.InteractPermissions); + } private bool GenericPrimMediaPermission(SceneObjectPart part, UUID agentID, MediaPermission perms) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 70af978719..003390047f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -82,6 +82,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); public delegate bool ControlPrimMediaHandler(UUID userID, UUID primID, int face); + public delegate bool InteractWithPrimMediaHandler(UUID userID, UUID primID, int face); #endregion public class ScenePermissions @@ -141,6 +142,7 @@ namespace OpenSim.Region.Framework.Scenes public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; public event ControlPrimMediaHandler OnControlPrimMedia; + public event InteractWithPrimMediaHandler OnInteractWithPrimMedia; #endregion #region Object Permission Checks @@ -963,6 +965,21 @@ namespace OpenSim.Region.Framework.Scenes } } return true; - } + } + + public bool CanInteractWithPrimMedia(UUID userID, UUID primID, int face) + { + InteractWithPrimMediaHandler handler = OnInteractWithPrimMedia; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (InteractWithPrimMediaHandler h in list) + { + if (h(userID, primID, face) == false) + return false; + } + } + return true; + } } } \ No newline at end of file