diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
4 files changed, 174 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0271738..da1ff2e 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | public void RequestCreateInventoryItem(IClientAPI remoteClient, | 146 | public bool RequestCreateInventoryItem(IClientAPI remoteClient, |
147 | UUID transactionID, UUID folderID, uint callbackID, | 147 | UUID transactionID, UUID folderID, uint callbackID, |
148 | string description, string name, sbyte invType, | 148 | string description, string name, sbyte invType, |
149 | sbyte type, byte wearableType, uint nextOwnerMask) | 149 | sbyte type, byte wearableType, uint nextOwnerMask) |
@@ -153,6 +153,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
153 | uploader.RequestCreateInventoryItem( | 153 | uploader.RequestCreateInventoryItem( |
154 | remoteClient, folderID, callbackID, | 154 | remoteClient, folderID, callbackID, |
155 | description, name, invType, type, wearableType, nextOwnerMask); | 155 | description, name, invType, type, wearableType, nextOwnerMask); |
156 | |||
157 | return true; | ||
156 | } | 158 | } |
157 | 159 | ||
158 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, | 160 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
@@ -172,4 +174,4 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
172 | uploader.RequestUpdateInventoryItem(remoteClient, item); | 174 | uploader.RequestUpdateInventoryItem(remoteClient, item); |
173 | } | 175 | } |
174 | } | 176 | } |
175 | } \ No newline at end of file | 177 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index d1ad74f..faee189 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
158 | /// <param name="type"></param> | 158 | /// <param name="type"></param> |
159 | /// <param name="wearableType"></param> | 159 | /// <param name="wearableType"></param> |
160 | /// <param name="nextOwnerMask"></param> | 160 | /// <param name="nextOwnerMask"></param> |
161 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, | 161 | public bool HandleItemCreationFromTransaction(IClientAPI remoteClient, |
162 | UUID transactionID, UUID folderID, uint callbackID, | 162 | UUID transactionID, UUID folderID, uint callbackID, |
163 | string description, string name, sbyte invType, | 163 | string description, string name, sbyte invType, |
164 | sbyte type, byte wearableType, uint nextOwnerMask) | 164 | sbyte type, byte wearableType, uint nextOwnerMask) |
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
169 | AgentAssetTransactions transactions = | 169 | AgentAssetTransactions transactions = |
170 | GetUserTransactions(remoteClient.AgentId); | 170 | GetUserTransactions(remoteClient.AgentId); |
171 | 171 | ||
172 | transactions.RequestCreateInventoryItem(remoteClient, transactionID, | 172 | return transactions.RequestCreateInventoryItem(remoteClient, transactionID, |
173 | folderID, callbackID, description, name, invType, type, | 173 | folderID, callbackID, description, name, invType, type, |
174 | wearableType, nextOwnerMask); | 174 | wearableType, nextOwnerMask); |
175 | } | 175 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 11efe6d..43b8b44 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
31 | using log4net; | 32 | using log4net; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -38,6 +39,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
38 | { | 39 | { |
39 | public class AssetXferUploader | 40 | public class AssetXferUploader |
40 | { | 41 | { |
42 | // Viewer's notion of the default texture | ||
43 | private List<UUID> defaultIDs = new List<UUID> { | ||
44 | new UUID("5748decc-f629-461c-9a36-a35a221fe21f"), | ||
45 | new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"), | ||
46 | new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"), | ||
47 | new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97") | ||
48 | }; | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 50 | ||
43 | /// <summary> | 51 | /// <summary> |
@@ -85,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
85 | 93 | ||
86 | private sbyte type = 0; | 94 | private sbyte type = 0; |
87 | private byte wearableType = 0; | 95 | private byte wearableType = 0; |
96 | private byte[] m_oldData = null; | ||
88 | public ulong XferID; | 97 | public ulong XferID; |
89 | private Scene m_Scene; | 98 | private Scene m_Scene; |
90 | 99 | ||
@@ -127,18 +136,27 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
127 | 136 | ||
128 | if (XferID == xferID) | 137 | if (XferID == xferID) |
129 | { | 138 | { |
130 | if (m_asset.Data.Length > 1) | 139 | lock (this) |
131 | { | 140 | { |
132 | byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; | 141 | int assetLength = m_asset.Data.Length; |
133 | Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); | 142 | int dataLength = data.Length; |
134 | Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); | 143 | |
135 | m_asset.Data = destinationArray; | 144 | if (m_asset.Data.Length > 1) |
136 | } | 145 | { |
137 | else | 146 | byte[] destinationArray = new byte[assetLength + dataLength]; |
138 | { | 147 | Array.Copy(m_asset.Data, 0, destinationArray, 0, assetLength); |
139 | byte[] buffer2 = new byte[data.Length - 4]; | 148 | Array.Copy(data, 0, destinationArray, assetLength, dataLength); |
140 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); | 149 | m_asset.Data = destinationArray; |
141 | m_asset.Data = buffer2; | 150 | } |
151 | else | ||
152 | { | ||
153 | if (dataLength > 4) | ||
154 | { | ||
155 | byte[] buffer2 = new byte[dataLength - 4]; | ||
156 | Array.Copy(data, 4, buffer2, 0, dataLength - 4); | ||
157 | m_asset.Data = buffer2; | ||
158 | } | ||
159 | } | ||
142 | } | 160 | } |
143 | 161 | ||
144 | ourClient.SendConfirmXfer(xferID, packetID); | 162 | ourClient.SendConfirmXfer(xferID, packetID); |
@@ -394,6 +412,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
394 | 412 | ||
395 | private void CompleteCreateItem(uint callbackID) | 413 | private void CompleteCreateItem(uint callbackID) |
396 | { | 414 | { |
415 | ValidateAssets(); | ||
397 | m_Scene.AssetService.Store(m_asset); | 416 | m_Scene.AssetService.Store(m_asset); |
398 | 417 | ||
399 | InventoryItemBase item = new InventoryItemBase(); | 418 | InventoryItemBase item = new InventoryItemBase(); |
@@ -414,6 +433,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
414 | item.Flags = (uint) wearableType; | 433 | item.Flags = (uint) wearableType; |
415 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 434 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
416 | 435 | ||
436 | m_log.DebugFormat("[XFER]: Created item {0} with asset {1}", | ||
437 | item.ID, item.AssetID); | ||
438 | |||
417 | if (m_Scene.AddInventoryItem(item)) | 439 | if (m_Scene.AddInventoryItem(item)) |
418 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); | 440 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); |
419 | else | 441 | else |
@@ -421,5 +443,132 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
421 | 443 | ||
422 | m_transactions.RemoveXferUploader(m_transactionID); | 444 | m_transactions.RemoveXferUploader(m_transactionID); |
423 | } | 445 | } |
446 | |||
447 | private void ValidateAssets() | ||
448 | { | ||
449 | if (m_asset.Type == (sbyte)AssetType.Clothing || | ||
450 | m_asset.Type == (sbyte)AssetType.Bodypart) | ||
451 | { | ||
452 | string content = System.Text.Encoding.ASCII.GetString(m_asset.Data); | ||
453 | string[] lines = content.Split(new char[] {'\n'}); | ||
454 | |||
455 | List<string> validated = new List<string>(); | ||
456 | |||
457 | Dictionary<int, UUID> allowed = ExtractTexturesFromOldData(); | ||
458 | |||
459 | int textures = 0; | ||
460 | |||
461 | foreach (string line in lines) | ||
462 | { | ||
463 | try | ||
464 | { | ||
465 | if (line.StartsWith("textures ")) | ||
466 | { | ||
467 | textures = Convert.ToInt32(line.Substring(9)); | ||
468 | validated.Add(line); | ||
469 | } | ||
470 | else if (textures > 0) | ||
471 | { | ||
472 | string[] parts = line.Split(new char[] {' '}); | ||
473 | |||
474 | UUID tx = new UUID(parts[1]); | ||
475 | int id = Convert.ToInt32(parts[0]); | ||
476 | |||
477 | if (defaultIDs.Contains(tx) || tx == UUID.Zero || | ||
478 | (allowed.ContainsKey(id) && allowed[id] == tx)) | ||
479 | { | ||
480 | validated.Add(parts[0] + " " + tx.ToString()); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx); | ||
485 | int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy); | ||
486 | |||
487 | if ((perms & full) != full) | ||
488 | { | ||
489 | m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); | ||
490 | validated.Add(parts[0] + " " + UUID.Zero.ToString()); | ||
491 | } | ||
492 | else | ||
493 | { | ||
494 | validated.Add(line); | ||
495 | } | ||
496 | } | ||
497 | textures--; | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | validated.Add(line); | ||
502 | } | ||
503 | } | ||
504 | catch | ||
505 | { | ||
506 | // If it's malformed, skip it | ||
507 | } | ||
508 | } | ||
509 | |||
510 | string final = String.Join("\n", validated.ToArray()); | ||
511 | |||
512 | m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | /// <summary> | ||
517 | /// Get the asset data uploaded in this transfer. | ||
518 | /// </summary> | ||
519 | /// <returns>null if the asset has not finished uploading</returns> | ||
520 | public AssetBase GetAssetData() | ||
521 | { | ||
522 | if (m_uploadState == UploadState.Complete) | ||
523 | { | ||
524 | ValidateAssets(); | ||
525 | return m_asset; | ||
526 | } | ||
527 | |||
528 | return null; | ||
529 | } | ||
530 | |||
531 | public void SetOldData(byte[] d) | ||
532 | { | ||
533 | m_oldData = d; | ||
534 | } | ||
535 | |||
536 | private Dictionary<int,UUID> ExtractTexturesFromOldData() | ||
537 | { | ||
538 | Dictionary<int,UUID> result = new Dictionary<int,UUID>(); | ||
539 | if (m_oldData == null) | ||
540 | return result; | ||
541 | |||
542 | string content = System.Text.Encoding.ASCII.GetString(m_oldData); | ||
543 | string[] lines = content.Split(new char[] {'\n'}); | ||
544 | |||
545 | int textures = 0; | ||
546 | |||
547 | foreach (string line in lines) | ||
548 | { | ||
549 | try | ||
550 | { | ||
551 | if (line.StartsWith("textures ")) | ||
552 | { | ||
553 | textures = Convert.ToInt32(line.Substring(9)); | ||
554 | } | ||
555 | else if (textures > 0) | ||
556 | { | ||
557 | string[] parts = line.Split(new char[] {' '}); | ||
558 | |||
559 | UUID tx = new UUID(parts[1]); | ||
560 | int id = Convert.ToInt32(parts[0]); | ||
561 | result[id] = tx; | ||
562 | textures--; | ||
563 | } | ||
564 | } | ||
565 | catch | ||
566 | { | ||
567 | // If it's malformed, skip it | ||
568 | } | ||
569 | } | ||
570 | |||
571 | return result; | ||
572 | } | ||
424 | } | 573 | } |
425 | } \ No newline at end of file | 574 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index 4299726..7113f4f 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -160,6 +160,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
160 | { | 160 | { |
161 | byte[] fileData = NewFiles[fileName].Data; | 161 | byte[] fileData = NewFiles[fileName].Data; |
162 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | 162 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); |
163 | if (fileName.StartsWith("inventory_")) | ||
164 | transaction.isTaskInventory = true; | ||
163 | 165 | ||
164 | Transfers.Add(xferID, transaction); | 166 | Transfers.Add(xferID, transaction); |
165 | 167 | ||
@@ -243,6 +245,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
243 | public uint Packet = 0; | 245 | public uint Packet = 0; |
244 | public uint Serial = 1; | 246 | public uint Serial = 1; |
245 | public ulong XferID = 0; | 247 | public ulong XferID = 0; |
248 | public bool isTaskInventory = false; | ||
246 | 249 | ||
247 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) | 250 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) |
248 | { | 251 | { |
@@ -268,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
268 | byte[] transferData = new byte[Data.Length + 4]; | 271 | byte[] transferData = new byte[Data.Length + 4]; |
269 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | 272 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); |
270 | Array.Copy(Data, 0, transferData, 4, Data.Length); | 273 | Array.Copy(Data, 0, transferData, 4, Data.Length); |
271 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | 274 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData, isTaskInventory); |
272 | complete = true; | 275 | complete = true; |
273 | } | 276 | } |
274 | else | 277 | else |
@@ -276,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
276 | byte[] transferData = new byte[1000 + 4]; | 279 | byte[] transferData = new byte[1000 + 4]; |
277 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | 280 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); |
278 | Array.Copy(Data, 0, transferData, 4, 1000); | 281 | Array.Copy(Data, 0, transferData, 4, 1000); |
279 | Client.SendXferPacket(XferID, 0, transferData); | 282 | Client.SendXferPacket(XferID, 0, transferData, isTaskInventory); |
280 | Packet++; | 283 | Packet++; |
281 | DataPointer = 1000; | 284 | DataPointer = 1000; |
282 | } | 285 | } |
@@ -297,7 +300,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
297 | { | 300 | { |
298 | byte[] transferData = new byte[1000]; | 301 | byte[] transferData = new byte[1000]; |
299 | Array.Copy(Data, DataPointer, transferData, 0, 1000); | 302 | Array.Copy(Data, DataPointer, transferData, 0, 1000); |
300 | Client.SendXferPacket(XferID, Packet, transferData); | 303 | Client.SendXferPacket(XferID, Packet, transferData, isTaskInventory); |
301 | Packet++; | 304 | Packet++; |
302 | DataPointer += 1000; | 305 | DataPointer += 1000; |
303 | } | 306 | } |
@@ -306,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
306 | byte[] transferData = new byte[Data.Length - DataPointer]; | 309 | byte[] transferData = new byte[Data.Length - DataPointer]; |
307 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); | 310 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); |
308 | uint endPacket = Packet |= (uint) 0x80000000; | 311 | uint endPacket = Packet |= (uint) 0x80000000; |
309 | Client.SendXferPacket(XferID, endPacket, transferData); | 312 | Client.SendXferPacket(XferID, endPacket, transferData, isTaskInventory); |
310 | Packet++; | 313 | Packet++; |
311 | DataPointer += (Data.Length - DataPointer); | 314 | DataPointer += (Data.Length - DataPointer); |
312 | 315 | ||