Change the semantics of the Allow_* os function control. Omitting a function

causes defautlt behavior. "true" now means usable unconditionally, "false"
means disabled, and a list of UUIDs restricts it.
This changes SECURITY! If you used "true" here before, you shoudl review
your setup!
0.6.1-post-fixes
Melanie Thielker 2008-11-17 04:23:03 +00:00
parent 840ef17b8d
commit 928d003bf5
2 changed files with 37 additions and 20 deletions

View File

@ -187,30 +187,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_FunctionPerms.ContainsKey(function))
{
string perm = m_ScriptEngine.Config.GetString("Allow_"+function, "true");
bool allowed;
if (bool.TryParse(perm, out allowed))
string perm = m_ScriptEngine.Config.GetString("Allow_"+function, "");
if (perm == "")
{
// Boolean given
if (allowed)
m_FunctionPerms[function] = null; // a null value is all
else
m_FunctionPerms[function] = new List<UUID>(); // Empty list = none
m_FunctionPerms[function] = null; // a null value is default
}
else
{
m_FunctionPerms[function] = new List<UUID>();
bool allowed;
string[] ids = perm.Split(new char[] {','});
foreach (string id in ids)
if (bool.TryParse(perm, out allowed))
{
string current = id.Trim();
UUID uuid;
if (UUID.TryParse(current, out uuid))
// Boolean given
if (allowed)
{
m_FunctionPerms[function].Add(uuid);
m_FunctionPerms[function] = new List<UUID>();
m_FunctionPerms[function].Add(UUID.Zero);
}
else
m_FunctionPerms[function] = new List<UUID>(); // Empty list = none
}
else
{
m_FunctionPerms[function] = new List<UUID>();
string[] ids = perm.Split(new char[] {','});
foreach (string id in ids)
{
string current = id.Trim();
UUID uuid;
if (UUID.TryParse(current, out uuid))
{
if (uuid != uuid.Zero)
m_FunctionPerms[function].Add(uuid);
}
}
}
}
@ -223,6 +234,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// to use that particular function. False causes an empty
// list and therefore means "no one"
//
// To allow use by anyone, the list contains UUID.Zero
//
if (m_FunctionPerms[function] == null) // No list = true
{
if (level > m_MaxThreatLevel)
@ -230,8 +243,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
if (!m_FunctionPerms[function].Contains(m_host.OwnerID))
throw new Exception("Threat level too high - "+function);
if (!m_FunctionPerms[function].Contains(UUID.Zero))
{
if (!m_FunctionPerms[function].Contains(m_host.OwnerID))
throw new Exception("Threat level too high - "+function);
}
}
}

View File

@ -835,8 +835,9 @@
; OS Functions enable/disable
; For each function, you can add one line, as shown
; The default for all functions allows them if below threat level
; true is the default for all functions, and allows them if below threat level
; true allows the use of the function unconditionally
; Allow_osSetRegionWaterHeight = true
; false disables the function completely