From eacc2561d14dbe9cba6966e3b32bfd776e044f8a Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Thu, 10 Jan 2013 17:03:19 -0800
Subject: BulletSim: add osGetPhysicsEngineType() LSL function and update the
physics engines to return the name that is specified in the INI file
("physics = XXX") as the type of engine. This os function is a little
different than the others in that it does not throw an exception of one is
not privilaged to use it. It merely returns an empty string.
---
.../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 2 +-
.../BasicPhysicsPlugin/BasicPhysicsScene.cs | 4 +-
OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs | 2 +-
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 9 +++-
OpenSim/Region/Physics/Manager/PhysicsScene.cs | 11 +++-
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +-
OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 3 +-
OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 2 +-
OpenSim/Region/Physics/POSPlugin/POSScene.cs | 4 +-
.../Shared/Api/Implementation/OSSL_Api.cs | 59 ++++++++++++++++++----
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ++
12 files changed, 82 insertions(+), 22 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 7ab2a03..373c7e0 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public PhysicsScene GetScene(string sceneIdentifier)
{
- return new BasicScene(sceneIdentifier);
+ return new BasicScene(GetName(), sceneIdentifier);
}
public string GetName()
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index f5826ed..c4b9117 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -49,8 +49,10 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
//protected internal string sceneIdentifier;
- public BasicScene(string _sceneIdentifier)
+ public BasicScene(string engineType, string _sceneIdentifier)
{
+ EngineType = engineType;
+ Name = EngineType + "/" + _sceneIdentifier;
//sceneIdentifier = _sceneIdentifier;
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs
index 65be52a..9442854 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs
@@ -59,7 +59,7 @@ public class BSPlugin : IPhysicsPlugin
{
if (_mScene == null)
{
- _mScene = new BSScene(sceneIdentifier);
+ _mScene = new BSScene(GetName(), sceneIdentifier);
}
return (_mScene);
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 4a6cebd..a5bdc07 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -167,11 +167,16 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
public bool VehiclePhysicalLoggingEnabled { get; private set; }
#region Construction and Initialization
- public BSScene(string identifier)
+ public BSScene(string engineType, string identifier)
{
m_initialized = false;
- // we are passed the name of the region we're working for.
+
+ // The name of the region we're working for is passed to us. Keep for identification.
RegionName = identifier;
+
+ // Set identifying variables in the PhysicsScene interface.
+ EngineType = engineType;
+ Name = EngineType + "/" + RegionName;
}
public override void Initialise(IMesher meshmerizer, IConfigSource config)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 488900e..201007b 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -62,13 +62,20 @@ namespace OpenSim.Region.Physics.Manager
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
- /// Name of this scene. Useful in debug messages to distinguish one OdeScene instance from another.
+ /// A unique identifying string for this instance of the physics engine.
+ /// Useful in debug messages to distinguish one OdeScene instance from another.
+ /// Usually set to include the region name that the physics engine is acting for.
///
public string Name { get; protected set; }
+ ///
+ /// A string identifying the family of this physics engine. Most common values returned
+ /// are "OpenDynamicsEngine" and "BulletSim" but others are possible.
+ ///
+ public string EngineType { get; protected set; }
+
// The only thing that should register for this event is the SceneGraph
// Anything else could cause problems.
-
public event physicsCrash OnPhysicsCrash;
public static PhysicsScene Null
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 478dd95..07663b3 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// http://opensimulator.org/mantis/view.php?id=2750).
d.InitODE();
- m_scene = new OdeScene(sceneIdentifier);
+ m_scene = new OdeScene(GetName(), sceneIdentifier);
}
return m_scene;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index d53bd90..02a0b15 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -526,11 +526,12 @@ namespace OpenSim.Region.Physics.OdePlugin
/// These settings need to be tweaked 'exactly' right or weird stuff happens.
///
/// Name of the scene. Useful in debug messages.
- public OdeScene(string name)
+ public OdeScene(string engineType, string name)
{
m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
Name = name;
+ EngineType = engineType;
nearCallback = near;
triCallback = TriCallback;
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index e6b42e6..ed086dd 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Physics.POSPlugin
public PhysicsScene GetScene(string sceneIdentifier)
{
- return new POSScene(sceneIdentifier);
+ return new POSScene(GetName(), sceneIdentifier);
}
public string GetName()
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
index 2f24a50..d30d482 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
@@ -43,8 +43,10 @@ namespace OpenSim.Region.Physics.POSPlugin
//protected internal string sceneIdentifier;
- public POSScene(String _sceneIdentifier)
+ public POSScene(string engineType, String _sceneIdentifier)
{
+ EngineType = engineType;
+ Name = EngineType + "/" + _sceneIdentifier;
//sceneIdentifier = _sceneIdentifier;
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 33c02ef..958a448 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -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
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index cdd9ea8..51d0581 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -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);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index afa9ae0..c9902e4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -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();
--
cgit v1.1