diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 354f587466..811781cae8 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -2763,15 +2763,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
///
private void ApplyNextOwnerPermissions(InventoryItemBase item)
{
- if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
+ if (item.InvType == (int)InventoryType.Object)
{
- 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;
+ uint perms = item.CurrentPermissions;
+ PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
+ item.CurrentPermissions = perms;
}
+
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 3dce04dde0..d785a781f5 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -64,5 +64,24 @@ 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 da36ed0ab6..a7e6fdd1f8 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -443,13 +443,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;
+ AddPermissions(item, objlist[0], objlist, remoteClient);
+
m_Scene.AddInventoryItem(item);
if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -495,16 +495,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
effectivePerms &= grp.GetEffectivePermissions();
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())
{
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;
+ PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
item.BasePermissions = perms & so.RootPart.NextOwnerMask;
item.CurrentPermissions = item.BasePermissions;
@@ -530,8 +526,10 @@ 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 22a53a84f4..0cb574a4dc 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -198,13 +198,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
- 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;
+ PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
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 65536dbdbc..9cc5cde2d1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -669,17 +669,13 @@ 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
- ownerPerms &= foldedPerms;
- basePerms &= foldedPerms;
+ PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms);
+ PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms);
// If the root was mod, let the mask reflect that
// We also need to adjust the base here, because
@@ -1209,9 +1205,16 @@ namespace OpenSim.Region.Framework.Scenes
{
agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
if (taskItem.InvType == (int)InventoryType.Object)
- agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move));
+ {
+ uint perms = taskItem.CurrentPermissions;
+ PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
+ agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
+ agentItem.CurrentPermissions = agentItem.BasePermissions;
+ }
else
+ {
agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
+ }
agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
agentItem.NextPermissions = taskItem.NextPermissions;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 5fa01e31e1..fb8ecd5df9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1132,14 +1132,11 @@ namespace OpenSim.Region.Framework.Scenes
// "[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.InvType == (int)InventoryType.Object)
{
- 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;
+ uint perms = item.CurrentPermissions;
+ PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
+ item.CurrentPermissions = perms;
}
item.CurrentPermissions &= item.NextPermissions;