From 5699bb2e64766da634ca4be34bc2d8eab991f2e1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 15 Aug 2007 14:10:26 +0000 Subject: * Permissions! - You can now only perform certain functions (such as editing other peoples objects) if you have permission to do so. * Moved OnPermissionError to EventManager - now triggers a standard blue alert. * Terraforming now requires permission via the permissions manager. [Defaults to admin-only] * Permissions manager is now substantiated in Scene * Buttload of new permissions added. * Estate manager operations now require various levels of permission to operate * OGS1 now produces 'summary reports' for a commsManager of each scene it maintains connections for. Reduces grid network traffic for ping checks. * Added new "permissions true" / "permissions false" console command to enable or disable permissions. --- .../Environment/Scenes/Scene.PacketHandlers.cs | 42 ++++++++++++++-------- OpenSim/Region/Environment/Scenes/Scene.cs | 16 +++++++++ OpenSim/Region/Environment/Scenes/SceneEvents.cs | 9 +++++ 3 files changed, 52 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index bba0138..cca8998 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -50,6 +50,12 @@ namespace OpenSim.Region.Environment.Scenes /// Distance from the west border where the cursor is located public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser) { + // Do a permissions check before allowing terraforming. + // random users are now no longer allowed to terraform + // if permissions are enabled. + if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0))) + return; + // Shiny. double size = (double)(1 << brushsize); @@ -240,15 +246,18 @@ namespace OpenSim.Region.Environment.Scenes } if (selectedEnt != null) { - List avatars = this.RequestAvatarList(); - foreach (ScenePresence avatar in avatars) - { - avatar.ControllingClient.SendKillObject(this.m_regionHandle, selectedEnt.LocalId); - } - - lock (Entities) + if (PermissionsMngr.CanDeRezObject(simClient.AgentId, selectedEnt.m_uuid)) { - Entities.Remove(selectedEnt.m_uuid); + List avatars = this.RequestAvatarList(); + foreach (ScenePresence avatar in avatars) + { + avatar.ControllingClient.SendKillObject(this.m_regionHandle, selectedEnt.LocalId); + } + + lock (Entities) + { + Entities.Remove(selectedEnt.m_uuid); + } } } } @@ -501,16 +510,19 @@ namespace OpenSim.Region.Environment.Scenes public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) + if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) { - if (ent is SceneObjectGroup) + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); - if (hasPrim != false) + if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); - break; + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); + if (hasPrim != false) + { + ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); + break; + } } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 6c87c5d..0fa3ab7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -110,6 +110,13 @@ namespace OpenSim.Region.Environment.Scenes get { return m_scriptManager; } } + private PermissionManager m_permissionManager; + + public PermissionManager PermissionsMngr + { + get { return m_permissionManager; } + } + public Dictionary Objects { get { return Prims; } @@ -143,10 +150,13 @@ namespace OpenSim.Region.Environment.Scenes m_estateManager = new EstateManager(this, m_regInfo); m_scriptManager = new ScriptManager(this); m_eventManager = new EventManager(); + m_permissionManager = new PermissionManager(this); m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; + m_eventManager.OnPermissionError += SendPermissionAlert; + MainLog.Instance.Verbose("Creating new entitities instance"); Entities = new Dictionary(); Avatars = new Dictionary(); @@ -966,6 +976,12 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Alert Methods + + void SendPermissionAlert(LLUUID user, string reason) + { + SendAlertToUser(user, reason, false); + } + public void SendGeneralAlert(string message) { foreach (ScenePresence presence in this.Avatars.Values) diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index cb5a967..050207c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -33,7 +33,16 @@ namespace OpenSim.Region.Environment.Scenes public event OnShutdownDelegate OnShutdown; public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); + public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); public event ObjectGrabDelegate OnObjectGrab; + public event OnPermissionErrorDelegate OnPermissionError; + + + public void TriggerPermissionError(LLUUID user, string reason) + { + if (OnPermissionError != null) + OnPermissionError(user, reason); + } public void TriggerOnScriptConsole(string[] args) { -- cgit v1.1