From 8fb0dccffaa2fd3a5a216a93e92844aaa4473f40 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 16 Oct 2014 03:46:45 +0200 Subject: [PATCH 1/7] Fix transferring inventory from prims to agent inventory --- .../Region/Framework/Scenes/Scene.Inventory.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 542d454629..f07de9ca98 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1226,16 +1226,21 @@ namespace OpenSim.Region.Framework.Scenes agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); if (taskItem.InvType == (int)InventoryType.Object) { - uint perms = taskItem.CurrentPermissions; + // Bake the new base permissions from folded permissions + // The folded perms are in the lowest 3 bits of the current perms + // We use base permissions here to avoid baking the "Locked" status + // into the item as it is passed. + uint perms = taskItem.BasePermissions & taskItem.NextPermissions; PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); + // Avoid the "lock trap" - move must always be enabled but the above may remove it + // Add it back here. agentItem.BasePermissions = perms | (uint)PermissionMask.Move; - agentItem.CurrentPermissions = agentItem.BasePermissions; - } - else - { - agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; + // Newly given items cannot be "locked" on rez. Make sure by + // setting current equal to base. } + agentItem.CurrentPermissions = agentItem.BasePermissions; + agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); From ddda314f14b678bc4629836002f0f32be93453e9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 16 Oct 2014 19:54:40 +0100 Subject: [PATCH 2/7] Add some more llGiveInventory() regression tests --- .../Shared/Tests/LSL_ApiInventoryTests.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index 6dd6c170b7..37caa5dc12 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs @@ -45,6 +45,7 @@ using OpenSim.Region.ScriptEngine.Shared.Instance; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.ScriptEngine.Shared.Tests { @@ -167,5 +168,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); } } + + /// + /// Test giving inventory from an object to an avatar that is not the object's owner. + /// + [Test] + public void TestLlGiveInventoryO2DifferentAvatar() + { + TestHelpers.InMethod(); + // TestHelpers.EnableLogging(); + + UUID user1Id = TestHelpers.ParseTail(0x1); + UUID user2Id = TestHelpers.ParseTail(0x2); + string inventoryItemName = "item1"; + + SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); + m_scene.AddSceneObject(so1); + LSL_Api api = new LSL_Api(); + api.Initialize(m_engine, so1.RootPart, null, null); + + // Create an object embedded inside the first + UUID itemId = TestHelpers.ParseTail(0x20); + TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); + + UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); + + api.llGiveInventory(user2Id.ToString(), inventoryItemName); + + InventoryItemBase receivedItem + = UserInventoryHelpers.GetInventoryItem( + m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); + + Assert.IsNotNull(receivedItem); + } + + /// + /// Test giving inventory from an object to an avatar that is not the object's owner and where the next + /// permissions do not include mod. + /// + [Test] + public void TestLlGiveInventoryO2DifferentAvatarNoMod() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID user1Id = TestHelpers.ParseTail(0x1); + UUID user2Id = TestHelpers.ParseTail(0x2); + string inventoryItemName = "item1"; + + SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); + m_scene.AddSceneObject(so1); + LSL_Api api = new LSL_Api(); + api.Initialize(m_engine, so1.RootPart, null, null); + + // Create an object embedded inside the first + UUID itemId = TestHelpers.ParseTail(0x20); + TaskInventoryItem tii + = TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); + tii.NextPermissions &= ~((uint)PermissionMask.Modify); + + UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); + + api.llGiveInventory(user2Id.ToString(), inventoryItemName); + + InventoryItemBase receivedItem + = UserInventoryHelpers.GetInventoryItem( + m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); + + Assert.IsNotNull(receivedItem); + Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify); + } } } \ No newline at end of file From 10ed3a5520232e29f500937cf452a65a30a811b2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Thu, 16 Oct 2014 20:22:43 +0100 Subject: [PATCH 3/7] Change 0.8 post fixes to 0.8.0.2 release --- OpenSim/Framework/Servers/VersionInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index f6b99dc20a..c6cc6dd5e4 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,8 +29,8 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.8.0.1"; - private const Flavour VERSION_FLAVOUR = Flavour.Post_Fixes; + private const string VERSION_NUMBER = "0.8.0.2"; + private const Flavour VERSION_FLAVOUR = Flavour.Release; public enum Flavour { From 3879f9a0815c84c7287d34feae1272536c443f98 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Thu, 16 Oct 2014 21:10:02 +0100 Subject: [PATCH 4/7] Change 0.8-post-fixes branch back to Post-Fixes flavour --- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index c6cc6dd5e4..efbe0db3d1 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -30,7 +30,7 @@ namespace OpenSim public class VersionInfo { private const string VERSION_NUMBER = "0.8.0.2"; - private const Flavour VERSION_FLAVOUR = Flavour.Release; + private const Flavour VERSION_FLAVOUR = Flavour.Post_Fixes; public enum Flavour { From c9f494c00e97cca24bc4fd264ece1fc3382bb96b Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 8 Aug 2014 16:44:22 -0400 Subject: [PATCH 5/7] Added RestrictEmail to make llEmail only send to avatars email address if true. --- .../Shared/Api/Implementation/LSL_Api.cs | 34 +++++++++++++++++++ bin/OpenSimDefaults.ini | 5 +++ 2 files changed, 39 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 991107ea46..0e6e8bbd71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -120,6 +120,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IUrlModule m_UrlModule = null; protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. + protected string m_internalObjectHost = "lsl.opensim.local"; + protected bool m_restrictEmail = false; protected ISoundModule m_SoundModule = null; //An array of HTTP/1.1 headers that are not allowed to be used @@ -193,11 +195,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (seConfigSource != null) { + IConfig lslConfig = seConfigSource.Configs["LL-Functions"]; + if (lslConfig != null) + { + m_restrictEmail = lslConfig.GetBoolean("RestrictEmail", m_restrictEmail); + } + IConfig smtpConfig = seConfigSource.Configs["SMTP"]; if (smtpConfig != null) { // there's an smtp config, so load in the snooze time. EMAIL_PAUSE_TIME = smtpConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); + + m_internalObjectHost = smtpConfig.GetString("internal_object_host", m_internalObjectHost); } } } @@ -3387,6 +3397,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + //Restrict email destination to the avatars registered email address? + //The restriction only applies if the destination address is not local. + if (m_restrictEmail == true && address.Contains(m_internalObjectHost) == false) + { + UserAccount account = + World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + m_host.OwnerID); + + if (account == null) + { + Error("llEmail", "Can't find user account for '" + m_host.OwnerID.ToString() + "'"); + return; + } + + if (String.IsNullOrEmpty(account.Email)) + { + Error("llEmail", "User account has not registered an email address."); + return; + } + + address = account.Email; + } + emailModule.SendEmail(m_host.UUID, address, subject, message); ScriptSleep(EMAIL_PAUSE_TIME * 1000); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 180d1f3b53..bfc9e9393d 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1318,6 +1318,11 @@ ; If false then gods cannot execute these functions either. AllowGodFunctions = false + ; Restrict the email address used by llEmail to the address associated with the avatars user account? + ; If true then llEmail will only send email to the address in the user account of the avatar who owns the object containing the script. + ; If false then email may be sent to any valid email address. + RestrictEmail = false + ; Maximum number of llListen events we allow over the entire region. ; Set this to 0 to have no limit imposed max_listens_per_region = 1000 From bd86ae3d67cdca9060704cee3d436af7d147e0d7 Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Mon, 18 Aug 2014 16:00:49 -0400 Subject: [PATCH 6/7] Prevent exception if inventory item in llGiveInventory() call doesn't exist. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0e6e8bbd71..50e4804ef0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4138,6 +4138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (item == null) { Error("llGiveInventory", "Can't find inventory object '" + inventory + "'"); + return; } UUID objId = item.ItemID; From f9ec08656594bfda6a5c510ef8be7a3fe047f86e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Tue, 11 Nov 2014 17:27:02 +0000 Subject: [PATCH 7/7] Fix issue where llRemoteLoadScriptPin() would treat 0 (the default) as a valid set pin in a destination prim rather than the unset no pin state Adds regression test for this case. --- .../Framework/Scenes/Scene.Inventory.cs | 20 ++++---- .../Shared/Tests/LSL_ApiInventoryTests.cs | 48 +++++++++++++++++++ 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f07de9ca98..00800d6824 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1939,8 +1939,11 @@ namespace OpenSim.Region.Framework.Scenes /// Rez a script into a prim's inventory from another prim /// /// - /// - /// + /// + /// + /// + /// + /// public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) { TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); @@ -1960,12 +1963,11 @@ namespace OpenSim.Region.Framework.Scenes if (destPart == null) { m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Could not find script for ID {0}", - destId); + "[PRIM INVENTORY]: Could not find part {0} to insert script item {1} from {2} {3} in {4}", + destId, srcId, srcPart.Name, srcPart.UUID, Name); return; } - + // Must own the object, and have modify rights if (srcPart.OwnerID != destPart.OwnerID) { @@ -1973,12 +1975,14 @@ namespace OpenSim.Region.Framework.Scenes if ((destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) || ((destPart.GroupMask & (uint)PermissionMask.Modify) == 0)) return; - } else { + } + else + { if ((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0) return; } - if (destPart.ScriptAccessPin != pin) + if (destPart.ScriptAccessPin == 0 || destPart.ScriptAccessPin != pin) { m_log.WarnFormat( "[PRIM INVENTORY]: " + diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index 37caa5dc12..1ad0a9994b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs @@ -238,5 +238,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.IsNotNull(receivedItem); Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify); } + + [Test] + public void TestLlRemoteLoadScriptPin() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID user1Id = TestHelpers.ParseTail(0x1); + UUID user2Id = TestHelpers.ParseTail(0x2); + + SceneObjectGroup sourceSo = SceneHelpers.AddSceneObject(m_scene, 1, user1Id, "sourceSo", 0x10); + m_scene.AddSceneObject(sourceSo); + LSL_Api api = new LSL_Api(); + api.Initialize(m_engine, sourceSo.RootPart, null, null); + TaskInventoryHelpers.AddScript(m_scene, sourceSo.RootPart, "script", "Hello World"); + + SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene, 1, user1Id, "targetSo", 0x20); + SceneObjectGroup otherOwnedTargetSo + = SceneHelpers.AddSceneObject(m_scene, 1, user2Id, "otherOwnedTargetSo", 0x30); + + // Test that we cannot load a script when the target pin has never been set (i.e. it is zero) + api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 0, 0, 0); + Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); + + // Test that we cannot load a script when the given pin does not match the target + targetSo.RootPart.ScriptAccessPin = 5; + api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); + Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); + + // Test that we cannot load into a prim with a different owner + otherOwnedTargetSo.RootPart.ScriptAccessPin = 3; + api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); + Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); + + // Test that we can load a script when given pin and dest pin match. + targetSo.RootPart.ScriptAccessPin = 3; + api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); + TaskInventoryItem insertedItem = targetSo.RootPart.Inventory.GetInventoryItem("script"); + Assert.IsNotNull(insertedItem); + + // Test that we can no longer load if access pin is unset + targetSo.RootPart.Inventory.RemoveInventoryItem(insertedItem.ItemID); + Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); + + targetSo.RootPart.ScriptAccessPin = 0; + api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); + Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); + } } } \ No newline at end of file