From 7f99a8c900251c59bc7cb7d8309a14ad5360de42 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Jan 2011 16:20:38 +0100 Subject: Fix direct item give permissions --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 +++++++++++++++++++--- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 2 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 22 ++++++++--- 3 files changed, 56 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1f32362..7216b39 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -308,10 +308,17 @@ namespace OpenSim.Region.Framework.Scenes { if (UUID.Zero == transactionID) { + item.Flags = itemUpd.Flags; item.Name = itemUpd.Name; item.Description = itemUpd.Description; + if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; + if (item.EveryOnePermissions != (itemUpd.EveryOnePermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; + if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; item.GroupID = itemUpd.GroupID; item.GroupOwned = itemUpd.GroupOwned; @@ -326,9 +333,12 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Check if folder changed and move item //item.NextPermissions = itemUpd.Folder; item.InvType = itemUpd.InvType; + + if (item.SalePrice != itemUpd.SalePrice || + item.SaleType != itemUpd.SaleType) + item.Flags |= (uint)InventoryItemFlags.ObjectSlamSale; item.SalePrice = itemUpd.SalePrice; item.SaleType = itemUpd.SaleType; - item.Flags = itemUpd.Flags; InventoryService.UpdateItem(item); } @@ -509,7 +519,8 @@ namespace OpenSim.Region.Framework.Scenes // Assign to the actual item. Make sure the slam bit is // set, if it wasn't set before. itemCopy.BasePermissions = basePerms; - itemCopy.CurrentPermissions = ownerPerms | 16; // Slam + itemCopy.CurrentPermissions = ownerPerms; + itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; itemCopy.NextPermissions = item.NextPermissions; @@ -1049,7 +1060,7 @@ namespace OpenSim.Region.Framework.Scenes else agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; - agentItem.CurrentPermissions |= 16; // Slam + agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; @@ -1260,7 +1271,7 @@ namespace OpenSim.Region.Framework.Scenes (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.BasePermissions = srcTaskItem.BasePermissions & (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); - destTaskItem.CurrentPermissions |= 16; // Slam! + destTaskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } } @@ -1434,6 +1445,8 @@ namespace OpenSim.Region.Framework.Scenes // Base ALWAYS has move currentItem.BasePermissions |= (uint)PermissionMask.Move; + itemInfo.Flags = currentItem.Flags; + // Check if we're allowed to mess with permissions if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god { @@ -1451,6 +1464,14 @@ namespace OpenSim.Region.Framework.Scenes // Owner can't change base, and can change other // only up to base itemInfo.BasePermissions = currentItem.BasePermissions; + if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; + if (itemInfo.GroupPermissions != currentItem.GroupPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; + if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; + if (itemInfo.NextPermissions != currentItem.NextPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; itemInfo.EveryonePermissions &= currentItem.BasePermissions; itemInfo.GroupPermissions &= currentItem.BasePermissions; itemInfo.CurrentPermissions &= currentItem.BasePermissions; @@ -1458,6 +1479,19 @@ namespace OpenSim.Region.Framework.Scenes } } + else + { + if (itemInfo.BasePermissions != currentItem.BasePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; + if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; + if (itemInfo.GroupPermissions != currentItem.GroupPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; + if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; + if (itemInfo.NextPermissions != currentItem.NextPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; + } // Next ALWAYS has move itemInfo.NextPermissions |= (uint)PermissionMask.Move; @@ -1666,7 +1700,7 @@ namespace OpenSim.Region.Framework.Scenes srcTaskItem.NextPermissions; destTaskItem.BasePermissions = srcTaskItem.BasePermissions & srcTaskItem.NextPermissions; - destTaskItem.CurrentPermissions |= 16; // Slam! + destTaskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 50521c4..0b545c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes taskItem.NextPermissions = item.NextPermissions; // We're adding this to a prim we don't own. Force // owner change - taskItem.CurrentPermissions |= 16; // Slam + taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3b1ab01..8761284 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -815,14 +815,19 @@ namespace OpenSim.Region.Framework.Scenes group.SetGroup(m_part.GroupID, null); - if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) + // TODO: Remove magic number badness + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) { foreach (SceneObjectPart part in partList) { - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; } group.ApplyNextOwnerPermissions(); @@ -831,15 +836,20 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in partList) { - if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) + // TODO: Remove magic number badness + if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; } rootPart.TrimPermissions(); -- cgit v1.1 From f59b55d930b4a715d2ea5b99d2b3f5494073b1ae Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Jan 2011 17:40:21 +0100 Subject: Dont' trust the viewer! Fix a permission slam error caused by trusting the viewer too much. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7216b39..7fa5509 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -308,7 +308,6 @@ namespace OpenSim.Region.Framework.Scenes { if (UUID.Zero == transactionID) { - item.Flags = itemUpd.Flags; item.Name = itemUpd.Name; item.Description = itemUpd.Description; if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) -- cgit v1.1