From d60e4574633e50d257730cc582a6efb63c8e9d7b Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Thu, 15 May 2008 19:28:10 +0000
Subject: Committing patch from Melanie. 0001290: [PATCH] implement
permissions propagation and script module hooks. Thanks Melanie! *
Implements quite a few inventory related perms. * (from Teravus) Fixes Take
Copy
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 4 +-
.../Region/Environment/Scenes/Scene.Inventory.cs | 218 +++++++++++++++------
.../Environment/Scenes/SceneExternalChecks.cs | 37 +++-
.../Scenes/SceneObjectGroup.Inventory.cs | 34 ++++
.../Region/Environment/Scenes/SceneObjectGroup.cs | 2 +-
.../Scenes/SceneObjectPart.Inventory.cs | 100 +++++++---
.../Region/Environment/Scenes/SceneObjectPart.cs | 18 +-
7 files changed, 301 insertions(+), 112 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 6d00f71..aa22740 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -1339,11 +1339,11 @@ namespace OpenSim.Region.Environment.Scenes
if (IncludeInSearch && m_parentScene.ExternalChecks.ExternalChecksCanEditObject(objid, user))
{
- obj.AddFlag(LLObject.ObjectFlags.JointWheel);
+ obj.ParentGroup.RootPart.AddFlag(LLObject.ObjectFlags.JointWheel);
}
else if (!IncludeInSearch && m_parentScene.ExternalChecks.ExternalChecksCanMoveObject(objid,user))
{
- obj.RemFlag(LLObject.ObjectFlags.JointWheel);
+ obj.ParentGroup.RootPart.RemFlag(LLObject.ObjectFlags.JointWheel);
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 62ad2cd..fb142f5 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -284,6 +284,7 @@ namespace OpenSim.Region.Environment.Scenes
item.Name = itemUpd.Name;
item.Description = itemUpd.Description;
item.NextPermissions = itemUpd.NextPermissions;
+ item.CurrentPermissions |= 8; // Slam!
item.EveryOnePermissions = itemUpd.EveryOnePermissions;
// TODO: Requires sanity checks
@@ -347,7 +348,13 @@ namespace OpenSim.Region.Environment.Scenes
InventoryItemBase item = senderUserInfo.RootFolder.FindItem(itemId);
if (item != null)
- {
+ {
+ if (!ExternalChecks.ExternalChecksBypassPermissions())
+ {
+ if((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
+ return;
+ }
+
// TODO get recipient's root folder
CachedUserInfo recipientUserInfo
= CommsManager.UserProfileCacheService.GetUserDetails(recipientClient.AgentId);
@@ -365,12 +372,37 @@ namespace OpenSim.Region.Environment.Scenes
itemCopy.AssetType = item.AssetType;
itemCopy.InvType = item.InvType;
itemCopy.Folder = recipientUserInfo.RootFolder.ID;
- itemCopy.CurrentPermissions = 2147483647;
- itemCopy.NextPermissions = 2147483647;
- itemCopy.EveryOnePermissions = item.EveryOnePermissions;
- itemCopy.BasePermissions = item.BasePermissions;
- itemCopy.CurrentPermissions = item.CurrentPermissions;
-
+ if (ExternalChecks.ExternalChecksPropagatePermissions())
+ {
+ if(item.InvType == 6)
+ {
+ itemCopy.BasePermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
+ itemCopy.BasePermissions |= (item.CurrentPermissions & 7) << 13;
+ }
+ else
+ {
+ Console.WriteLine("Non-Prim item ==>");
+ itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions;
+ }
+
+ itemCopy.CurrentPermissions = itemCopy.BasePermissions;
+ if((item.CurrentPermissions & 8) != 0) // Propagate slam bit
+ {
+ itemCopy.CurrentPermissions = item.NextPermissions;
+ itemCopy.BasePermissions=itemCopy.CurrentPermissions;
+ itemCopy.CurrentPermissions |= 8;
+ }
+
+ itemCopy.NextPermissions = item.NextPermissions;
+ itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions;
+ }
+ else
+ {
+ itemCopy.CurrentPermissions = item.CurrentPermissions;
+ itemCopy.NextPermissions = item.NextPermissions;
+ itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions;
+ itemCopy.BasePermissions = item.BasePermissions;
+ }
itemCopy.GroupID = item.GroupID;
itemCopy.GroupOwned = item.GroupOwned;
itemCopy.Flags = item.Flags;
@@ -379,6 +411,12 @@ namespace OpenSim.Region.Environment.Scenes
recipientUserInfo.AddItem(itemCopy);
+ if (!ExternalChecks.ExternalChecksBypassPermissions())
+ {
+ if((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
+ senderUserInfo.DeleteItem(itemId);
+ }
+
// Let the recipient client know about this new item
recipientClient.SendBulkUpdateInventory(itemCopy);
}
@@ -446,9 +484,16 @@ namespace OpenSim.Region.Environment.Scenes
if (asset != null)
{
- // TODO: preserve current permissions?
- CreateNewInventoryItem(
- remoteClient, newFolderID, callbackID, asset, item.NextPermissions);
+ if(remoteClient.AgentId == oldAgentID)
+ {
+ CreateNewInventoryItem(
+ remoteClient, newFolderID, callbackID, asset, item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions);
+ }
+ else
+ {
+ CreateNewInventoryItem(
+ remoteClient, newFolderID, callbackID, asset, item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions);
+ }
}
else
{
@@ -507,7 +552,6 @@ namespace OpenSim.Region.Environment.Scenes
userInfo.DeleteItem(item.ID);
- // TODO: preserve current permissions?
AddInventoryItem(remoteClient, item);
}
else
@@ -525,6 +569,12 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
+ AssetBase asset, uint nextOwnerMask)
+ {
+ CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask, nextOwnerMask, 0, nextOwnerMask);
+ }
+
///
/// Create a new inventory item.
///
@@ -534,7 +584,7 @@ namespace OpenSim.Region.Environment.Scenes
///
///
private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
- AssetBase asset, uint nextOwnerMask)
+ AssetBase asset, uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
@@ -551,8 +601,10 @@ namespace OpenSim.Region.Environment.Scenes
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.Folder = folderID;
- item.CurrentPermissions = 2147483647;
+ item.CurrentPermissions = currentMask;
item.NextPermissions = nextOwnerMask;
+ item.EveryOnePermissions = everyoneMask;
+ item.BasePermissions = baseMask;
userInfo.AddItem(item);
remoteClient.SendInventoryItemCreateUpdate(item);
@@ -766,9 +818,9 @@ namespace OpenSim.Region.Environment.Scenes
///
public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
{
- SceneObjectGroup group = GetGroupByPrim(primLocalId);
+ SceneObjectPart part = GetSceneObjectPart(primLocalId);
- if (null == group)
+ if (null == part)
{
m_log.WarnFormat(
"[PRIM INVENTORY]: " +
@@ -778,7 +830,7 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
- TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId);
+ TaskInventoryItem taskItem = part.GetInventoryItem(itemId);
if (null == taskItem)
{
@@ -786,19 +838,9 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
-// bool permission;
-// permission = Permissions.CanCopyObject(remoteClient.AgentId,
-// ((SceneObjectGroup) selectedEnt).UUID);
-
- // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner
- // to copy
+ // Only owner can copy
if (remoteClient.AgentId != taskItem.OwnerID)
{
- m_log.InfoFormat(
- "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5},"
- + " but temporarily not allowed pending upstream bugfixes/feature implementation",
- remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID);
-
return;
}
@@ -813,22 +855,29 @@ namespace OpenSim.Region.Environment.Scenes
agentItem.AssetType = taskItem.Type;
agentItem.InvType = taskItem.InvType;
agentItem.Folder = folderId;
- agentItem.EveryOnePermissions = taskItem.EveryoneMask;
- if (remoteClient.AgentId != taskItem.OwnerID)
+ if ((remoteClient.AgentId != taskItem.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
agentItem.BasePermissions = taskItem.NextOwnerMask;
agentItem.CurrentPermissions = taskItem.NextOwnerMask;
agentItem.NextPermissions = taskItem.NextOwnerMask;
+ agentItem.EveryOnePermissions = taskItem.EveryoneMask & taskItem.NextOwnerMask;
}
else
{
agentItem.BasePermissions = taskItem.BaseMask;
agentItem.CurrentPermissions = taskItem.OwnerMask;
- agentItem.NextPermissions = taskItem.NextOwnerMask;
+ agentItem.NextPermissions = taskItem.NextOwnerMask;
+ agentItem.EveryOnePermissions = taskItem.EveryoneMask;
}
AddInventoryItem(remoteClient, agentItem);
+ if (!ExternalChecks.ExternalChecksBypassPermissions())
+ {
+ if((taskItem.OwnerMask & (uint)PermissionMask.Copy) == 0)
+ part.RemoveInventoryItem(itemId);
+ }
+
}
///
@@ -842,9 +891,9 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID,
uint primLocalID)
{
- SceneObjectGroup group = GetGroupByPrim(primLocalID);
+ SceneObjectPart part = GetSceneObjectPart(primLocalID);
- if (group != null)
+ if (part != null)
{
LLUUID copyID = LLUUID.Random();
if (itemID != LLUUID.Zero)
@@ -864,11 +913,16 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
- group.AddInventoryItem(remoteClient, primLocalID, item, copyID);
+ part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
m_log.InfoFormat(
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
item.Name, primLocalID, remoteClient.Name);
- group.GetProperties(remoteClient);
+ part.ParentGroup.GetProperties(remoteClient);
+ if (!ExternalChecks.ExternalChecksBypassPermissions())
+ {
+ if((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
+ RemoveInventoryItem(remoteClient, itemID);
+ }
}
else
{
@@ -915,12 +969,12 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
- SceneObjectGroup group = GetGroupByPrim(localID);
- if (group != null)
+ SceneObjectPart part = GetSceneObjectPart(localID);
+ if (part != null)
{
- group.AddInventoryItem(remoteClient, localID, item, copyID);
- group.StartScript(localID, copyID);
- group.GetProperties(remoteClient);
+ part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
+ part.ParentGroup.StartScript(localID, copyID);
+ part.ParentGroup.GetProperties(remoteClient);
// m_log.InfoFormat("[PRIMINVENTORY]: " +
// "Rezzed script {0} into prim local ID {1} for user {2}",
@@ -959,7 +1013,7 @@ namespace OpenSim.Region.Environment.Scenes
///
///
public virtual void DeRezObject(Packet packet, IClientAPI remoteClient)
- {
+ {
DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
@@ -1038,18 +1092,21 @@ namespace OpenSim.Region.Environment.Scenes
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.Folder = DeRezPacket.AgentBlock.DestinationID;
- item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
- if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
+ if ((remoteClient.AgentId != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
- item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
- item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
- item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
+ objectGroup.ApplyNextOwnerPermissions();
+
+ item.BasePermissions = objectGroup.GetEffectivePermissions() & objectGroup.RootPart.NextOwnerMask;
+ item.CurrentPermissions = objectGroup.GetEffectivePermissions() & objectGroup.RootPart.NextOwnerMask;
+ item.NextPermissions = objectGroup.GetEffectivePermissions() & objectGroup.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
}
else
{
- item.BasePermissions = objectGroup.RootPart.BaseMask;
- item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
+ item.BasePermissions = objectGroup.GetEffectivePermissions();
+ item.CurrentPermissions = objectGroup.GetEffectivePermissions();
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
}
// TODO: add the new fields (Flags, Sale info, etc)
@@ -1068,6 +1125,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
+
public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID)
{
SceneObjectGroup objectGroup = grp;
@@ -1130,19 +1188,20 @@ namespace OpenSim.Region.Environment.Scenes
// Sticking it in root folder for now.. objects folder later?
item.Folder = foundFolder;// DeRezPacket.AgentBlock.DestinationID;
- item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
- if (agentID != objectGroup.RootPart.OwnerID)
+ if ((agentID != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
}
- else
- {
- item.BasePermissions = objectGroup.RootPart.BaseMask;
- item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
+ else
+ {
+ item.BasePermissions = objectGroup.GetEffectivePermissions();
+ item.CurrentPermissions = objectGroup.GetEffectivePermissions();
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
- }
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
+ }
userInfo.AddItem(item);
@@ -1187,18 +1246,19 @@ namespace OpenSim.Region.Environment.Scenes
// Sticking it in root folder for now.. objects folder later?
item.Folder = userInfo.RootFolder.ID;// DeRezPacket.AgentBlock.DestinationID;
- item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
- if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
+ if ((remoteClient.AgentId != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
}
else
{
item.BasePermissions = objectGroup.RootPart.BaseMask;
item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
}
userInfo.AddItem(item);
@@ -1344,18 +1404,33 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.Description = item.Description;
List partList = new List(group.Children.Values);
+
+ if(rootPart.OwnerID != item.Owner)
+ {
+ if((item.CurrentPermissions & 8) != 0)
+ {
+ foreach (SceneObjectPart part in partList)
+ {
+ part.EveryoneMask = item.EveryOnePermissions;
+ part.NextOwnerMask = item.NextPermissions;
+ }
+ }
+ group.ApplyNextOwnerPermissions();
+ }
+
foreach (SceneObjectPart part in partList)
{
if (part.OwnerID != item.Owner)
{
part.LastOwnerID = part.OwnerID;
part.OwnerID = item.Owner;
- part.EveryoneMask = item.EveryOnePermissions;
- part.BaseMask = item.BasePermissions;
- part.OwnerMask = item.CurrentPermissions;
- part.NextOwnerMask = item.NextPermissions;
part.ChangeInventoryOwner(item.Owner);
}
+ else if(((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
+ {
+ part.EveryoneMask = item.EveryOnePermissions;
+ part.NextOwnerMask = item.NextPermissions;
+ }
}
rootPart.TrimPermissions();
@@ -1421,18 +1496,33 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.Description = item.Description;
List partList = new List(group.Children.Values);
+
+ if(rootPart.OwnerID != item.OwnerID)
+ {
+ if((item.OwnerMask & 8) != 0)
+ {
+ foreach (SceneObjectPart part in partList)
+ {
+ part.EveryoneMask = item.EveryoneMask;
+ part.NextOwnerMask = item.NextOwnerMask;
+ }
+ }
+ group.ApplyNextOwnerPermissions();
+ }
+
foreach (SceneObjectPart part in partList)
{
if (part.OwnerID != item.OwnerID)
{
part.LastOwnerID = part.OwnerID;
part.OwnerID = item.OwnerID;
- part.EveryoneMask = item.EveryoneMask;
- part.BaseMask = item.BaseMask;
- part.OwnerMask = item.OwnerMask;
- part.NextOwnerMask = item.NextOwnerMask;
part.ChangeInventoryOwner(item.OwnerID);
}
+ else if((item.OwnerMask & 8) != 0) // Slam!
+ {
+ part.EveryoneMask = item.EveryoneMask;
+ part.NextOwnerMask = item.NextOwnerMask;
+ }
}
rootPart.TrimPermissions();
if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
index fcc6c75..645c302 100644
--- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
@@ -61,7 +61,16 @@ namespace OpenSim.Region.Environment.Scenes
public uint ExternalChecksGenerateClientFlags(LLUUID userID, LLUUID objectID)
{
- uint perms=(uint)2147483647;
+ SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);
+
+ uint perms=part.GetEffectiveObjectFlags() |
+ (uint)LLObject.ObjectFlags.ObjectModify |
+ (uint)LLObject.ObjectFlags.ObjectCopy |
+ (uint)LLObject.ObjectFlags.ObjectMove |
+ (uint)LLObject.ObjectFlags.ObjectTransfer |
+ (uint)LLObject.ObjectFlags.ObjectYouOwner |
+ (uint)LLObject.ObjectFlags.ObjectYouOfficer;
+
foreach (GenerateClientFlags check in GenerateClientFlagsCheckFunctions)
{
perms &= check(userID, objectID);
@@ -117,6 +126,32 @@ namespace OpenSim.Region.Environment.Scenes
return true;
}
+ public delegate bool PropagatePermissions();
+ private List PropagatePermissionsCheckFunctions = new List();
+
+ public void addPropagatePermissions(PropagatePermissions delegateFunc)
+ {
+ if (!PropagatePermissionsCheckFunctions.Contains(delegateFunc))
+ PropagatePermissionsCheckFunctions.Add(delegateFunc);
+ }
+ public void removePropagatePermissions(PropagatePermissions delegateFunc)
+ {
+ if (PropagatePermissionsCheckFunctions.Contains(delegateFunc))
+ PropagatePermissionsCheckFunctions.Remove(delegateFunc);
+ }
+
+ public bool ExternalChecksPropagatePermissions()
+ {
+ foreach (PropagatePermissions check in PropagatePermissionsCheckFunctions)
+ {
+ if (check() == false)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
#region REZ OBJECT
public delegate bool CanRezObject(int objectCount, LLUUID owner, LLVector3 objectPosition, Scene scene);
private List CanRezObjectCheckFunctions = new List();
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 721680f..8a7096f 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Reflection;
using libsecondlife;
using log4net;
@@ -282,5 +283,38 @@ namespace OpenSim.Region.Environment.Scenes
return -1;
}
+
+ public uint GetEffectivePermissions()
+ {
+ uint perms=(uint)(PermissionMask.Modify |
+ PermissionMask.Copy |
+ PermissionMask.Move |
+ PermissionMask.Transfer) | 7;
+
+ foreach (SceneObjectPart part in m_parts.Values)
+ perms &= part.MaskEffectivePermissions();
+
+ if((RootPart.OwnerMask & (uint)PermissionMask.Modify) == 0)
+ perms &= ~(uint)PermissionMask.Modify;
+ if((RootPart.OwnerMask & (uint)PermissionMask.Copy) == 0)
+ perms &= ~(uint)PermissionMask.Copy;
+ if((RootPart.OwnerMask & (uint)PermissionMask.Transfer) == 0)
+ perms &= ~(uint)PermissionMask.Transfer;
+
+ if((RootPart.OwnerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
+ perms &= ~((uint)PermissionMask.Modify >> 13);
+ if((RootPart.OwnerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
+ perms &= ~((uint)PermissionMask.Copy >> 13);
+ if((RootPart.OwnerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
+ perms &= ~((uint)PermissionMask.Transfer >> 13);
+
+ return perms;
+ }
+
+ public void ApplyNextOwnerPermissions()
+ {
+ foreach (SceneObjectPart part in m_parts.Values)
+ part.ApplyNextOwnerPermissions();
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 3ec6ed8..14bfde0 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -1352,7 +1352,7 @@ namespace OpenSim.Region.Environment.Scenes
{
// Apply Next Owner Permissions if we're not bypassing permissions
if (!m_scene.ExternalChecks.ExternalChecksBypassPermissions())
- m_rootPart.ApplyNextOwnerPermissions();
+ ApplyNextOwnerPermissions();
}
part.ScheduleFullUpdate();
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 9a9314c..e1be8ff 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -44,18 +44,13 @@ namespace OpenSim.Region.Environment.Scenes
private string m_inventoryFileName = String.Empty;
///
- /// The inventory folder for this prim
- ///
- private LLUUID m_folderID = LLUUID.Zero;
-
- ///
/// Exposing this is not particularly good, but it's one of the least evils at the moment to see
/// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
///
public LLUUID FolderID
{
- get { return m_folderID; }
- set { m_folderID = value; }
+ get { return UUID; }
+ set { } // Don't allow assignment, or legacy prims wil b0rk
}
///
@@ -133,8 +128,6 @@ namespace OpenSim.Region.Environment.Scenes
{
item.LastOwnerID = item.OwnerID;
item.OwnerID = ownerId;
- item.BaseMask = item.NextOwnerMask & (uint)PermissionMask.All;
- item.OwnerMask = item.NextOwnerMask & (uint)PermissionMask.All;
}
}
}
@@ -291,7 +284,7 @@ namespace OpenSim.Region.Environment.Scenes
///
public void AddInventoryItem(TaskInventoryItem item)
{
- item.ParentID = m_folderID;
+ item.ParentID = UUID;
item.CreationDate = 1000;
item.ParentPartID = UUID;
@@ -486,7 +479,7 @@ namespace OpenSim.Region.Environment.Scenes
// Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
// what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
// isn't available (such as drag from prim inventory to agent inventory)
- InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, LLUUID.Zero);
+ InventoryStringBuilder invString = new InventoryStringBuilder(UUID, LLUUID.Zero);
lock (m_taskInventory)
{
@@ -494,26 +487,15 @@ namespace OpenSim.Region.Environment.Scenes
{
invString.AddItemStart();
invString.AddNameValueLine("item_id", item.ItemID.ToString());
- invString.AddNameValueLine("parent_id", m_folderID.ToString());
+ invString.AddNameValueLine("parent_id", UUID.ToString());
invString.AddPermissionsStart();
- // FIXME: Temporary until permissions are properly sorted.
- invString.AddNameValueLine("base_mask", "7fffffff");
- invString.AddNameValueLine("owner_mask", "7fffffff");
- invString.AddNameValueLine("group_mask", "7fffffff");
- invString.AddNameValueLine("everyone_mask", "7fffffff");
- invString.AddNameValueLine("next_owner_mask", "7fffffff");
-
-// invString.AddNameValueLine("group_mask", "00000000");
-// invString.AddNameValueLine("everyone_mask", "00000000");
-// invString.AddNameValueLine("next_owner_mask", "00086000");
-
-// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask));
-// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask));
-// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask));
-// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask));
-// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask));
+ invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask));
+ invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask));
+ invString.AddNameValueLine("group_mask", "00000000");
+ invString.AddNameValueLine("everyone_mask", "00000000");
+ invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask));
invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
@@ -538,8 +520,6 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddNameValueLine("desc", item.Description + "|");
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
-// invString.AddNameValueLine("creation_date", "1209151453");
-
invString.AddSectionEnd();
}
}
@@ -629,5 +609,65 @@ namespace OpenSim.Region.Environment.Scenes
{
}
}
+
+ public uint MaskEffectivePermissions()
+ {
+ uint mask=0x7fffffff;
+
+ foreach (TaskInventoryItem item in m_taskInventory.Values)
+ {
+ if(item.InvType != 6)
+ {
+ if((item.OwnerMask & item.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
+ mask &= ~((uint)PermissionMask.Copy >> 13);
+ if((item.OwnerMask & item.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
+ mask &= ~((uint)PermissionMask.Transfer >> 13);
+ if((item.OwnerMask & item.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
+ mask &= ~((uint)PermissionMask.Modify >> 13);
+ }
+ else
+ {
+ if((item.OwnerMask & ((uint)PermissionMask.Copy >> 13)) == 0)
+ mask &= ~((uint)PermissionMask.Copy >> 13);
+ if((item.OwnerMask & ((uint)PermissionMask.Transfer >> 13)) == 0)
+ mask &= ~((uint)PermissionMask.Transfer >> 13);
+ if((item.OwnerMask & ((uint)PermissionMask.Modify >> 13)) == 0)
+ mask &= ~((uint)PermissionMask.Modify >> 13);
+ }
+
+ if((item.OwnerMask & (uint)PermissionMask.Copy) == 0)
+ mask &= ~(uint)PermissionMask.Copy;
+ if((item.OwnerMask & (uint)PermissionMask.Transfer) == 0)
+ mask &= ~(uint)PermissionMask.Transfer;
+ if((item.OwnerMask & (uint)PermissionMask.Modify) == 0)
+ mask &= ~(uint)PermissionMask.Modify;
+ }
+ return mask;
+ }
+
+ public void ApplyNextOwnerPermissions()
+ {
+ BaseMask &= NextOwnerMask;
+ OwnerMask &= NextOwnerMask;
+ EveryoneMask &= NextOwnerMask;
+
+ foreach (TaskInventoryItem item in m_taskInventory.Values)
+ {
+ if(item.InvType == 6)
+ {
+ if((item.OwnerMask & ((uint)PermissionMask.Copy >> 13)) == 0)
+ item.OwnerMask &= ~(uint)PermissionMask.Copy;
+ if((item.OwnerMask & ((uint)PermissionMask.Transfer >> 13)) == 0)
+ item.OwnerMask &= ~(uint)PermissionMask.Transfer;
+ if((item.OwnerMask & ((uint)PermissionMask.Modify >> 13)) == 0)
+ item.OwnerMask &= ~(uint)PermissionMask.Modify;
+ }
+ item.OwnerMask &= item.NextOwnerMask;
+ item.BaseMask &= item.NextOwnerMask;
+ item.EveryoneMask &= item.NextOwnerMask;
+ }
+
+ TriggerScriptChangedEvent(Changed.OWNER);
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index c171e78..0196b91 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -813,11 +813,9 @@ namespace OpenSim.Region.Environment.Scenes
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
// the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
- m_folderID = UUID;
Flags = 0;
- Flags |= LLObject.ObjectFlags.AllowInventoryDrop |
- LLObject.ObjectFlags.CreateSelected;
+ Flags |= LLObject.ObjectFlags.CreateSelected;
TrimPermissions();
//m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo());
@@ -877,9 +875,10 @@ namespace OpenSim.Region.Environment.Scenes
///
public static SceneObjectPart FromXml(XmlReader xmlReader)
{
+ // It's not necessary to persist this
+
XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader);
-
return newobject;
}
@@ -913,15 +912,6 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- public void ApplyNextOwnerPermissions()
- {
- BaseMask = NextOwnerMask;
- OwnerMask = NextOwnerMask;
-
- TriggerScriptChangedEvent(Changed.OWNER);
-
- }
-
public void TrimPermissions()
{
@@ -2541,7 +2531,7 @@ namespace OpenSim.Region.Environment.Scenes
}
info.AddValue("m_inventoryFileName", m_inventoryFileName);
- info.AddValue("m_folderID", m_folderID.UUID);
+ info.AddValue("m_folderID", UUID);
info.AddValue("PhysActor", PhysActor);
Dictionary TaskInventory_work = new Dictionary();
--
cgit v1.1