From 657c14c5db8b0c882484926ba76aa64ec757ee07 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 03:07:25 +0100 Subject: [PATCH] Fix up QueryAccess to also check parcels --- .../EntityTransfer/EntityTransferModule.cs | 5 +-- .../Simulation/LocalSimulationConnector.cs | 4 +-- .../Simulation/RemoteSimulationConnector.cs | 6 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 31 ++++++++++++++----- .../Handlers/Simulation/AgentHandlers.cs | 9 +++++- .../Simulation/SimulationServiceConnector.cs | 10 ++++-- .../Services/Interfaces/ISimulationService.cs | 2 +- 7 files changed, 47 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 016871fded..9e1d414861 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -285,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId)) + if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) { sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); return; @@ -797,8 +797,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); - if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId)) + if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) { + agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); if (r == null) { r = new ExpiringCache(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index aaf7bf3331..971a56f979 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -257,7 +257,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool QueryAccess(GridRegion destination, UUID id) + public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) { if (destination == null) return false; @@ -265,7 +265,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionID == destination.RegionID) - return s.QueryAccess(id); + return s.QueryAccess(id, position); } return false; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 27792c8345..e8a662910b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -239,18 +239,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } - public bool QueryAccess(GridRegion destination, UUID id) + public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) { if (destination == null) return false; // Try local first - if (m_localBackend.QueryAccess(destination, id)) + if (m_localBackend.QueryAccess(destination, id, position)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.QueryAccess(destination, id); + return m_remoteConnector.QueryAccess(destination, id, position); return false; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5caf06c5a7..c65a82be7b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5141,23 +5141,38 @@ namespace OpenSim.Region.Framework.Scenes // from logging into the region, teleporting into the region // or corssing the broder walking, but will NOT prevent // child agent creation, thereby emulating the SL behavior. - public bool QueryAccess(UUID agentID) + public bool QueryAccess(UUID agentID, Vector3 position) { string reason; if (!AuthorizeUser(agentID, out reason)) { - m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } - float posX = 128.0f; - float posY = 128.0f; - - if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) + if (position == Vector3.Zero) // Teleport { - m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); - return false; + float posX = 128.0f; + float posY = 128.0f; + + if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) + { + // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); + return false; + } + } + else // Walking + { + ILandObject land = LandChannel.GetLandObject(position.X, position.Y); + if (land == null) + return false; + + bool banned = land.IsBannedFromLand(agentID); + bool restricted = land.IsRestrictedFromLand(agentID); + + if (banned || restricted) + return false; } return true; } diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 89832f4354..b33b0d5847 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -331,10 +331,17 @@ namespace OpenSim.Server.Handlers.Simulation return; } + // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]); + OSDMap args = Utils.GetOSDMap((string)request["body"]); + + Vector3 position = Vector3.Zero; + if (args.ContainsKey("position")) + position = Vector3.Parse(args["position"].AsString()); + GridRegion destination = new GridRegion(); destination.RegionID = regionID; - bool result = m_SimulationService.QueryAccess(destination, id); + bool result = m_SimulationService.QueryAccess(destination, id, position); responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = result.ToString(); diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 039d9e5bbc..752d5526ed 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -31,6 +31,7 @@ using System.IO; using System.Net; using System.Reflection; using System.Text; +using System.Collections; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -206,9 +207,9 @@ namespace OpenSim.Services.Connectors.Simulation /// /// - public bool QueryAccess(GridRegion destination, UUID id) + public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) { - // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start"); + // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); IPEndPoint ext = destination.ExternalEndPoint; if (ext == null) return false; @@ -216,9 +217,12 @@ namespace OpenSim.Services.Connectors.Simulation // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; + OSDMap request = new OSDMap(); + request.Add("position", OSD.FromString(position.ToString())); + try { - OSDMap result = WebUtil.ServiceOSDRequest(uri,null,"QUERYACCESS",10000); + OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000); return result["Success"].AsBoolean(); } catch (Exception e) diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 1f8474c437..f08e1c0449 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -60,7 +60,7 @@ namespace OpenSim.Services.Interfaces bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); - bool QueryAccess(GridRegion destination, UUID id); + bool QueryAccess(GridRegion destination, UUID id, Vector3 position); /// /// Message from receiving region to departing region, telling it got contacted by the client.