From 9f932a42057b4a9cd4517c90007a7c31c98277c6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 5 Jun 2009 09:47:42 +0000 Subject: Thank you, thomax, for a patch to provide finer-grained access control to scripting. Fixes Mantis #2862 --- .../World/Permissions/PermissionsModule.cs | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 6b46176..9298380 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -87,6 +87,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions /// permissions are not being bypassed. This overrides normal permissions.- /// private UserSet m_allowedScriptEditors = UserSet.All; + + private Dictionary GrantLSL = new Dictionary(); + private Dictionary GrantCS = new Dictionary(); + private Dictionary GrantVB = new Dictionary(); + private Dictionary GrantJS = new Dictionary(); #endregion @@ -143,6 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED + m_scene.Permissions.OnCompileScript += CanCompileScript; m_scene.Permissions.OnSellParcel += CanSellParcel; m_scene.Permissions.OnTakeObject += CanTakeObject; m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; @@ -184,6 +190,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions "debug permissions ", "Enable permissions debugging", HandleDebugPermissions); + + + string grant = myConfig.GetString("GrantLSL",""); + if(grant.Length > 0) { + foreach (string uuidl in grant.Split(',')) { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantLSL.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantCS",""); + if(grant.Length > 0) { + foreach (string uuidl in grant.Split(',')) { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantCS.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantVB",""); + if(grant.Length > 0) { + foreach (string uuidl in grant.Split(',')) { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantVB.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantJS",""); + if(grant.Length > 0) { + foreach (string uuidl in grant.Split(',')) { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantJS.Add(uuid, true); + } + } + } public void HandleBypassPermissions(string module, string[] args) @@ -1584,5 +1624,34 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericParcelPermission(client.AgentId, parcel); } + + private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { + //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); + switch(scriptType) { + case 0: + if(GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) { + return(true); + } + break; + case 1: + if(GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) { + return(true); + } + break; + case 2: + if(GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) { + return(true); + } + break; + case 3: + if(GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString())) { + return(true); + } + break; + } + return(false); + } + + } } -- cgit v1.1