From 9090a907692e7deaafd79150bf6482507be86d55 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 03:48:16 +1000 Subject: * Beginnings of a Security Credential system in MRM. This will eventually lead to trusted execution of untrusted MRMs. --- .../Scripting/Minimodule/ISecurityCredential.cs | 7 +++++++ .../Scripting/Minimodule/MRMModule.cs | 10 ++++++++-- .../Scripting/Minimodule/ObjectAccessor.cs | 22 +++++++++++++--------- .../Scripting/Minimodule/SOPObject.cs | 9 +++++++++ .../Scripting/Minimodule/SecurityCredential.cs | 21 +++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 6 ++++-- 6 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs new file mode 100644 index 0000000..464723e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs @@ -0,0 +1,7 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface ISecurityCredential + { + ISocialEntity owner { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 5ed9af3..0cc7930 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -166,8 +166,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) { - world = new World(m_scene); - host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), m_microthreads); + // UUID should be changed to object owner. + UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; + SEUser securityUser = new SEUser(owner, "Name Unassigned"); + SecurityCredential creds = new SecurityCredential(securityUser); + + world = new World(m_scene, creds); + host = new Host(new SOPObject(m_scene, localID, creds), m_scene, new ExtensionHandler(m_extensions), + m_microthreads); } public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 4638ad0..6ba5ccf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -40,10 +40,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_scene; private readonly IEnumerator m_sogEnum; + private readonly ISecurityCredential m_security; - public IObjEnum(Scene scene) + public IObjEnum(Scene scene, ISecurityCredential security) { m_scene = scene; + m_security = security; m_sogEnum = m_scene.Entities.GetAllByType().GetEnumerator(); } @@ -66,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_sogEnum.Current.LocalId); + return new SOPObject(m_scene, m_sogEnum.Current.LocalId, m_security); } } @@ -79,17 +81,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor { private readonly Scene m_scene; + private readonly ISecurityCredential m_security; - public ObjectAccessor(Scene scene) + public ObjectAccessor(Scene scene, ISecurityCredential security) { m_scene = scene; + m_security = security; } public IObject this[int index] { get { - return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId, m_security); } } @@ -97,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); } } @@ -105,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); } } @@ -117,20 +121,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObject Create(Vector3 position, Quaternion rotation) { - SceneObjectGroup sog = m_scene.AddNewPrim(m_scene.RegionInfo.MasterAvatarAssignedUUID, + SceneObjectGroup sog = m_scene.AddNewPrim(m_security.owner.GlobalID, UUID.Zero, position, rotation, PrimitiveBaseShape.CreateBox()); - IObject ret = new SOPObject(m_scene, sog.LocalId); + IObject ret = new SOPObject(m_scene, sog.LocalId, m_security); return ret; } public IEnumerator GetEnumerator() { - return new IObjEnum(m_scene); + return new IObjEnum(m_scene, m_security); } IEnumerator IEnumerable.GetEnumerator() diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index bc26389..fa9ef53 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -42,13 +42,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_rootScene; private readonly uint m_localID; + private readonly ISecurityCredential m_security; + [Obsolete("Replace with 'credential' constructor [security]")] public SOPObject(Scene rootScene, uint localID) { m_rootScene = rootScene; m_localID = localID; } + public SOPObject(Scene rootScene, uint localID, ISecurityCredential credential) + { + m_rootScene = rootScene; + m_localID = localID; + m_security = credential; + } + /// /// This needs to run very, very quickly. /// It is utilized in nearly every property and method. diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs new file mode 100644 index 0000000..bd4440c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SecurityCredential : ISecurityCredential + { + private readonly ISocialEntity m_owner; + + public SecurityCredential(ISocialEntity m_owner) + { + this.m_owner = m_owner; + } + + public ISocialEntity owner + { + get { return m_owner; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 1ec4a33..a34684f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -37,15 +37,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class World : System.MarshalByRefObject, IWorld, IWorldAudio { private readonly Scene m_internalScene; + private readonly ISecurityCredential m_security; private readonly Heightmap m_heights; private readonly ObjectAccessor m_objs; - public World(Scene internalScene) + public World(Scene internalScene, ISecurityCredential securityCredential) { + m_security = securityCredential; m_internalScene = internalScene; m_heights = new Heightmap(m_internalScene); - m_objs = new ObjectAccessor(m_internalScene); + m_objs = new ObjectAccessor(m_internalScene, securityCredential); } #region Events -- cgit v1.1