* [MRM] Implements permission checks on IObject implementations in SOPObject.cs. Does not implement security on IObjectInventory yet.

arthursv
Adam Frisby 2009-08-16 21:20:45 +10:00
parent 8b6d79aa3c
commit 975c49a399
3 changed files with 92 additions and 9 deletions

View File

@ -3,5 +3,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public interface ISecurityCredential public interface ISecurityCredential
{ {
ISocialEntity owner { get; } ISocialEntity owner { get; }
bool CanEditObject(IObject target);
bool CanEditTerrain(int x, int y);
} }
} }

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
@ -68,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
return m_rootScene.GetSceneObjectPart(m_localID); 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 #region OnTouch
private event OnTouchDelegate _OnTouch; private event OnTouchDelegate _OnTouch;
@ -139,13 +149,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public string Name public string Name
{ {
get { return GetSOP().Name; } get { return GetSOP().Name; }
set { GetSOP().Name = value; } set
{
if (CanEdit())
GetSOP().Name = value;
}
} }
public string Description public string Description
{ {
get { return GetSOP().Description; } get { return GetSOP().Description; }
set { GetSOP().Description = value; } set
{
if (CanEdit())
GetSOP().Description = value;
}
} }
public IObject[] Children public IObject[] Children
@ -169,7 +187,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public IObject Root 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 public IObjectMaterial[] Materials
@ -191,7 +209,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public Vector3 Scale public Vector3 Scale
{ {
get { return GetSOP().Scale; } get { return GetSOP().Scale; }
set { GetSOP().Scale = value; } set
{
if (CanEdit())
GetSOP().Scale = value;
}
} }
public Quaternion WorldRotation public Quaternion WorldRotation
@ -210,16 +232,25 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get { return GetSOP().AbsolutePosition; } get { return GetSOP().AbsolutePosition; }
set set
{
if (CanEdit())
{ {
SceneObjectPart pos = GetSOP(); SceneObjectPart pos = GetSOP();
pos.UpdateOffSet(value - pos.AbsolutePosition); pos.UpdateOffSet(value - pos.AbsolutePosition);
} }
} }
}
public Vector3 OffsetPosition public Vector3 OffsetPosition
{ {
get { return GetSOP().OffsetPosition; } get { return GetSOP().OffsetPosition; }
set { GetSOP().OffsetPosition = value; } set
{
if (CanEdit())
{
GetSOP().OffsetPosition = value;
}
}
} }
public Vector3 SitTarget public Vector3 SitTarget
@ -319,8 +350,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public void Say(string msg) 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); m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false);
} }
@ -512,6 +545,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
} }
set set
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z);
} }
} }
@ -525,6 +561,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
} }
set set
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
} }
} }
@ -538,6 +577,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
} }
set set
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z);
} }
} }
@ -560,27 +602,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
} }
set set
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z);
} }
} }
public bool FloatOnWater public bool FloatOnWater
{ {
set { GetSOP().PhysActor.FloatOnWater = value; } set
{
if (!CanEdit())
return;
GetSOP().PhysActor.FloatOnWater = value;
}
} }
public void AddForce(Vector3 force, bool pushforce) public void AddForce(Vector3 force, bool pushforce)
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
} }
public void AddAngularForce(Vector3 force, bool pushforce) public void AddAngularForce(Vector3 force, bool pushforce)
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
} }
public void SetMomentum(Vector3 momentum) public void SetMomentum(Vector3 momentum)
{ {
if (!CanEdit())
return;
GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); 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; } get { return m_sculptMap; }
set set
{ {
if (!CanEdit())
return;
m_sculptMap = value; m_sculptMap = value;
SetPrimitiveSculpted(SculptMap, (byte) SculptType); SetPrimitiveSculpted(SculptMap, (byte) SculptType);
} }
@ -607,6 +669,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return m_sculptType; } get { return m_sculptType; }
set set
{ {
if(!CanEdit())
return;
m_sculptType = value; m_sculptType = value;
SetPrimitiveSculpted(SculptMap, (byte) SculptType); SetPrimitiveSculpted(SculptMap, (byte) SculptType);
} }
@ -663,6 +728,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public void Play(UUID asset, double volume) public void Play(UUID asset, double volume)
{ {
if (!CanEdit())
return;
GetSOP().SendSound(asset.ToString(), volume, true, 0); GetSOP().SendSound(asset.ToString(), volume, true, 0);
} }

View File

@ -1,12 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenMetaverse;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
class SecurityCredential : ISecurityCredential class SecurityCredential : ISecurityCredential
{ {
private readonly ISocialEntity m_owner; private readonly ISocialEntity m_owner;
private readonly Scene m_scene;
public SecurityCredential(ISocialEntity m_owner) public SecurityCredential(ISocialEntity m_owner)
{ {
@ -17,5 +20,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get { return m_owner; } get { return m_owner; }
} }
public bool CanEditObject(IObject target)
{
return m_scene.Permissions.CanEditObject(target.GlobalID, m_owner.GlobalID);
}
public bool CanEditTerrain(int x, int y)
{
return m_scene.Permissions.CanTerraformLand(m_owner.GlobalID, new Vector3(x, y, 0));
}
} }
} }