From 6a279feb2fdd9f85876b6533fed1020fdbffc20a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Mar 2014 23:54:20 +0000 Subject: Only allow llBreakAllLinks() to work if script has received PERMISSION_CHANGE_LINKS As per http://wiki.secondlife.com/wiki/LlBreakAllLinks Same as existing llCreateLink() and llBreakLink() --- .../Shared/Api/Implementation/LSL_Api.cs | 8 +++++ .../Shared/Tests/LSL_ApiLinkingTests.cs | 42 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 45a7c96..abd8123 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3922,6 +3922,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llBreakAllLinks() { m_host.AddScriptLPS(1); + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + && !m_automaticLinkPermission) + { + Error("llBreakAllLinks", "PERMISSION_CHANGE_LINKS permission not set"); + return; + } + SceneObjectGroup parentPrim = m_host.ParentGroup; if (parentPrim.AttachmentPoint != 0) return; // Fail silently if attached diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index ac9f93b..4c5a501 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs @@ -141,5 +141,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); Assert.That(grp2, Is.Not.Null); } + + [Test] + public void TestllBreakAllLinks() + { + TestHelpers.InMethod(); + + UUID ownerId = TestHelpers.ParseTail(0x1); + + SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(3, ownerId, "grp1-", 0x10); + grp1.AbsolutePosition = new Vector3(10, 10, 10); + m_scene.AddSceneObject(grp1); + + // FIXME: This should really be a script item (with accompanying script) + TaskInventoryItem grp1Item + = TaskInventoryHelpers.AddNotecard( + m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + + grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; + + LSL_Api apiGrp1 = new LSL_Api(); + apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); + + apiGrp1.llBreakAllLinks(); + + { + SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part1"); + Assert.That(nowGrp, Is.Not.Null); + Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); + } + + { + SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part2"); + Assert.That(nowGrp, Is.Not.Null); + Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); + } + + { + SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part3"); + Assert.That(nowGrp, Is.Not.Null); + Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); + } + } } } \ No newline at end of file -- cgit v1.1