From 975c49a399d2822b93496d7abea8587c9f8c7af4 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:20:45 +1000 Subject: * [MRM] Implements permission checks on IObject implementations in SOPObject.cs. Does not implement security on IObjectInventory yet. --- .../Scripting/Minimodule/SOPObject.cs | 86 +++++++++++++++++++--- 1 file changed, 77 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index fa9ef53..674c9e0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Security; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; @@ -68,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return m_rootScene.GetSceneObjectPart(m_localID); } + private bool CanEdit() + { + if(!m_security.CanEditObject(this)) + { + throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); + } + return true; + } + #region OnTouch private event OnTouchDelegate _OnTouch; @@ -139,13 +149,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public string Name { get { return GetSOP().Name; } - set { GetSOP().Name = value; } + set + { + if (CanEdit()) + GetSOP().Name = value; + } } public string Description { get { return GetSOP().Description; } - set { GetSOP().Description = value; } + set + { + if (CanEdit()) + GetSOP().Description = value; + } } public IObject[] Children @@ -169,7 +187,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObject Root { - get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } + get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); } } public IObjectMaterial[] Materials @@ -191,7 +209,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 Scale { get { return GetSOP().Scale; } - set { GetSOP().Scale = value; } + set + { + if (CanEdit()) + GetSOP().Scale = value; + } } public Quaternion WorldRotation @@ -211,15 +233,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return GetSOP().AbsolutePosition; } set { - SceneObjectPart pos = GetSOP(); - pos.UpdateOffSet(value - pos.AbsolutePosition); + if (CanEdit()) + { + SceneObjectPart pos = GetSOP(); + pos.UpdateOffSet(value - pos.AbsolutePosition); + } } } public Vector3 OffsetPosition { get { return GetSOP().OffsetPosition; } - set { GetSOP().OffsetPosition = value; } + set + { + if (CanEdit()) + { + GetSOP().OffsetPosition = value; + } + } } public Vector3 SitTarget @@ -319,8 +350,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void Say(string msg) { - SceneObjectPart sop = GetSOP(); + if (!CanEdit()) + return; + SceneObjectPart sop = GetSOP(); m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); } @@ -512,6 +545,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -525,6 +561,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -538,6 +577,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -560,27 +602,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); } } public bool FloatOnWater { - set { GetSOP().PhysActor.FloatOnWater = value; } + set + { + if (!CanEdit()) + return; + GetSOP().PhysActor.FloatOnWater = value; + } } public void AddForce(Vector3 force, bool pushforce) { + if (!CanEdit()) + return; + GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void AddAngularForce(Vector3 force, bool pushforce) { + if (!CanEdit()) + return; + GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void SetMomentum(Vector3 momentum) { + if (!CanEdit()) + return; + GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); } @@ -595,6 +654,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_sculptMap; } set { + if (!CanEdit()) + return; + m_sculptMap = value; SetPrimitiveSculpted(SculptMap, (byte) SculptType); } @@ -607,6 +669,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_sculptType; } set { + if(!CanEdit()) + return; + m_sculptType = value; SetPrimitiveSculpted(SculptMap, (byte) SculptType); } @@ -663,6 +728,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void Play(UUID asset, double volume) { + if (!CanEdit()) + return; + GetSOP().SendSound(asset.ToString(), volume, true, 0); } -- cgit v1.1