From da91a2ab7eaea0b66e0a019f4284d780612b24c6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 04:33:14 +0100 Subject: Convert the agent asset transactions module to a new style module. Refactor to remove the property "MyScene" and the pointless circular refs to the managing classes. Converted the module to a non-shared module. Reformatted source for 80 columns. Removed the special role the module had in the old loader. --- .../AssetTransaction/AgentAssetsTransactions.cs | 115 ++++++++------------- 1 file changed, 43 insertions(+), 72 deletions(-) (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 3d6e7f3..0af113a 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// public class AgentAssetTransactions { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); // Fields private bool m_dumpAssetsToFile; - public AssetTransactionModule Manager; + private Scene m_Scene; public UUID UserID; - public Dictionary XferUploaders = new Dictionary(); + public Dictionary XferUploaders = + new Dictionary(); // Methods - public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) + public AgentAssetTransactions(UUID agentID, Scene scene, + bool dumpAssetsToFile) { + m_Scene = scene; UserID = agentID; - Manager = manager; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (!XferUploaders.ContainsKey(transactionID)) { - AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); + AssetXferUploader uploader = new AssetXferUploader(m_Scene, + m_dumpAssetsToFile); lock (XferUploaders) { @@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { if (XferUploaders.ContainsKey(transactionID)) { - XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, - callbackID, description, name, invType, type, - wearableType, nextOwnerMask); + XferUploaders[transactionID].RequestCreateInventoryItem( + remoteClient, transactionID, folderID, + callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } } /// - /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. + /// Get an uploaded asset. If the data is successfully retrieved, + /// the transaction will be removed. /// /// /// The asset if the upload has completed, null if it has not. @@ -125,48 +132,21 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction return null; } - //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) - //{ - // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); - // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( - // ourClient.AgentId); - - // if (userInfo != null) - // { - // InventoryItemBase item = new InventoryItemBase(); - // item.Owner = ourClient.AgentId; - // item.Creator = ourClient.AgentId; - // item.ID = UUID.Random(); - // item.AssetID = asset.FullID; - // item.Description = asset.Description; - // item.Name = asset.Name; - // item.AssetType = asset.Type; - // item.InvType = asset.Type; - // item.Folder = inventoryFolderID; - // item.BasePermissions = 0x7fffffff; - // item.CurrentPermissions = 0x7fffffff; - // item.EveryOnePermissions = 0; - // item.NextPermissions = nextPerms; - // item.Flags = wearableType; - // item.CreationDate = Util.UnixTimeSinceEpoch(); - - // userInfo.AddItem(item); - // ourClient.SendInventoryItemCreateUpdate(item); - // } - // else - // { - // m_log.ErrorFormat( - // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", - // ourClient.AgentId); - // } - //} - - public void RequestUpdateTaskInventoryItem( - IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) + public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, + SceneObjectPart part, UUID transactionID, + TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { - AssetBase asset = XferUploaders[transactionID].GetAssetData(); + AssetBase asset = GetTransactionAsset(transactionID); + + // Only legacy viewers use this, and they prefer CAPS, which + // we have, so this really never runs. + // Allow it, but only for "safe" types. + if ((InventoryType)item.InvType != InventoryType.Notecard && + (InventoryType)item.InvType != InventoryType.LSL) + return; + if (asset != null) { m_log.DebugFormat( @@ -178,32 +158,23 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.Type; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); - if (part.Inventory.UpdateInventoryItem(item)) - { - if ((InventoryType)item.InvType == InventoryType.Notecard) - remoteClient.SendAgentAlertMessage("Notecard saved", false); - else if ((InventoryType)item.InvType == InventoryType.LSL) - remoteClient.SendAgentAlertMessage("Script saved", false); - else - remoteClient.SendAgentAlertMessage("Item saved", false); - - part.GetProperties(remoteClient); - } + part.Inventory.UpdateInventoryItem(item); } } } - - public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, - InventoryItemBase item) + public void RequestUpdateInventoryItem(IClientAPI remoteClient, + UUID transactionID, InventoryItemBase item) { - if (XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { - UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); + UUID assetID = UUID.Combine(transactionID, + remoteClient.SecureSessionId); - AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); + AssetBase asset = m_Scene.AssetService.Get( + assetID.ToString()); if (asset == null) { @@ -219,10 +190,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.AssetType; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); } - IInventoryService invService = Manager.MyScene.InventoryService; + IInventoryService invService = m_Scene.InventoryService; invService.UpdateItem(item); } } -- cgit v1.1 From f41dfbabc8e31ed9e38e50cdfa9963ac05b1648c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 05:01:44 +0100 Subject: Simplify updating of agent inventory assets. Make newly created asset IDs random rather than using IDs known by the client ahead of time. --- .../AssetTransaction/AgentAssetsTransactions.cs | 25 ++++++---------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0af113a..c66a4ea 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -149,10 +149,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (asset != null) { - m_log.DebugFormat( - "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", - item.Name, part.Name, transactionID); - + asset.FullID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; @@ -170,20 +167,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { - UUID assetID = UUID.Combine(transactionID, - remoteClient.SecureSessionId); - - AssetBase asset = m_Scene.AssetService.Get( - assetID.ToString()); - - if (asset == null) - { - asset = GetTransactionAsset(transactionID); - } + AssetBase asset = GetTransactionAsset(transactionID); - if (asset != null && asset.FullID == assetID) + if (asset != null) { - // Assets never get updated, new ones get created asset.FullID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; @@ -191,10 +178,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.AssetID = asset.FullID; m_Scene.AssetService.Store(asset); - } - IInventoryService invService = m_Scene.InventoryService; - invService.UpdateItem(item); + IInventoryService invService = m_Scene.InventoryService; + invService.UpdateItem(item); + } } } } -- cgit v1.1 From 96446adfa4dd91194c6ce6383927cdece8bdda1f Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 07:06:30 +0100 Subject: Monitor the UUIDs used to create and update wearable assets. Reject any changed texture that is not present in the user's inventory full perm. This will prevent "UUID snatching", a copybot-type of attack that can cause clothing makers to be forced to destroy and replace legit items in order to invalidate the copies. --- .../Agent/AssetTransaction/AgentAssetsTransactions.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index c66a4ea..85e1c99 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -167,6 +167,16 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { + // Here we need to get the old asset to extract the + // texture UUIDs if it's a wearable. + if (item.AssetType == (int)AssetType.Bodypart || + item.AssetType == (int)AssetType.Clothing) + { + AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + if (oldAsset != null) + XferUploaders[transactionID].SetOldData(oldAsset.Data); + } + AssetBase asset = GetTransactionAsset(transactionID); if (asset != null) -- cgit v1.1