From ae63b2d2caf39fa8db3bb877a8d78f3d394c8f5d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 15 Sep 2008 23:50:07 +0000 Subject: Finish up OSSL enable/disable options in XEngine. Now each function can be allowed, subject to threat level, disabled, or restricted to certain UUIDs. --- .../Shared/Api/Implementation/OSSL_Api.cs | 53 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9a01025..4da0076 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; internal float m_ScriptDelayFactor = 1.0f; internal float m_ScriptDistanceFactor = 1.0f; - internal Dictionary m_FunctionPerms = new Dictionary(); + internal Dictionary > m_FunctionPerms = new Dictionary >(); public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) { @@ -184,15 +184,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!m_FunctionPerms.ContainsKey(function)) { - m_FunctionPerms[function] = - m_ScriptEngine.Config.GetBoolean("Allow_"+function, true); - } + string perm = m_ScriptEngine.Config.GetString("Allow_"+function, "true"); + bool allowed; - if (!m_FunctionPerms[function]) - return; + if (bool.TryParse(perm, out allowed)) + { + // Boolean given + if(allowed) + m_FunctionPerms[function] = null; // a null value is all + else + m_FunctionPerms[function] = new List(); // Empty list = none + } + else + { + m_FunctionPerms[function] = new List(); + + string[] ids = perm.Split(new char[] {','}); + foreach (string id in ids) + { + string current = id.Trim(); + UUID uuid; + + if (UUID.TryParse(current, out uuid)) + { + m_FunctionPerms[function].Add(uuid); + } + } + } + } - if (level > m_MaxThreatLevel) - throw new Exception("Threat level too high - "+function); + // If the list is null, then the value was true / undefined + // Threat level governs permissions in this case + // + // If the list is non-null, then it is a list of UUIDs allowed + // to use that particular function. False causes an empty + // list and therefore means "no one" + // + if (m_FunctionPerms[function] == null) // No list = true + { + if (level > m_MaxThreatLevel) + throw new Exception("Threat level too high - "+function); + } + else + { + if (!m_FunctionPerms[function].Contains(m_host.OwnerID)) + throw new Exception("Threat level too high - "+function); + } } protected void ScriptSleep(int delay) -- cgit v1.1