From 9655cf280779021e6241a08f8610cad9b982763f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 May 2008 20:14:53 +0000 Subject: [PATCH] * Refactor: Break out permissions code into a separate region PermissionsModule --- OpenSim/Grid/ScriptServer/FakeScene.cs | 4 +- OpenSim/Region/Application/OpenSimMain.cs | 13 +-- .../ClientStack/LindenUDP/LLClientView.cs | 26 ++--- .../ClientStack/RegionApplicationBase.cs | 9 +- .../Interfaces/IScenePermissions.cs | 103 ++++++++++++++++++ .../Modules/Agent/Xfer/XferModule.cs | 4 - .../World/Estate/EstateManagementModule.cs | 4 +- .../World/Permissions/PermissionsModule.cs} | 66 +++++------ .../Modules/World/Terrain/TerrainModule.cs | 2 +- .../Region/Environment/Scenes/InnerScene.cs | 42 ++++--- .../Environment/Scenes/Scene.Inventory.cs | 12 +- .../Scenes/Scene.PacketHandlers.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 34 +++--- .../Region/Environment/Scenes/SceneManager.cs | 2 +- .../Environment/Scenes/SceneObjectGroup.cs | 2 +- .../Environment/Scenes/ScenePresence.cs | 2 +- .../Common/LSL_BuiltIn_Commands.cs | 8 +- .../Common/OSSL_BuilIn_Commands.cs | 6 +- 18 files changed, 219 insertions(+), 124 deletions(-) create mode 100644 OpenSim/Region/Environment/Interfaces/IScenePermissions.cs rename OpenSim/Region/Environment/{PermissionManager.cs => Modules/World/Permissions/PermissionsModule.cs} (94%) diff --git a/OpenSim/Grid/ScriptServer/FakeScene.cs b/OpenSim/Grid/ScriptServer/FakeScene.cs index 480050dd24..ffabfb5f3b 100644 --- a/OpenSim/Grid/ScriptServer/FakeScene.cs +++ b/OpenSim/Grid/ScriptServer/FakeScene.cs @@ -36,12 +36,12 @@ namespace OpenSim.Grid.ScriptServer { public class FakeScene: Scene { - public FakeScene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, + public FakeScene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool sendTasksToChild) : base( - regInfo, authen, permissionManager, commsMan, sceneGridService, assetCach, storeManager, httpServer, + regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, httpServer, moduleLoader, dumpAssetsToFile, physicalPrim, sendTasksToChild) { } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 43f73752d4..a25f3c0b0b 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -74,7 +74,6 @@ namespace OpenSim protected List m_regionData = new List(); protected bool m_physicalPrim; - protected bool m_permissions = false; protected bool m_standaloneAuthenticate = false; protected string m_standaloneWelcomeMessage = null; @@ -263,9 +262,7 @@ namespace OpenSim m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true); - - m_permissions = startupConfig.GetBoolean("serverside_object_permissions", false); - + m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.Data.SQLite.dll"); if (m_storageDll == "OpenSim.DataStore.MonoSqlite.dll") { @@ -490,7 +487,7 @@ namespace OpenSim } IClientNetworkServer clientServer; - Scene scene = SetupScene(regionInfo, proxyOffset, out clientServer, m_permissions); + Scene scene = SetupScene(regionInfo, proxyOffset, out clientServer); m_log.Info("[MODULES]: Loading Region's modules"); @@ -530,9 +527,6 @@ namespace OpenSim // and has to happen before the region is registered with the grid. scene.CreateTerrainTexture(true); scene.RegisterRegionWithGrid(); - - //Server side object editing permissions checking - scene.PermissionsMngr.BypassPermissions = !m_permissions; // We need to do this after we've initialized the scripting engines. scene.StartScripts(); @@ -565,10 +559,9 @@ namespace OpenSim protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) { - PermissionManager permissionManager = new PermissionManager(); SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); return - new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, + new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_see_into_region_from_neighbor); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f2271fb07f..f7d6f9edf8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4956,13 +4956,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP { case "getinfo": - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice); } break; case "setregioninfo": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter),convertParamStringToBool(messagePacket.ParamList[1].Parameter), convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter), @@ -4975,7 +4975,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case "texturebase": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -4990,7 +4990,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "texturedetail": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -5008,7 +5008,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case "textureheights": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -5029,7 +5029,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP OnCommitEstateTerrainTextureRequest(this); break; case "setregionterrain": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { if (messagePacket.ParamList.Length != 9) { @@ -5064,7 +5064,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case "restart": - if (((Scene)m_scene).PermissionsMngr.CanRestartSim(this.AgentId)) + if (((Scene)m_scene).Permissions.CanRestartSim(this.AgentId)) { // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) @@ -5078,7 +5078,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "estatechangecovenantid": - if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + if (((Scene)m_scene).Permissions.CanEditEstateTerrain(this.AgentId)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -5088,7 +5088,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "estateaccessdelta": // Estate access delta manages the banlist and allow list too. - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(messagePacket.ParamList[1].Parameter)); OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice,estateAccessType,new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter))); @@ -5096,7 +5096,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "simulatormessage": - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { LLUUID invoice = messagePacket.MethodData.Invoice; LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter)); @@ -5107,7 +5107,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "instantmessage": - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { LLUUID invoice = messagePacket.MethodData.Invoice; LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter)); @@ -5118,7 +5118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "setregiondebug": - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { LLUUID invoice = messagePacket.MethodData.Invoice; LLUUID SenderID = messagePacket.AgentData.AgentID; @@ -5130,7 +5130,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; case "teleporthomeuser": - if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + if (((Scene)m_scene).Permissions.GenericEstatePermission(this.AgentId)) { LLUUID invoice = messagePacket.MethodData.Invoice; LLUUID SenderID = messagePacket.AgentData.AgentID; diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index ba0b9b4f6e..1dcab20275 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -107,12 +107,12 @@ namespace OpenSim.Region.ClientStack return physicsPluginManager.GetPhysicsScene(engine, meshEngine); } - protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer, bool m_permissions) + protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer) { - return SetupScene(regionInfo, 0, out clientServer, m_permissions); + return SetupScene(regionInfo, 0, out clientServer); } - protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out IClientNetworkServer clientServer, bool m_permissions) + protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out IClientNetworkServer clientServer) { AgentCircuitManager circuitManager = new AgentCircuitManager(); IPAddress listenIP = regionInfo.InternalEndPoint.Address; @@ -162,8 +162,9 @@ namespace OpenSim.Region.ClientStack scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; } - scene.LoadPrimsFromStorage(m_permissions, regionInfo.originRegionID); + scene.LoadPrimsFromStorage(regionInfo.originRegionID); scene.StartTimer(); + return scene; } diff --git a/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs b/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs new file mode 100644 index 0000000000..ad8e139640 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs @@ -0,0 +1,103 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IScenePermissions + { + bool BypassPermissions { get; set; } + + #region Object Permissions + + bool CanRezObject(LLUUID user, LLVector3 position); + + /// + /// Permissions check - can user delete an object? + /// + /// User attempting the delete + /// Target object + /// Has permission? + bool CanDeRezObject(LLUUID user, LLUUID obj); + + bool CanCopyObject(LLUUID user, LLUUID obj); + + bool CanEditObject(LLUUID user, LLUUID obj); + + bool CanEditObjectPosition(LLUUID user, LLUUID obj); + + /// + /// Permissions check - can user enter an object? + /// + /// User attempting move an object + /// Source object-position + /// Target object-position + /// Has permission? + bool CanObjectEntry(LLUUID user, LLVector3 oldPos, LLVector3 newPos); + + bool CanReturnObject(LLUUID user, LLUUID obj); + + #endregion + + #region Uncategorized permissions + + bool CanInstantMessage(LLUUID user, LLUUID target); + + bool CanInventoryTransfer(LLUUID user, LLUUID target); + + bool CanEditScript(LLUUID user, LLUUID script); + + bool CanRunScript(LLUUID user, LLUUID script); + + bool CanRunConsoleCommand(LLUUID user); + + bool CanTerraform(LLUUID user, LLVector3 position); + + #endregion + + #region Estate Permissions + + bool IsEstateManager(LLUUID user); + + bool GenericEstatePermission(LLUUID user); + + bool CanEditEstateTerrain(LLUUID user); + + bool CanRestartSim(LLUUID user); + + bool CanEditParcel(LLUUID user, ILandObject parcel); + + bool CanSellParcel(LLUUID user, ILandObject parcel); + + bool CanAbandonParcel(LLUUID user, ILandObject parcel); + + #endregion + + uint GenerateClientFlags(LLUUID user, LLUUID objID); + } +} diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs index 8e90d1798f..c7ee2336c2 100644 --- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs @@ -41,10 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer public Dictionary NewFiles = new Dictionary(); public Dictionary Transfers = new Dictionary(); - public XferModule() - { - } - #region IRegionModule Members public void Initialise(Scene scene, IConfigSource config) diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index 403ab5bd39..ebe0357991 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates - if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions) + if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.Permissions.BypassPermissions) { m_scene.RegionInfo.EstateSettings.AddEstateManager(user); remote_client.sendEstateManagersList(invoice); @@ -219,7 +219,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate case 512: // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates - if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions) + if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.Permissions.BypassPermissions) { m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user); remote_client.sendEstateManagersList(invoice); diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs similarity index 94% rename from OpenSim/Region/Environment/PermissionManager.cs rename to OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index fd8387be99..de02702674 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -26,12 +26,14 @@ */ using libsecondlife; +using Nini.Config; + using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -namespace OpenSim.Region.Environment +namespace OpenSim.Region.Environment.Modules.World.Permissions { - public class PermissionManager + public class PermissionsModule : IRegionModule, IScenePermissions { protected Scene m_scene; @@ -43,11 +45,9 @@ namespace OpenSim.Region.Environment private uint PERM_MOVE = (uint)524288; //private uint PERM_TRANS = (uint)8192; private uint PERM_LOCKED = (uint)540672; - // Bypasses the permissions engine (always returns OK) - // disable in any production environment - // TODO: Change this to false when permissions are a desired default - // TODO: Move to configuration option. - private bool m_bypassPermissions = true; + + // Bypasses the permissions engine + private bool m_bypassPermissions = false; public bool BypassPermissions { @@ -55,20 +55,40 @@ namespace OpenSim.Region.Environment set { m_bypassPermissions = value; } } - public PermissionManager() + #region IRegionModule Members + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + + // FIXME: Possibly move all permissions related stuff to its own section + IConfig myConfig = config.Configs["Startup"]; + + m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", false); + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() { } - public PermissionManager(Scene scene) + public void Close() { - m_scene = scene; } - public void Initialise(Scene scene) + public string Name { - m_scene = scene; + get { return "PermissionsModule"; } } + public bool IsSharedModule + { + get { return false; } + } + + #endregion + protected virtual void SendPermissionError(LLUUID user, string reason) { m_scene.EventManager.TriggerPermissionError(user, reason); @@ -159,17 +179,9 @@ namespace OpenSim.Region.Environment return permission; } - /// - /// Permissions check - can user enter an object? - /// - /// User attempting move an object - /// Source object-position - /// Target object-position - /// Has permission? + /// User attempting the delete - /// Target object - /// Has permission? + /// m_updateList = new List(); protected int m_numRootAgents = 0; protected int m_numPrim = 0; @@ -79,11 +78,10 @@ namespace OpenSim.Region.Environment.Scenes #endregion - public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) + public InnerScene(Scene parent, RegionInfo regInfo) { m_parentScene = parent; m_regInfo = regInfo; - PermissionsMngr = permissionsMngr; QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize); QuadTree.Subdivide(); QuadTree.Subdivide(); @@ -1031,7 +1029,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.Resize(scale, localID); } @@ -1042,7 +1040,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.GroupResize(scale, localID); } @@ -1078,7 +1076,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateSingleRotation(rot, localID); } @@ -1096,7 +1094,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateGroupRotation(rot); } @@ -1115,7 +1113,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateGroupRotation(pos, rot); } @@ -1128,12 +1126,12 @@ namespace OpenSim.Region.Environment.Scenes if (group != null) { LLVector3 oldPos = group.AbsolutePosition; - if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) + if (!m_parentScene.Permissions.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) { group.SendGroupTerseUpdate(); return; } - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment) { group.UpdateSinglePosition(pos, localID); } @@ -1159,12 +1157,12 @@ namespace OpenSim.Region.Environment.Scenes } else { - if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) + if (!m_parentScene.Permissions.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) { group.SendGroupTerseUpdate(); return; } - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment) { group.UpdateGroupPosition(pos); } @@ -1183,7 +1181,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateTextureEntry(localID, texture); } @@ -1201,7 +1199,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { - if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObject(remoteClient.AgentId, group.UUID)) { group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); } @@ -1213,7 +1211,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(objectID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))// && PermissionsMngr.) + if (m_parentScene.Permissions.CanEditObjectPosition(remoteClient.AgentId, group.UUID))// && PermissionsMngr.) { group.GrabMovement(offset, pos, remoteClient); } @@ -1235,7 +1233,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) { - if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObject(remoteClient.AgentId, group.UUID)) { group.SetPartName(Util.CleanString(name), primLocalID); } @@ -1252,7 +1250,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) { - if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + if (m_parentScene.Permissions.CanEditObject(remoteClient.AgentId, group.UUID)) { group.SetPartDescription(Util.CleanString(description), primLocalID); } @@ -1265,7 +1263,7 @@ namespace OpenSim.Region.Environment.Scenes if (group != null) { - if (PermissionsMngr.CanEditObject(agentID, group.UUID)) + if (m_parentScene.Permissions.CanEditObject(agentID, group.UUID)) { group.UpdateExtraParam(primLocalID, type, inUse, data); } @@ -1282,7 +1280,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) { - if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) + if (m_parentScene.Permissions.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) { group.UpdateShape(shapeBlock, primLocalID); } @@ -1448,11 +1446,11 @@ namespace OpenSim.Region.Environment.Scenes // * Asset/DRM permission bit "modify" is enabled //use CanEditObjectPosition - if (IncludeInSearch && PermissionsMngr.CanEditObject(user, objid)) + if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(user, objid)) { obj.AddFlag(LLObject.ObjectFlags.JointWheel); } - else if (!IncludeInSearch && PermissionsMngr.CanEditObjectPosition(user, objid)) + else if (!IncludeInSearch && m_parentScene.Permissions.CanEditObjectPosition(user, objid)) { obj.RemFlag(LLObject.ObjectFlags.JointWheel); } @@ -1485,7 +1483,7 @@ namespace OpenSim.Region.Environment.Scenes if (originPrim != null) { - if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID)) + if (m_parentScene.Permissions.CanCopyObject(AgentID, originPrim.UUID)) { SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID); copy.AbsolutePosition = copy.AbsolutePosition + offset; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index ee52a66945..65e6fd8a96 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemCreateUpdate(item); int userlevel = 0; - if (PermissionsMngr.IsEstateManager(remoteClient.AgentId)) + if (Permissions.IsEstateManager(remoteClient.AgentId)) { userlevel = 1; } @@ -784,7 +784,7 @@ namespace OpenSim.Region.Environment.Scenes } // bool permission; -// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, +// permission = Permissions.CanCopyObject(remoteClient.AgentId, // ((SceneObjectGroup) selectedEnt).UUID); // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner @@ -988,12 +988,12 @@ namespace OpenSim.Region.Environment.Scenes bool permission; if (DeRezPacket.AgentBlock.Destination == 1) { // Take Copy - permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, + permission = Permissions.CanCopyObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID); } else { // Take - permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId, + permission = Permissions.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID); } @@ -1267,7 +1267,7 @@ namespace OpenSim.Region.Environment.Scenes RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), BypassRayCast, bRayEndIsIntersection,true,scale, false); - if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) + if (!Permissions.CanRezObject(remoteClient.AgentId, pos) && !attachment) { return null; } @@ -1361,7 +1361,7 @@ namespace OpenSim.Region.Environment.Scenes { LLUUID ownerID = item.OwnerID; - if (!PermissionsMngr.CanRezObject(ownerID, pos)) + if (!Permissions.CanRezObject(ownerID, pos)) { return null; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index b4a581da1c..350990e52a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.Environment.Scenes if (((SceneObjectGroup) ent).LocalId == primLocalID) { // A prim is only tainted if it's allowed to be edited by the person clicking it. - if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) + if (Permissions.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || Permissions.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) { ((SceneObjectGroup) ent).GetProperties(remoteClient); ((SceneObjectGroup) ent).IsSelected = true; @@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment.Scenes { if (((SceneObjectGroup) ent).LocalId == primLocalID) { - if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) + if (Permissions.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || Permissions.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) { ((SceneObjectGroup) ent).IsSelected = false; LandChannel.setPrimsTainted(); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f861361d0d..a70362252b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -114,6 +114,7 @@ namespace OpenSim.Region.Environment.Scenes protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; + protected IScenePermissions m_permissions; // Central Update Loop @@ -169,13 +170,12 @@ namespace OpenSim.Region.Environment.Scenes get { return m_timedilation; } } - protected readonly PermissionManager m_permissionManager; - // This is the instance to the permissions manager. - // This manages permissions to clients on in world objects - - public PermissionManager PermissionsMngr + /// + /// The reference by which general permissions in the scene can be set and queried. + /// + public IScenePermissions Permissions { - get { return m_permissionManager; } + get { return m_permissions; } } public int TimePhase @@ -219,7 +219,7 @@ namespace OpenSim.Region.Environment.Scenes #region Constructors - public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, + public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor) @@ -248,10 +248,7 @@ namespace OpenSim.Region.Environment.Scenes EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); - m_permissionManager = permissionManager; - m_permissionManager.Initialise(this); - - m_innerScene = new InnerScene(this, m_regInfo, m_permissionManager); + m_innerScene = new InnerScene(this, m_regInfo); // If the Inner scene has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific @@ -613,6 +610,9 @@ namespace OpenSim.Region.Environment.Scenes m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); } + /// + /// Sets up references to loaded modules required by thie scene + /// public void SetModuleInterfaces() { m_simChatModule = RequestModuleInterface(); @@ -621,6 +621,7 @@ namespace OpenSim.Region.Environment.Scenes m_worldCommModule = RequestModuleInterface(); XferManager = RequestModuleInterface(); m_AvatarFactory = RequestModuleInterface(); + m_permissions = RequestModuleInterface(); } #endregion @@ -1121,7 +1122,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// Loads the World's objects /// - public virtual void LoadPrimsFromStorage(bool m_permissions, LLUUID regionID) + public virtual void LoadPrimsFromStorage(LLUUID regionID) { m_log.Info("[SCENE]: Loading objects from datastore"); @@ -1243,12 +1244,11 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false); - if (PermissionsMngr.CanRezObject(ownerID, pos)) + if (Permissions.CanRezObject(ownerID, pos)) { // rez ON the ground, not IN the ground pos.Z += 0.25F; - AddNewPrim(ownerID, pos, rot, shape); } } @@ -2499,7 +2499,7 @@ namespace OpenSim.Region.Environment.Scenes IClientAPI controllingClient) { // First check that this is the sim owner - if (m_permissionManager.GenericEstatePermission(agentID)) + if (Permissions.GenericEstatePermission(agentID)) { // User needs to be logged into this sim if (m_scenePresences.ContainsKey(agentID)) @@ -2577,7 +2577,7 @@ namespace OpenSim.Region.Environment.Scenes LLUUID kickUserID = new LLUUID("44e87126e7944ded05b37c42da3d5cdb"); if (m_scenePresences.ContainsKey(agentID) || agentID == kickUserID) { - if (m_permissionManager.GenericEstatePermission(godID)) + if (Permissions.GenericEstatePermission(godID)) { if (agentID == kickUserID) { @@ -2896,7 +2896,7 @@ namespace OpenSim.Region.Environment.Scenes } else if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0) { - if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || PermissionsMngr.GenericEstatePermission(part.OwnerID)) + if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || Permissions.GenericEstatePermission(part.OwnerID)) { return true; } diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 2dfea2ac0d..8603ccc13b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions) { - ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; }); + ForEachCurrentScene(delegate(Scene scene) { scene.Permissions.BypassPermissions = bypassPermissions; }); } private void ForEachCurrentScene(Action func) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 9ed5990762..2e44c541fc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1340,7 +1340,7 @@ namespace OpenSim.Region.Environment.Scenes if (part.OwnerID != cAgentID) { // Apply Next Owner Permissions if we're not bypassing permissions - if (!m_scene.PermissionsMngr.BypassPermissions) + if (!m_scene.Permissions.BypassPermissions) m_rootPart.ApplyNextOwnerPermissions(); } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 453c18fdfa..fcd93d8718 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -451,7 +451,7 @@ namespace OpenSim.Region.Environment.Scenes public uint GenerateClientFlags(LLUUID ObjectID) { - return m_scene.PermissionsMngr.GenerateClientFlags(m_uuid, ObjectID); + return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); } /// diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index ca94dd790f..54c26d9bc5 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -180,8 +180,8 @@ namespace OpenSim.Region.ScriptEngine.Common { m_host.AddScriptLPS(1); //Check to make sure that the script's owner is the estate manager/master - //World.PermissionsMngr.GenericEstatePermission( - if (World.PermissionsMngr.GenericEstatePermission(m_host.OwnerID)) + //World.Permissions.GenericEstatePermission( + if (World.Permissions.GenericEstatePermission(m_host.OwnerID)) { World.EventManager.TriggerRequestChangeWaterHeight((float)height); } @@ -2616,7 +2616,7 @@ namespace OpenSim.Region.ScriptEngine.Common public void llModifyLand(int action, int brush) { m_host.AddScriptLPS(1); - if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0))) + if (World.Permissions.CanTerraform(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0))) { NotImplemented("llModifyLand"); } @@ -3869,7 +3869,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (m_host.ObjectOwner == parcel.landData.ownerID || (m_host.OwnerID == m_host.GroupID && m_host.GroupID == parcel.landData.groupID - && parcel.landData.isGroupOwned) || World.PermissionsMngr.GenericEstatePermission(m_host.OwnerID)) + && parcel.landData.isGroupOwned) || World.Permissions.GenericEstatePermission(m_host.OwnerID)) { av.StandUp(); } diff --git a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs index 731168d792..ddca617f06 100644 --- a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs @@ -258,7 +258,7 @@ namespace OpenSim.Region.ScriptEngine.Common if (x > 255 || x < 0 || y > 255 || y < 0) LSLError("osTerrainSetHeight: Coordinate out of bounds"); - if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0))) + if (World.Permissions.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0))) { World.Heightmap[x, y] = val; return 1; @@ -281,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Common public int osRegionRestart(double seconds) { m_host.AddScriptLPS(1); - if (World.PermissionsMngr.CanRestartSim(m_host.OwnerID)) + if (World.Permissions.CanRestartSim(m_host.OwnerID)) { World.Restart((float)seconds); return 1; @@ -406,7 +406,7 @@ namespace OpenSim.Region.ScriptEngine.Common if (config.Configs["LL-Functions"].GetBoolean("AllowosConsoleCommand", false)) { - if (World.PermissionsMngr.CanRunConsoleCommand(m_host.OwnerID)) + if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { MainConsole.Instance.RunCommand(command); return true;