Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

This commit is contained in:
Justin Clark-Casey (justincc)
2013-01-15 00:24:51 +00:00
30 changed files with 559 additions and 251 deletions

View File

@@ -245,11 +245,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
}
// Returns of the function is allowed. Throws a script exception if not allowed.
public void CheckThreatLevel(ThreatLevel level, string function)
{
if (!m_OSFunctionsEnabled)
OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws
string reasonWhyNot = CheckThreatLevelTest(level, function);
if (!String.IsNullOrEmpty(reasonWhyNot))
{
OSSLError(reasonWhyNot);
}
}
// Check to see if function is allowed. Returns an empty string if function permitted
// or a string explaining why this function can't be used.
private string CheckThreatLevelTest(ThreatLevel level, string function)
{
if (!m_FunctionPerms.ContainsKey(function))
{
FunctionPerms perms = new FunctionPerms();
@@ -329,10 +341,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
// Allow / disallow by threat level
if (level > m_MaxThreatLevel)
OSSLError(
return
String.Format(
"{0} permission denied. Allowed threat level is {1} but function threat level is {2}.",
function, m_MaxThreatLevel, level));
function, m_MaxThreatLevel, level);
}
else
{
@@ -342,7 +354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID))
{
// prim owner is in the list of allowed owners
return;
return String.Empty;
}
UUID ownerID = m_item.OwnerID;
@@ -354,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
{
return;
return String.Empty;
}
}
@@ -365,7 +377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (land.LandData.OwnerID == ownerID)
{
return;
return String.Empty;
}
}
@@ -375,7 +387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Only Estate Managers may use the function
if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
{
return;
return String.Empty;
}
}
@@ -384,25 +396,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (World.RegionInfo.EstateSettings.EstateOwner == ownerID)
{
return;
return String.Empty;
}
}
if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
OSSLError(
return(
String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
function));
if (m_item.CreatorID != ownerID)
{
if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
OSSLError(
String.Format("{0} permission denied. Script permissions error.",
function));
return String.Format("{0} permission denied. Script permissions error.", function);
}
}
}
return String.Empty;
}
internal void OSSLDeprecated(string function, string replacement)
@@ -1558,6 +1569,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
public string osGetPhysicsEngineType()
{
// High because it can be used to target attacks to known weaknesses
// This would allow a new class of griefer scripts that don't even
// require their user to know what they are doing (see script
// kiddie)
// Because it would be nice if scripts didn't blow up if the information
// about the physics engine, this function returns an empty string if
// the user does not have permission to see it. This as opposed to
// throwing an exception.
m_host.AddScriptLPS(1);
string ret = String.Empty;
if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType")))
{
if (m_ScriptEngine.World.PhysicsScene != null)
{
ret = m_ScriptEngine.World.PhysicsScene.EngineType;
// An old physics engine might have an uninitialized engine type
if (ret == null)
ret = "unknown";
}
}
return ret;
}
public string osGetSimulatorVersion()
{
// High because it can be used to target attacks to known weaknesses

View File

@@ -259,6 +259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osGetScriptEngineName();
string osGetSimulatorVersion();
string osGetPhysicsEngineType();
Object osParseJSONNew(string JSON);
Hashtable osParseJSON(string JSON);

View File

@@ -420,6 +420,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetScriptEngineName();
}
public string osGetPhysicsEngineType()
{
return m_OSSL_Functions.osGetPhysicsEngineType();
}
public string osGetSimulatorVersion()
{
return m_OSSL_Functions.osGetSimulatorVersion();