From 3ff7391495271fed152aadc7a588ae976e09bafc Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 29 Apr 2013 00:55:34 +0100 Subject: Some more pieces of Avination's ban system - if an avatar isn't allowed on any parcel in the sim, keep them out entirely. --- OpenSim/Region/Framework/Scenes/Scene.cs | 95 +++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 69fe137..829a7e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3693,7 +3693,7 @@ namespace OpenSim.Region.Framework.Scenes //On login test land permisions if (vialogin) { - if (land != null && !TestLandRestrictions(agent, land, out reason)) + if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) { return false; } @@ -3868,20 +3868,37 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) + public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { - bool banned = land.IsBannedFromLand(agent.AgentID); - bool restricted = land.IsRestrictedFromLand(agent.AgentID); + if (posX < 0) + posX = 0; + else if (posX >= 256) + posX = 255.999f; + if (posY < 0) + posY = 0; + else if (posY >= 256) + posY = 255.999f; + + reason = String.Empty; + if (Permissions.IsGod(agentID)) + return true; + + ILandObject land = LandChannel.GetLandObject(posX, posY); + if (land == null) + return false; + + bool banned = land.IsBannedFromLand(agentID); + bool restricted = land.IsRestrictedFromLand(agentID); if (banned || restricted) { - ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); + ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); if (nearestParcel != null) { //Move agent to nearest allowed Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); - agent.startpos.X = newPosition.X; - agent.startpos.Y = newPosition.Y; + posX = newPosition.X; + posY = newPosition.Y; } else { @@ -5466,6 +5483,8 @@ namespace OpenSim.Region.Framework.Scenes /// public bool QueryAccess(UUID agentID, Vector3 position, out string reason) { + reason = "You are banned from the region"; + if (EntityTransferModule.IsInTransit(agentID)) { reason = "Agent is still in transit from this region"; @@ -5477,6 +5496,12 @@ namespace OpenSim.Region.Framework.Scenes return false; } + if (Permissions.IsGod(agentID)) + { + reason = String.Empty; + return true; + } + // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. // However, the long term fix is to make sure root agent count is always accurate. m_sceneGraph.RecalculateStats(); @@ -5497,6 +5522,41 @@ 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(aCircuit, out reason)) + { + // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + return false; + } + } + catch (Exception e) + { + m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); + return false; + } + if (position == Vector3.Zero) // Teleport { if (!RegionInfo.EstateSettings.AllowDirectTeleport) @@ -5530,6 +5590,27 @@ namespace OpenSim.Region.Framework.Scenes } } } + + 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; } reason = String.Empty; -- cgit v1.1