From 7223b63563f28f6fe8044bdabcd1b9900d28c54a Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Tue, 27 Mar 2012 22:09:58 +0200 Subject: User level based restrictions for HyperGrid teleports, asset uploads, group creations and getting contacted from other grids. Incoming HyperGrid teleports can also be restricted to local users. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 34 +++++++++++++---- .../NewFileAgentInventoryVariablePriceModule.cs | 44 +++++++++++++++------- .../AssetTransaction/AssetTransactionModule.cs | 22 ++++++++++- .../EntityTransfer/EntityTransferModule.cs | 15 ++++++++ .../Avatar/XmlRpcGroups/GroupsModule.cs | 22 ++++++++++- .../Shared/Api/Implementation/LSL_Api.cs | 3 ++ 6 files changed, 117 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ed3430a..8ec2f20 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -111,6 +111,7 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_assetService; private bool m_dumpAssetsToFile = false; private string m_regionName; + private int m_levelUpload = 0; public BunchOfCaps(Scene scene, Caps caps) { @@ -121,7 +122,10 @@ namespace OpenSim.Region.ClientStack.Linden { IConfig sconfig = config.Configs["Startup"]; if (sconfig != null) + { m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); + m_levelUpload = sconfig.GetInt("LevelUpload", 0); + } } m_assetService = m_Scene.AssetService; @@ -357,21 +361,37 @@ namespace OpenSim.Region.ClientStack.Linden llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { + ScenePresence avatar = null; IClientAPI client = null; - IScene scene = null; - if (GetClient != null) + m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); + + // check user level + if (avatar != null) { - client = GetClient(m_HostCapsObj.AgentID); - scene = client.Scene; + client = avatar.ControllingClient; + + if (avatar.UserLevel < m_levelUpload) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); - IMoneyModule mm = scene.RequestModuleInterface(); + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // check funds + if (client != null) + { + IMoneyModule mm = m_Scene.RequestModuleInterface(); if (mm != null) { if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 1117f2a..91872c5 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.ClientStack.Linden // private IAssetService m_assetService; private bool m_dumpAssetsToFile = false; private bool m_enabled = true; + private int m_levelUpload = 0; #region IRegionModuleBase Members @@ -72,6 +73,7 @@ namespace OpenSim.Region.ClientStack.Linden return; m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); + m_levelUpload = meshConfig.GetInt("LevelUpload", 0); } public void AddRegion(Scene pScene) @@ -137,25 +139,41 @@ namespace OpenSim.Region.ClientStack.Linden // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") // { + // check user level + ScenePresence avatar = null; IClientAPI client = null; + m_scene.TryGetScenePresence(agentID, out avatar); - + if (avatar != null) + { + client = avatar.ControllingClient; + + if (avatar.UserLevel < m_levelUpload) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // check funds IMoneyModule mm = m_scene.RequestModuleInterface(); - + if (mm != null) { - if (m_scene.TryGetClient(agentID, out client)) + if (!mm.UploadCovered(agentID, mm.UploadCharge)) { - if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; } } // } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 95e3aec..874693e 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -47,6 +47,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction protected Scene m_Scene; private bool m_dumpAssetsToFile = false; + private int m_levelUpload = 0; /// /// Each agent has its own singleton collection of transactions @@ -56,8 +57,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction #region IRegionModule Members - public void Initialise(IConfigSource config) + public void Initialise(IConfigSource source) { + IConfig sconfig = source.Configs["Startup"]; + if (sconfig != null) + { + m_levelUpload = sconfig.GetInt("LevelUpload", 0); + } } public void AddRegion(Scene scene) @@ -241,7 +247,21 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction (AssetType)type == AssetType.Animation) && tempFile == false) { + ScenePresence avatar = null; Scene scene = (Scene)remoteClient.Scene; + scene.TryGetScenePresence(remoteClient.AgentId, out avatar); + + // check user level + if (avatar != null) + { + if (avatar.UserLevel < m_levelUpload) + { + remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + return; + } + } + + // check funds IMoneyModule mm = scene.RequestModuleInterface(); if (mm != null) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 2d73594..427a49d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -60,6 +60,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer set { m_MaxTransferDistance = value; } } + private int m_levelHGTeleport = 0; + protected bool m_Enabled = false; protected Scene m_aScene; protected List m_Scenes = new List(); @@ -101,7 +103,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { IConfig transferConfig = source.Configs["EntityTransfer"]; if (transferConfig != null) + { MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); + m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); + } m_agentsInTransit = new List(); m_Enabled = true; @@ -227,6 +232,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } + // check if HyperGrid teleport is allowed, based on user level + int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID); + + if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport)) + { + m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); + sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted"); + return; + } + uint curX = 0, curY = 0; Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); int curCellX = (int)(curX / Constants.RegionSize); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index b60cd42..ea5d805 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -84,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private bool m_groupsEnabled = false; private bool m_groupNoticesEnabled = true; private bool m_debugEnabled = false; + private int m_levelGroupCreate = 0; #region IRegionModuleBase Members @@ -115,6 +116,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", false); + m_levelGroupCreate = groupsConfig.GetInt("LevelGroupCreate", 0); } } @@ -708,13 +710,29 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); return UUID.Zero; } + + // check user level + ScenePresence avatar = null; + Scene scene = (Scene)remoteClient.Scene; + scene.TryGetScenePresence(remoteClient.AgentId, out avatar); + + if (avatar != null) + { + if (avatar.UserLevel < m_levelGroupCreate) + { + remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got insufficient permissions to create a group."); + return UUID.Zero; + } + } + + // check funds // is there is a money module present ? - IMoneyModule money = remoteClient.Scene.RequestModuleInterface(); + IMoneyModule money = scene.RequestModuleInterface(); if (money != null) { // do the transaction, that is if the agent has got sufficient funds if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) { - remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); + remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got insufficient funds to create a group."); return UUID.Zero; } money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, "Group Creation"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d7a629b..7455929 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4151,6 +4151,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case 4: // DATA_RATING (0,0,0,0,0,0) reply = "0,0,0,0,0,0"; break; + case 7: // DATA_USERLEVEL (integer) + reply = account.UserLevel.ToString(); + break; case 8: // DATA_PAYINFO (0|1|2|3) reply = "0"; break; -- cgit v1.1