aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs6
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs186
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs11
4 files changed, 183 insertions, 24 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 b67c0df..f489262 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..e13f479 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using 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);
@@ -242,10 +260,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
242 { 260 {
243 CompleteTaskItemUpdate(m_updateTaskItemData); 261 CompleteTaskItemUpdate(m_updateTaskItemData);
244 } 262 }
245// else if (m_storeLocal) 263 else if (m_asset.Local)
246// { 264 {
247// m_Scene.AssetService.Store(m_asset); 265 m_Scene.AssetService.Store(m_asset);
248// } 266 }
249 } 267 }
250 268
251 m_log.DebugFormat( 269 m_log.DebugFormat(
@@ -373,6 +391,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
373// m_asset.FullID, item.Name, ourClient.Name); 391// m_asset.FullID, item.Name, ourClient.Name);
374 392
375 m_Scene.AssetService.Store(m_asset); 393 m_Scene.AssetService.Store(m_asset);
394 if (m_asset.FullID != UUID.Zero)
395 {
396 item.AssetID = m_asset.FullID;
397 m_Scene.InventoryService.UpdateItem(item);
398 }
376 399
377 m_transactions.RemoveXferUploader(m_transactionID); 400 m_transactions.RemoveXferUploader(m_transactionID);
378 } 401 }
@@ -394,6 +417,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
394 417
395 private void CompleteCreateItem(uint callbackID) 418 private void CompleteCreateItem(uint callbackID)
396 { 419 {
420 ValidateAssets();
397 m_Scene.AssetService.Store(m_asset); 421 m_Scene.AssetService.Store(m_asset);
398 422
399 InventoryItemBase item = new InventoryItemBase(); 423 InventoryItemBase item = new InventoryItemBase();
@@ -414,6 +438,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
414 item.Flags = (uint) wearableType; 438 item.Flags = (uint) wearableType;
415 item.CreationDate = Util.UnixTimeSinceEpoch(); 439 item.CreationDate = Util.UnixTimeSinceEpoch();
416 440
441 m_log.DebugFormat("[XFER]: Created item {0} with asset {1}",
442 item.ID, item.AssetID);
443
417 if (m_Scene.AddInventoryItem(item)) 444 if (m_Scene.AddInventoryItem(item))
418 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 445 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
419 else 446 else
@@ -421,5 +448,132 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
421 448
422 m_transactions.RemoveXferUploader(m_transactionID); 449 m_transactions.RemoveXferUploader(m_transactionID);
423 } 450 }
451
452 private void ValidateAssets()
453 {
454 if (m_asset.Type == (sbyte)AssetType.Clothing ||
455 m_asset.Type == (sbyte)AssetType.Bodypart)
456 {
457 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
458 string[] lines = content.Split(new char[] {'\n'});
459
460 List<string> validated = new List<string>();
461
462 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
463
464 int textures = 0;
465
466 foreach (string line in lines)
467 {
468 try
469 {
470 if (line.StartsWith("textures "))
471 {
472 textures = Convert.ToInt32(line.Substring(9));
473 validated.Add(line);
474 }
475 else if (textures > 0)
476 {
477 string[] parts = line.Split(new char[] {' '});
478
479 UUID tx = new UUID(parts[1]);
480 int id = Convert.ToInt32(parts[0]);
481
482 if (defaultIDs.Contains(tx) || tx == UUID.Zero ||
483 (allowed.ContainsKey(id) && allowed[id] == tx))
484 {
485 validated.Add(parts[0] + " " + tx.ToString());
486 }
487 else
488 {
489 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
490 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
491
492 if ((perms & full) != full)
493 {
494 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
495 validated.Add(parts[0] + " " + UUID.Zero.ToString());
496 }
497 else
498 {
499 validated.Add(line);
500 }
501 }
502 textures--;
503 }
504 else
505 {
506 validated.Add(line);
507 }
508 }
509 catch
510 {
511 // If it's malformed, skip it
512 }
513 }
514
515 string final = String.Join("\n", validated.ToArray());
516
517 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
518 }
519 }
520
521 /// <summary>
522 /// Get the asset data uploaded in this transfer.
523 /// </summary>
524 /// <returns>null if the asset has not finished uploading</returns>
525 public AssetBase GetAssetData()
526 {
527 if (m_uploadState == UploadState.Complete)
528 {
529 ValidateAssets();
530 return m_asset;
531 }
532
533 return null;
534 }
535
536 public void SetOldData(byte[] d)
537 {
538 m_oldData = d;
539 }
540
541 private Dictionary<int,UUID> ExtractTexturesFromOldData()
542 {
543 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
544 if (m_oldData == null)
545 return result;
546
547 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
548 string[] lines = content.Split(new char[] {'\n'});
549
550 int textures = 0;
551
552 foreach (string line in lines)
553 {
554 try
555 {
556 if (line.StartsWith("textures "))
557 {
558 textures = Convert.ToInt32(line.Substring(9));
559 }
560 else if (textures > 0)
561 {
562 string[] parts = line.Split(new char[] {' '});
563
564 UUID tx = new UUID(parts[1]);
565 int id = Convert.ToInt32(parts[0]);
566 result[id] = tx;
567 textures--;
568 }
569 }
570 catch
571 {
572 // If it's malformed, skip it
573 }
574 }
575
576 return result;
577 }
424 } 578 }
425} \ No newline at end of file 579}
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