From 2dbf96593cf216595a1528afa2a668c0f38e1791 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 30 Apr 2017 19:44:49 +0100 Subject: [PATCH 1/3] Permissions compatibility hack 1: anyone copy - new permissions require that all items in all object parts contents have anyone copy set. Old code only required it on object. This hack tries to allow objects older than today to still work as before on this. (this is a test, we may need to change it) --- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 42f47b5938..66c901301d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -338,6 +338,8 @@ namespace OpenSim.Region.Framework.Scenes uint rootEveryonePerms = RootPart.EveryoneMask; uint everyone = rootEveryonePerms; + // date is time of writing april 30th 2017 + bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { @@ -345,7 +347,8 @@ namespace OpenSim.Region.Framework.Scenes part.AggregateInnerPerms(); owner &= part.AggregatedInnerOwnerPerms; group &= part.AggregatedInnerGroupPerms; - everyone &= part.AggregatedInnerEveryonePerms; + if(newObject) + everyone &= part.AggregatedInnerEveryonePerms; } // recover modify and move rootOwnerPerms &= movemodmask; @@ -407,14 +410,16 @@ namespace OpenSim.Region.Framework.Scenes uint everyone = rootEveryonePerms; bool needUpdate = false; - + // date is time of writing april 30th 2017 + bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; owner &= part.AggregatedInnerOwnerPerms; group &= part.AggregatedInnerGroupPerms; - everyone &= part.AggregatedInnerEveryonePerms; + if(newObject) + everyone &= part.AggregatedInnerEveryonePerms; } // recover modify and move rootOwnerPerms &= movemodmask; From 60dc124872c52fb50cbf2f4413bd8813e50c527b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 1 May 2017 14:18:59 +0100 Subject: [PATCH 2/3] rename sog.GetEffectivePermissions() since its use is now limited to more specific task, and no longer on current effective(full) path. Note that change ownermask start to be current ownermask, and filter it to all parts basemask --- .../InventoryAccess/InventoryAccessModule.cs | 17 +++++------------ .../World/Objects/BuySell/BuySellModule.cs | 10 +++++----- .../Scenes/SceneObjectGroup.Inventory.cs | 11 +++-------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 916ddb0a97..f1885dad14 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -579,26 +579,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess IClientAPI remoteClient) { uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export | PermissionMask.FoldedMask); - - // For the porposes of inventory, an object is modify if the prims - // are modify. This allows renaming an object that contains no - // mod items. + foreach (SceneObjectGroup grp in objsForEffectivePermissions) { - uint groupPerms = grp.GetEffectivePermissions(true); -// if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0) -// groupPerms |= (uint)PermissionMask.Modify; - - effectivePerms &= groupPerms; + effectivePerms &= grp.CurrentAndFoldedNextPermissions(); } if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { + // apply parts inventory items next owner PermissionsUtil.ApplyNoModFoldedPermissions(effectivePerms, ref effectivePerms); - + // change to next owner uint basePerms = effectivePerms & so.RootPart.NextOwnerMask; - - // rebuild folded perms since we don't have then on inworld objects + // fix and update folded basePerms = PermissionsUtil.FixAndFoldPermissions(basePerms); item.BasePermissions = basePerms; diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 6854b53cf7..d1a109ee6c 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs @@ -206,12 +206,12 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell item.InvType = (int)InventoryType.Object; item.Folder = categoryID; - perms = group.GetEffectivePermissions(false); - + perms = group.CurrentAndFoldedNextPermissions(); + // apply parts inventory next perms PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms); - - perms &= part.NextOwnerMask; - + // change to next owner perms + perms &= part.NextOwnerMask; + // update folded perms = PermissionsUtil.FixAndFoldPermissions(perms); item.BasePermissions = perms; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 66c901301d..36844a9909 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -484,7 +484,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public uint GetEffectivePermissions(bool useBase) + public uint CurrentAndFoldedNextPermissions() { uint perms=(uint)(PermissionMask.Modify | PermissionMask.Copy | @@ -492,18 +492,13 @@ namespace OpenSim.Region.Framework.Scenes PermissionMask.Transfer | PermissionMask.FoldedMask); - uint ownerMask = 0x7fffffff; + uint ownerMask = RootPart.OwnerMask; SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; - - if (useBase) - ownerMask &= part.BaseMask; - else - ownerMask &= part.OwnerMask; - + ownerMask &= part.BaseMask; perms &= part.Inventory.MaskEffectivePermissions(); } From 28d8eda768a64e1eff9edf3006f494d4f0d62bc3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 1 May 2017 14:42:38 +0100 Subject: [PATCH 3/3] buysell: make sure we dont buy child parts, dont mess with absolute position its useless with variable size regions, and its a rezing job --- .../World/Objects/BuySell/BuySellModule.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index d1a109ee6c..a7a9d1ddb7 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs @@ -118,6 +118,11 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell return false; SceneObjectGroup group = part.ParentGroup; + if(group == null || group.IsDeleted || group.inTransit) + return false; + + // make sure we are not buying a child part + part = group.RootPart; switch (saleType) { @@ -157,18 +162,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell break; case 2: // Sell a copy - Vector3 inventoryStoredPosition = new Vector3( - Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6), - Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6), - group.AbsolutePosition.Z); - - Vector3 originalPosition = group.AbsolutePosition; - - group.AbsolutePosition = inventoryStoredPosition; - - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); - group.AbsolutePosition = originalPosition; - uint perms = group.EffectiveOwnerPerms; if ((perms & (uint)PermissionMask.Transfer) == 0) @@ -185,6 +178,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell return false; } + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); + AssetBase asset = m_scene.CreateAsset( group.GetPartName(localID), group.GetPartDescription(localID),