From ba4e13ef55c378db13b6aa97316e99d651762a02 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 28 Apr 2017 20:03:44 +0100 Subject: a few changes to permissions folding... we are testing. at this point only use master for TESTING also --- OpenSim/Framework/Util.cs | 5 ++- .../InventoryAccess/InventoryAccessModule.cs | 35 +++++++++------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 ++++-- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 25 +++--------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 46 +++++++++++++--------- 6 files changed, 69 insertions(+), 59 deletions(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0ec24e6..4d025a9 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -79,7 +79,9 @@ namespace OpenSim.Framework FoldedMask = 0x0f, - // + FoldingShift = 13 , // number of bit shifts from normal perm to folded or back (same as Transfer shift below) + // when doing as a block + Transfer = 1 << 13, // 0x02000 Modify = 1 << 14, // 0x04000 Copy = 1 << 15, // 0x08000 @@ -91,6 +93,7 @@ namespace OpenSim.Framework All = 0x8e000, AllAndExport = 0x9e000, AllEffective = 0x9e000 + } /// diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 67c847b..eb7211c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -574,8 +574,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess IClientAPI remoteClient) { uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; - uint allObjectsNextOwnerPerms = 0x7fffffff; - + // For the porposes of inventory, an object is modify if the prims // are modify. This allows renaming an object that contains no // mod items. @@ -591,21 +590,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { - uint perms = effectivePerms; - uint nextPerms = (perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; + if ((effectivePerms & (uint)PermissionMask.FoldedCopy) == 0) + effectivePerms &= ~(uint)PermissionMask.Copy; + if ((effectivePerms & (uint)PermissionMask.FoldedTransfer) == 0) + effectivePerms &= ~(uint)PermissionMask.Transfer; + if ((effectivePerms & (uint)PermissionMask.FoldedExport) == 0) + effectivePerms &= ~(uint)PermissionMask.Export; -// item.BasePermissions = perms & so.RootPart.NextOwnerMask; + uint basePerms = effectivePerms & so.RootPart.NextOwnerMask; - uint nextp = so.RootPart.NextOwnerMask | (uint)PermissionMask.FoldedMask; - item.BasePermissions = perms & nextp; + if((basePerms & (uint)PermissionMask.Copy) == 0) + basePerms |= (uint)PermissionMask.Transfer; + + // unlock + basePerms |= (uint)PermissionMask.Move; + + basePerms &= ~(uint)PermissionMask.FoldedMask; + basePerms |= ((basePerms >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask); + + item.BasePermissions = basePerms; item.CurrentPermissions = item.BasePermissions; - item.NextPermissions = perms & so.RootPart.NextOwnerMask; + item.NextPermissions = effectivePerms & so.RootPart.NextOwnerMask; item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; @@ -626,7 +631,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess (uint)PermissionMask.Modify | (uint)PermissionMask.Move | (uint)PermissionMask.Export | - 7); // Preserve folded permissions + (uint)PermissionMask.FoldedMask); // Preserve folded permissions ?? } return item; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2f016fa..edf8cb6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -682,19 +682,19 @@ namespace OpenSim.Region.Framework.Scenes // These will be applied to the root prim at next rez. // The legacy slam bit (bit 3) and folded permission (bits 0-2) // are preserved due to the above mangling - ownerPerms &= nextPerms; +// ownerPerms &= nextPerms; // Mask the base permissions. This is a conservative // approach altering only the three main perms - basePerms &= nextPerms; +// basePerms &= nextPerms; // Mask out the folded portion of the base mask. // While the owner mask carries the actual folded // permissions, the base mask carries the original // base mask, before masking with the folded perms. // We need this later for rezzing. - basePerms &= ~(uint)PermissionMask.FoldedMask; - basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0); +// basePerms &= ~(uint)PermissionMask.FoldedMask; +// basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0); // If this is an object, root prim perms may be more // permissive than folded perms. Use folded perms as @@ -729,6 +729,11 @@ namespace OpenSim.Region.Framework.Scenes } } + // move here so nextperms are mandatory + ownerPerms &= nextPerms; + basePerms &= nextPerms; + basePerms &= ~(uint)PermissionMask.FoldedMask; + basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0); // Assign to the actual item. Make sure the slam bit is // set, if it wasn't set before. itemCopy.BasePermissions = basePerms; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 081281e..42f47b5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -326,7 +326,7 @@ namespace OpenSim.Region.Framework.Scenes // aux const uint allmask = (uint)PermissionMask.AllEffective; const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); - const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); + const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer); uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; @@ -350,7 +350,7 @@ namespace OpenSim.Region.Framework.Scenes // recover modify and move rootOwnerPerms &= movemodmask; owner |= rootOwnerPerms; - if((owner & copytransfermast) == 0) + if((owner & copytransfermask) == 0) owner |= (uint)PermissionMask.Transfer; owner &= basePerms; @@ -479,17 +479,13 @@ namespace OpenSim.Region.Framework.Scenes } } - public uint GetEffectivePermissions() - { - return GetEffectivePermissions(false); - } - public uint GetEffectivePermissions(bool useBase) { uint perms=(uint)(PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Move | - PermissionMask.Transfer) | 7; + PermissionMask.Transfer | + PermissionMask.FoldedMask); uint ownerMask = 0x7fffffff; @@ -512,17 +508,8 @@ namespace OpenSim.Region.Framework.Scenes perms &= ~(uint)PermissionMask.Copy; if ((ownerMask & (uint)PermissionMask.Transfer) == 0) perms &= ~(uint)PermissionMask.Transfer; - - // If root prim permissions are applied here, this would screw - // with in-inventory manipulation of the next owner perms - // in a major way. So, let's move this to the give itself. - // Yes. I know. Evil. -// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0) -// perms &= ~((uint)PermissionMask.Modify >> 13); -// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0) -// perms &= ~((uint)PermissionMask.Copy >> 13); -// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0) -// perms &= ~((uint)PermissionMask.Transfer >> 13); + if ((ownerMask & (uint)PermissionMask.Export) == 0) + perms &= ~(uint)PermissionMask.Export; return perms; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e4f18d9..f948336 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5288,9 +5288,9 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter // Export needs to be preserved in the base and everyone // mask, but removed in the owner mask as a next owner // can never change the export status - BaseMask &= NextOwnerMask | (uint)PermissionMask.Export; + BaseMask &= (NextOwnerMask | (uint)PermissionMask.Export); OwnerMask &= NextOwnerMask; - EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export; + EveryoneMask &= (NextOwnerMask | (uint)PermissionMask.Export); GroupMask = 0; // Giving an object zaps group permissions Inventory.ApplyNextOwnerPermissions(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index b53c355..894078d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1340,33 +1340,38 @@ namespace OpenSim.Region.Framework.Scenes public uint MaskEffectivePermissions() { + // used to propagate permissions restrictions outwards + // Modify does not propagate outwards. uint mask=0x7fffffff; - + foreach (TaskInventoryItem item in m_items.Values) { if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) - mask &= ~((uint)PermissionMask.Copy >> 13); + mask &= ~((uint)PermissionMask.FoldedCopy); if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) - mask &= ~((uint)PermissionMask.Transfer >> 13); - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) - mask &= ~((uint)PermissionMask.Modify >> 13); + mask &= ~((uint)PermissionMask.FoldedTransfer); + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Export) == 0) + mask &= ~((uint)PermissionMask.FoldedExport); + // this breaks some SL legal use cases + // there should be no folding from task inventory +/* if (item.InvType == (int)InventoryType.Object) { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - mask &= ~((uint)PermissionMask.Copy >> 13); - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - mask &= ~((uint)PermissionMask.Transfer >> 13); - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - mask &= ~((uint)PermissionMask.Modify >> 13); + if ((item.CurrentPermissions & ((uint)PermissionMask.FoldedCopy)) == 0) + mask &= ~((uint)PermissionMask.FoldedCopy); + if ((item.CurrentPermissions & ((uint)PermissionMask.FoldedTransfer)) == 0) + mask &= ~((uint)PermissionMask.FoldedTransfer); + if ((item.CurrentPermissions & (uint)PermissionMask.FoldedExport) == 0) + mask &= ~((uint)PermissionMask.FoldedExport); } - +*/ if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) mask &= ~(uint)PermissionMask.Copy; if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) mask &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) - mask &= ~(uint)PermissionMask.Modify; + if ((item.CurrentPermissions & (uint)PermissionMask.Export) == 0) + mask &= ~((uint)PermissionMask.Export); } return mask; } @@ -1375,19 +1380,24 @@ namespace OpenSim.Region.Framework.Scenes { foreach (TaskInventoryItem item in m_items.Values) { - if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) + + // this breaks legal SL use cases + // there should be no unfold into task inventory +/* + if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & (uint)PermissionMask.FoldedMask) != 0) { // m_log.DebugFormat ( // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + if ((item.CurrentPermissions & ((uint)PermissionMask.FoldedCopy)) == 0) item.CurrentPermissions &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + if ((item.CurrentPermissions & ((uint)PermissionMask.FoldedTransfer)) == 0) item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + if ((item.CurrentPermissions & ((uint)PermissionMask.FoldedModify)) == 0) item.CurrentPermissions &= ~(uint)PermissionMask.Modify; } +*/ item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; item.EveryonePermissions &= item.NextPermissions; -- cgit v1.1