From b9e2606c2ff820369659940e4aafbcb55390794a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 15 Jan 2017 16:15:40 +0000 Subject: add code for fixing effective permitions. This is a test, and currently too slow for prodution. just finding our way home --- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 177 +++++++++++++++++++++ .../Framework/Scenes/SceneObjectPartInventory.cs | 46 +++++- 2 files changed, 221 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9f98554..f44604b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -248,6 +248,183 @@ namespace OpenSim.Region.Framework.Scenes return -1; } + // new test code, to place in better place later + private object PermissionsLock = new object(); + + private uint m_EffectiveEveryOnePerms; + public uint EffectiveEveryOnePerms + { + get + { + // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) + // bc this is on heavy duty code paths + // but for now we need to test the concept + AggregateEveryOnePerms(); + return m_EffectiveEveryOnePerms; + } + } + + public void AggregateEveryOnePerms() + { + lock(PermissionsLock) + { + // get object everyone permissions + uint baseperms = RootPart.EveryoneMask & (uint)PermissionMask.All; + + if(baseperms == 0) + { + m_EffectiveEveryOnePerms = 0; + return; + } + + uint current = baseperms; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + part.Inventory.AggregateEveryOnePerms(ref current); + if( current == 0) + break; + } + // recover move + baseperms &= (uint)PermissionMask.Move; + current |= baseperms; + current &= (uint)PermissionMask.All; + m_EffectiveEveryOnePerms = current; + } + } + + private uint m_EffectiveGroupPerms; + public uint EffectiveGroupPerms + { + get + { + // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) + // bc this is on heavy duty code paths + // but for now we need to test the concept + AggregateGroupPerms(); + return m_EffectiveGroupPerms; + } + } + + public void AggregateGroupPerms() + { + lock(PermissionsLock) + { + // get object everyone permissions + uint baseperms = RootPart.GroupMask & (uint)PermissionMask.All; + + if(baseperms == 0) + { + m_EffectiveGroupPerms = 0; + return; + } + + uint current = baseperms; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + part.Inventory.AggregateGroupPerms(ref current); + if( current == 0) + break; + } + // recover modify and move + baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); + current |= baseperms; + current &= (uint)PermissionMask.All; + m_EffectiveGroupPerms = current; + } + } + + private uint m_EffectiveGroupOrEveryOnePerms; + public uint EffectiveGroupOrEveryOnePerms + { + get + { + // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) + // bc this is on heavy duty code paths + // but for now we need to test the concept + AggregateGroupOrEveryOnePerms(); + return m_EffectiveGroupOrEveryOnePerms; + } + } + + public void AggregateGroupOrEveryOnePerms() + { + lock(PermissionsLock) + { + // get object everyone permissions + uint baseperms = (RootPart.EveryoneMask | RootPart.GroupMask) & (uint)PermissionMask.All; + + if(baseperms == 0) + { + m_EffectiveGroupOrEveryOnePerms = 0; + return; + } + + uint current = baseperms; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + part.Inventory.AggregateGroupOrEveryonePerms(ref current); + if( current == 0) + break; + } + // recover modify and move + baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); + current |= baseperms; + current &= (uint)PermissionMask.All; + m_EffectiveGroupOrEveryOnePerms = current; + } + } + + private uint m_EffectiveOwnerPerms; + public uint EffectiveOwnerPerms + { + get + { + // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) + // bc this is on heavy duty code paths + // but for now we need to test the concept + AggregateOwnerPerms(); + return m_EffectiveOwnerPerms; + } + } + + public void AggregateOwnerPerms() + { + lock(PermissionsLock) + { + // get object everyone permissions + uint baseperms = RootPart.OwnerMask & (uint)PermissionMask.All; + + if(baseperms == 0) + { + m_EffectiveOwnerPerms = 0; + return; + } + + uint current = baseperms; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + part.Inventory.AggregateOwnerPerms(ref current); + if( current == 0) + break; + } + // recover modify and move + baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); + current |= baseperms; + current &= (uint)PermissionMask.All; + if((current & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0) + current |= (uint)PermissionMask.Transfer; + m_EffectiveOwnerPerms = current; + } + } + public uint GetEffectivePermissions() { return GetEffectivePermissions(false); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 02b94ce..48ae39e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -944,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes group.SetGroup(m_part.GroupID, null); // TODO: Remove magic number badness - if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) { @@ -965,7 +965,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in partList) { // TODO: Remove magic number badness - if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number + if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; @@ -1319,6 +1319,48 @@ namespace OpenSim.Region.Framework.Scenes } } + // reduce to minimal set + public void AggregateEveryOnePerms(ref uint current) + { + foreach (TaskInventoryItem item in m_items.Values) + { + current &= item.EveryonePermissions; + if(current == 0) + break; + } + } + + public void AggregateGroupPerms(ref uint current) + { + foreach (TaskInventoryItem item in m_items.Values) + { + current &= item.GroupPermissions; + if(current == 0) + break; + } + } + + public void AggregateGroupOrEveryonePerms(ref uint current) + { + foreach (TaskInventoryItem item in m_items.Values) + { + current &= (item.GroupPermissions | item.EveryonePermissions); + if(current == 0) + break; + } + } + + public void AggregateOwnerPerms(ref uint current) + { + foreach (TaskInventoryItem item in m_items.Values) + { + current &= item.CurrentPermissions; + if(current == 0) + break; + } + } + + public uint MaskEffectivePermissions() { uint mask=0x7fffffff; -- cgit v1.1