mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
Fix bug where an avatar that had an object they owned attached through llAttachToAvatar() or osForceAttachToAvatar() would wrongly have next permissions come into play when they detached that object and rezzed it in scene.
This is because the attachments module code was setting the 'object slam' bit by using PermissionMask.All Solution here is to route the attachment item creation call through the existing inventory code in BasicInventoryAccessModule rather than copy/pasted code in AttachmentsModule itself.
This commit is contained in:
@@ -295,9 +295,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
public virtual UUID CopyToInventory(DeRezAction action, UUID folderID,
|
||||
List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
|
||||
public virtual List<InventoryItemBase> CopyToInventory(
|
||||
DeRezAction action, UUID folderID,
|
||||
List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)
|
||||
{
|
||||
List<InventoryItemBase> copiedItems = new List<InventoryItemBase>();
|
||||
|
||||
Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>();
|
||||
|
||||
if (CoalesceMultipleObjectsToInventory)
|
||||
@@ -324,16 +327,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
}
|
||||
}
|
||||
|
||||
// This is method scoped and will be returned. It will be the
|
||||
// last created asset id
|
||||
UUID assetID = UUID.Zero;
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY ACCESS MODULE]: Copying {0} object bundles to folder {1} action {2} for {3}",
|
||||
// bundlesToCopy.Count, folderID, action, remoteClient.Name);
|
||||
|
||||
// Each iteration is really a separate asset being created,
|
||||
// with distinct destinations as well.
|
||||
foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values)
|
||||
assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient);
|
||||
copiedItems.Add(CopyBundleToInventory(action, folderID, bundle, remoteClient, asAttachment));
|
||||
|
||||
return assetID;
|
||||
return copiedItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -344,12 +347,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="objlist"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <returns></returns>
|
||||
protected UUID CopyBundleToInventory(
|
||||
DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient)
|
||||
/// <param name="asAttachment">Should be true if the bundle is being copied as an attachment. This prevents
|
||||
/// attempted serialization of any script state which would abort any operating scripts.</param>
|
||||
/// <returns>The inventory item created by the copy</returns>
|
||||
protected InventoryItemBase CopyBundleToInventory(
|
||||
DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient,
|
||||
bool asAttachment)
|
||||
{
|
||||
UUID assetID = UUID.Zero;
|
||||
|
||||
CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
|
||||
Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
|
||||
|
||||
@@ -385,18 +389,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
string itemXml;
|
||||
|
||||
// If we're being called from a script, then trying to serialize that same script's state will not complete
|
||||
// in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
|
||||
// the client/server crashes rather than logging out normally, the attachment's scripts will resume
|
||||
// without state on relog. Arguably, this is what we want anyway.
|
||||
if (objlist.Count > 1)
|
||||
itemXml = CoalescedSceneObjectsSerializer.ToXml(coa);
|
||||
itemXml = CoalescedSceneObjectsSerializer.ToXml(coa, !asAttachment);
|
||||
else
|
||||
itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]);
|
||||
itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
|
||||
|
||||
// Restore the position of each group now that it has been stored to inventory.
|
||||
foreach (SceneObjectGroup objectGroup in objlist)
|
||||
objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
|
||||
|
||||
InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY ACCESS MODULE]: Created item is {0}",
|
||||
// item != null ? item.ID.ToString() : "NULL");
|
||||
|
||||
if (item == null)
|
||||
return UUID.Zero;
|
||||
return null;
|
||||
|
||||
// Can't know creator is the same, so null it in inventory
|
||||
if (objlist.Count > 1)
|
||||
@@ -406,7 +419,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
}
|
||||
else
|
||||
{
|
||||
item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
|
||||
item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
|
||||
item.CreatorData = objlist[0].RootPart.CreatorData;
|
||||
item.SaleType = objlist[0].RootPart.ObjectSaleType;
|
||||
item.SalePrice = objlist[0].RootPart.SalePrice;
|
||||
}
|
||||
@@ -419,8 +433,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
objlist[0].OwnerID.ToString());
|
||||
m_Scene.AssetService.Store(asset);
|
||||
|
||||
item.AssetID = asset.FullID;
|
||||
assetID = asset.FullID;
|
||||
item.AssetID = asset.FullID;
|
||||
|
||||
if (DeRezAction.SaveToExistingUserInventoryItem == action)
|
||||
{
|
||||
@@ -453,9 +466,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
// This is a hook to do some per-asset post-processing for subclasses that need that
|
||||
if (remoteClient != null)
|
||||
ExportAsset(remoteClient.AgentId, assetID);
|
||||
ExportAsset(remoteClient.AgentId, asset.FullID);
|
||||
|
||||
return assetID;
|
||||
return item;
|
||||
}
|
||||
|
||||
protected virtual void ExportAsset(UUID agentID, UUID assetID)
|
||||
@@ -643,7 +656,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
{
|
||||
// Catch all. Use lost & found
|
||||
//
|
||||
|
||||
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
|
||||
}
|
||||
}
|
||||
@@ -964,8 +976,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
so.FromFolderID = item.Folder;
|
||||
|
||||
// Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
|
||||
// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
|
||||
// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
|
||||
|
||||
if ((rootPart.OwnerID != item.Owner) ||
|
||||
(item.CurrentPermissions & 16) != 0)
|
||||
|
||||
Reference in New Issue
Block a user