From 4385d7d6934443530c1e14976e40f01dc90175bf Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Fri, 6 Jan 2017 13:17:43 +0000
Subject: Fix errors introduced by incomplete understanding of what folded
perms are
---
.../RemoteController/RemoteAdminPlugin.cs | 10 +++++----
OpenSim/Framework/PermissionsUtil.cs | 19 -----------------
.../InventoryAccess/InventoryAccessModule.cs | 24 ++++++++++------------
.../World/Objects/BuySell/BuySellModule.cs | 8 +++++++-
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 24 ++++++++--------------
.../Framework/Scenes/SceneObjectPartInventory.cs | 19 +++++++++++------
6 files changed, 46 insertions(+), 58 deletions(-)
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index a5c9fb4..597b439 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -3053,11 +3053,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
- uint perms = item.CurrentPermissions;
- PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
- item.CurrentPermissions = perms;
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
}
-
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryOnePermissions &= item.NextPermissions;
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
index 5d3186d..3dce04d 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -64,24 +64,5 @@ namespace OpenSim.Framework
str = ".";
return str;
}
-
- ///
- /// Applies an object's folded permissions to its regular permissions.
- ///
- /// The folded permissions. Only the lowest 7 bits are examined.
- /// The permissions variable to modify.
- public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
- {
-// if ((foldedPerms & 7) == 0)
-// return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
-
- if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
- mainPerms &= ~(uint)PermissionMask.Copy;
- if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0)
- mainPerms &= ~(uint)PermissionMask.Transfer;
- if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0)
- mainPerms &= ~(uint)PermissionMask.Modify;
- }
-
}
}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index fcf373b..4fb4cc2 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -532,17 +532,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
else
{
+ AddPermissions(item, objlist[0], objlist, remoteClient);
+
item.CreationDate = Util.UnixTimeSinceEpoch();
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
- //preserve perms on return
- if(DeRezAction.Return == action)
- AddPermissions(item, objlist[0], objlist, null);
- else
- AddPermissions(item, objlist[0], objlist, remoteClient);
-
m_Scene.AddInventoryItem(item);
if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -599,15 +595,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
effectivePerms |= (uint)PermissionMask.Move;
- //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
-
if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
// Changing ownership, so apply the "Next Owner" permissions to all of the
// inventory item's permissions.
uint perms = effectivePerms;
- PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
+ 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;
item.BasePermissions = perms & so.RootPart.NextOwnerMask;
item.CurrentPermissions = item.BasePermissions;
@@ -640,10 +640,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
(uint)PermissionMask.Move |
(uint)PermissionMask.Export |
7); // Preserve folded permissions
- }
-
- //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
-
+ }
+
return item;
}
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index b7f01be..2837358 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -211,7 +211,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
- PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
+ 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;
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e3ccf96..9c8dbb6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -681,13 +681,17 @@ namespace OpenSim.Region.Framework.Scenes
// a mask
if (item.InvType == (int)InventoryType.Object)
{
+ // Create a safe mask for the current perms
+ uint foldedPerms = (item.CurrentPermissions & 7) << 13;
+ foldedPerms |= permsMask;
+
bool isRootMod = (item.CurrentPermissions &
(uint)PermissionMask.Modify) != 0 ?
true : false;
// Mask the owner perms to the folded perms
- PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms);
- PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms);
+ ownerPerms &= foldedPerms;
+ basePerms &= foldedPerms;
// If the root was mod, let the mask reflect that
// We also need to adjust the base here, because
@@ -1240,19 +1244,9 @@ namespace OpenSim.Region.Framework.Scenes
{
agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
if (taskItem.InvType == (int)InventoryType.Object)
- {
- // 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;
- // Newly given items cannot be "locked" on rez. Make sure by
- // setting current equal to base.
- }
+ agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move));
+ else
+ agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
agentItem.CurrentPermissions = agentItem.BasePermissions;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a50f162..45c3ebd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1358,12 +1358,19 @@ namespace OpenSim.Region.Framework.Scenes
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
- if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
- item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
- if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
- item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
- if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
- item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
+// 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.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
+ {
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
+ if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
+ item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
+ }
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
--
cgit v1.1
From da76224eac91500013979c7a18c60bce63bad609 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Fri, 6 Jan 2017 13:18:22 +0000
Subject: Remove more calls to that horrible function
---
.../Framework/InventoryAccess/InventoryAccessModule.cs | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 4fb4cc2..aa5d381 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -597,9 +597,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
- // Changing ownership, so apply the "Next Owner" permissions to all of the
- // inventory item's permissions.
-
uint perms = effectivePerms;
uint nextPerms = (perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
@@ -620,13 +617,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
else
{
- // Not changing ownership.
- // In this case we apply the permissions in the object's items ONLY to the inventory
- // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions.
- // E.g., if the object contains a No-Transfer item then the item's "Next Owner"
- // permissions are also No-Transfer.
- PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms);
-
item.BasePermissions = effectivePerms;
item.CurrentPermissions = effectivePerms;
item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms;
--
cgit v1.1
From e526e8c5e225e931a5796532bf32b76530388089 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Fri, 6 Jan 2017 17:05:00 +0000
Subject: Fix the long-standing bug that object permissions set in inventory
were lost
NOTE: Items rezzed by users using 0.8 or older will still exhibit broken
behaviour. Until 0.8 becomes end of life, this fix will not produce
dependable results on grids with mixed versions. Grids based on 0.9 will
now work properly.
---
.../Framework/InventoryAccess/InventoryAccessModule.cs | 12 ++++++++----
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 18 ++++++++++++------
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 +
.../Services/UserAccountService/UserAccountService.cs | 1 -
4 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index aa5d381..0104823 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -1141,6 +1141,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
part.OwnerID = item.Owner;
part.RezzerID = item.Owner;
part.Inventory.ChangeInventoryOwner(item.Owner);
+
+ // This applies the base mask from the item as the next
+ // permissions for the object. This is correct because the
+ // giver's base mask was masked by the giver's next owner
+ // mask, so the base mask equals the original next owner mask.
+ part.NextOwnerMask = item.BasePermissions;
}
so.ApplyNextOwnerPermissions();
@@ -1152,10 +1158,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{
if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
{
- if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
- part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
- if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
- part.NextOwnerMask = item.NextPermissions & part.BaseMask;
+ part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
+ part.NextOwnerMask = item.NextPermissions & part.BaseMask;
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9c8dbb6..cb06540 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -627,6 +627,7 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.AssetType = item.AssetType;
itemCopy.InvType = item.InvType;
itemCopy.Folder = recipientFolderId;
+ itemCopy.Flags = item.Flags;
if (Permissions.PropagatePermissions() && recipient != senderId)
{
@@ -643,7 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
//
// Transfer
// Copy
- // Modufy
+ // Modify
uint permsMask = ~ ((uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer |
(uint)PermissionMask.Modify);
@@ -718,6 +719,10 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.BasePermissions = basePerms;
itemCopy.CurrentPermissions = ownerPerms;
itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
+ // Need to clear the other inventory slam options.
+ // That is so we can handle the case where the recipient
+ // changes the bits in inventory before rezzing
+ itemCopy.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
itemCopy.NextPermissions = item.NextPermissions;
@@ -767,9 +772,8 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.GroupID = UUID.Zero;
itemCopy.GroupOwned = false;
- itemCopy.Flags = item.Flags;
- itemCopy.SalePrice = item.SalePrice;
- itemCopy.SaleType = item.SaleType;
+ itemCopy.SalePrice = 0; //item.SalePrice;
+ itemCopy.SaleType = 0; //item.SaleType;
IInventoryAccessModule invAccess = RequestModuleInterface();
if (invAccess != null)
@@ -1251,9 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes
agentItem.CurrentPermissions = agentItem.BasePermissions;
agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
+ agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
- agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
+ // Group permissions make no sense here
+ agentItem.GroupPermissions = 0;
}
else
{
@@ -1261,7 +1267,7 @@ namespace OpenSim.Region.Framework.Scenes
agentItem.CurrentPermissions = taskItem.CurrentPermissions;
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions;
- agentItem.GroupPermissions = taskItem.GroupPermissions;
+ agentItem.GroupPermissions = 0;
}
message = null;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b97cceb..99be06b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -5242,6 +5242,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
BaseMask &= NextOwnerMask | (uint)PermissionMask.Export;
OwnerMask &= NextOwnerMask;
EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export;
+ GroupMask = 0; // Giving an object zaps group permissions
Inventory.ApplyNextOwnerPermissions();
}
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 7120aeb..f6b003a 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -947,7 +947,6 @@ namespace OpenSim.Services.UserAccountService
if (item.InvType == (int)InventoryType.Object)
{
uint perms = item.CurrentPermissions;
- PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
item.CurrentPermissions = perms;
}
--
cgit v1.1