diff options
author | UbitUmarov | 2017-07-28 17:36:40 +0100 |
---|---|---|
committer | UbitUmarov | 2017-07-28 17:36:40 +0100 |
commit | 21b71ff1d857239c919ad275db5aacbf0cb6331e (patch) | |
tree | dc08d6d95a8e1d88c84ccd458a2e2e8d814391a7 /OpenSim/Region | |
parent | mantis 8218 make Meshmerizer UseMeshiesPhysicsMesh defualt to true, to match ... (diff) | |
download | opensim-SC-21b71ff1d857239c919ad275db5aacbf0cb6331e.zip opensim-SC-21b71ff1d857239c919ad275db5aacbf0cb6331e.tar.gz opensim-SC-21b71ff1d857239c919ad275db5aacbf0cb6331e.tar.bz2 opensim-SC-21b71ff1d857239c919ad275db5aacbf0cb6331e.tar.xz |
partial mantis 8219; on creating or updating items (animationsets, wearables) that reference assets, and user does not have permissions on those, abort and warn, instead of silent invalition of the references to those assets, creating a broken item
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | 120 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 15 |
2 files changed, 79 insertions, 56 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index d2aa177..9f15531 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -258,24 +258,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
258 | { | 258 | { |
259 | m_uploadState = UploadState.Complete; | 259 | m_uploadState = UploadState.Complete; |
260 | 260 | ||
261 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); | 261 | bool sucess = true; |
262 | |||
263 | if (m_createItem) | 262 | if (m_createItem) |
264 | { | 263 | { |
265 | CompleteCreateItem(m_createItemCallback); | 264 | sucess = CompleteCreateItem(m_createItemCallback); |
266 | } | 265 | } |
267 | else if (m_updateItem) | 266 | else if (m_updateItem) |
268 | { | 267 | { |
269 | CompleteItemUpdate(m_updateItemData); | 268 | sucess = CompleteItemUpdate(m_updateItemData); |
270 | } | 269 | } |
271 | else if (m_updateTaskItem) | 270 | else if (m_updateTaskItem) |
272 | { | 271 | { |
273 | CompleteTaskItemUpdate(m_updateTaskItemData); | 272 | sucess = CompleteTaskItemUpdate(m_updateTaskItemData); |
274 | } | 273 | } |
275 | else if (m_asset.Local) | 274 | else if (m_asset.Local) |
276 | { | 275 | { |
277 | m_Scene.AssetService.Store(m_asset); | 276 | m_Scene.AssetService.Store(m_asset); |
278 | } | 277 | } |
278 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, sucess, m_asset.FullID); | ||
279 | } | 279 | } |
280 | 280 | ||
281 | m_log.DebugFormat( | 281 | m_log.DebugFormat( |
@@ -411,46 +411,70 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
411 | /// Store the asset for the given item when it has been uploaded. | 411 | /// Store the asset for the given item when it has been uploaded. |
412 | /// </summary> | 412 | /// </summary> |
413 | /// <param name="item"></param> | 413 | /// <param name="item"></param> |
414 | private void CompleteItemUpdate(InventoryItemBase item) | 414 | private bool CompleteItemUpdate(InventoryItemBase item) |
415 | { | 415 | { |
416 | // m_log.DebugFormat( | 416 | // m_log.DebugFormat( |
417 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", | 417 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", |
418 | // m_asset.FullID, item.Name, ourClient.Name); | 418 | // m_asset.FullID, item.Name, ourClient.Name); |
419 | 419 | ||
420 | ValidateAssets(); | 420 | uint perms = ValidateAssets(); |
421 | m_Scene.AssetService.Store(m_asset); | 421 | if(perms == 0) |
422 | if (m_asset.FullID != UUID.Zero) | ||
423 | { | 422 | { |
424 | item.AssetID = m_asset.FullID; | 423 | string error = string.Format("Not enought permissions on asset(s) referenced by item '{0}', update failed", item.Name); |
425 | m_Scene.InventoryService.UpdateItem(item); | 424 | ourClient.SendAlertMessage(error); |
425 | m_transactions.RemoveXferUploader(m_transactionID); | ||
426 | ourClient.SendBulkUpdateInventory(item); // invalid the change item on viewer cache | ||
427 | } | ||
428 | else | ||
429 | { | ||
430 | m_Scene.AssetService.Store(m_asset); | ||
431 | if (m_asset.FullID != UUID.Zero) | ||
432 | { | ||
433 | item.AssetID = m_asset.FullID; | ||
434 | m_Scene.InventoryService.UpdateItem(item); | ||
435 | } | ||
436 | ourClient.SendInventoryItemCreateUpdate(item, m_transactionID, 0); | ||
437 | m_transactions.RemoveXferUploader(m_transactionID); | ||
438 | m_Scene.EventManager.TriggerOnNewInventoryItemUploadComplete(item, 0); | ||
426 | } | 439 | } |
427 | 440 | ||
428 | ourClient.SendInventoryItemCreateUpdate(item, m_transactionID, 0); | 441 | return perms != 0; |
429 | |||
430 | m_transactions.RemoveXferUploader(m_transactionID); | ||
431 | |||
432 | m_Scene.EventManager.TriggerOnNewInventoryItemUploadComplete(item, 0); | ||
433 | } | 442 | } |
434 | 443 | ||
435 | /// <summary> | 444 | /// <summary> |
436 | /// Store the asset for the given task item when it has been uploaded. | 445 | /// Store the asset for the given task item when it has been uploaded. |
437 | /// </summary> | 446 | /// </summary> |
438 | /// <param name="taskItem"></param> | 447 | /// <param name="taskItem"></param> |
439 | private void CompleteTaskItemUpdate(TaskInventoryItem taskItem) | 448 | private bool CompleteTaskItemUpdate(TaskInventoryItem taskItem) |
440 | { | 449 | { |
441 | // m_log.DebugFormat( | 450 | // m_log.DebugFormat( |
442 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", | 451 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", |
443 | // m_asset.FullID, taskItem.Name, ourClient.Name); | 452 | // m_asset.FullID, taskItem.Name, ourClient.Name); |
444 | 453 | ||
445 | ValidateAssets(); | 454 | if(ValidateAssets() == 0) |
446 | m_Scene.AssetService.Store(m_asset); | 455 | { |
456 | m_transactions.RemoveXferUploader(m_transactionID); | ||
457 | string error = string.Format("Not enought permissions on asset(s) referenced by task item '{0}', update failed", taskItem.Name); | ||
458 | ourClient.SendAlertMessage(error); | ||
459 | // force old asset to viewers ?? | ||
460 | return false; | ||
461 | } | ||
447 | 462 | ||
463 | m_Scene.AssetService.Store(m_asset); | ||
448 | m_transactions.RemoveXferUploader(m_transactionID); | 464 | m_transactions.RemoveXferUploader(m_transactionID); |
465 | return true; | ||
449 | } | 466 | } |
450 | 467 | ||
451 | private void CompleteCreateItem(uint callbackID) | 468 | private bool CompleteCreateItem(uint callbackID) |
452 | { | 469 | { |
453 | ValidateAssets(); | 470 | if(ValidateAssets() == 0) |
471 | { | ||
472 | m_transactions.RemoveXferUploader(m_transactionID); | ||
473 | string error = string.Format("Not enought permissions on asset(s) referenced by item '{0}', creation failed", m_name); | ||
474 | ourClient.SendAlertMessage(error); | ||
475 | return false; | ||
476 | } | ||
477 | |||
454 | m_Scene.AssetService.Store(m_asset); | 478 | m_Scene.AssetService.Store(m_asset); |
455 | 479 | ||
456 | InventoryItemBase item = new InventoryItemBase(); | 480 | InventoryItemBase item = new InventoryItemBase(); |
@@ -480,35 +504,40 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
480 | ourClient.SendAlertMessage("Unable to create inventory item"); | 504 | ourClient.SendAlertMessage("Unable to create inventory item"); |
481 | 505 | ||
482 | m_transactions.RemoveXferUploader(m_transactionID); | 506 | m_transactions.RemoveXferUploader(m_transactionID); |
507 | return true; | ||
483 | } | 508 | } |
484 | 509 | ||
485 | 510 | private uint ValidateAssets() | |
486 | private void ValidateAssets() | ||
487 | { | 511 | { |
512 | uint retPerms = 0x7fffffff; | ||
513 | // if(m_Scene.Permissions.BypassPermissions()) | ||
514 | // return retPerms; | ||
515 | |||
488 | if (m_asset.Type == (sbyte)CustomAssetType.AnimationSet) | 516 | if (m_asset.Type == (sbyte)CustomAssetType.AnimationSet) |
489 | { | 517 | { |
518 | |||
490 | AnimationSet animSet = new AnimationSet(m_asset.Data); | 519 | AnimationSet animSet = new AnimationSet(m_asset.Data); |
491 | 520 | ||
492 | bool allOk = animSet.Validate(x => { | 521 | retPerms &= animSet.Validate(x => { |
493 | int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, x); | 522 | const uint required = (uint)(PermissionMask.Transfer | PermissionMask.Copy); |
494 | int required = (int)(PermissionMask.Transfer | PermissionMask.Copy); | 523 | uint perms = (uint)m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, x); |
524 | // currrent yes/no rule | ||
495 | if ((perms & required) != required) | 525 | if ((perms & required) != required) |
496 | return false; | 526 | return 0; |
497 | return true; | 527 | return perms; |
498 | }); | 528 | }); |
499 | 529 | ||
500 | if (!allOk) | 530 | return retPerms; |
501 | m_asset.Data = animSet.ToBytes(); | ||
502 | } | 531 | } |
503 | 532 | ||
504 | if (m_asset.Type == (sbyte)AssetType.Clothing || | 533 | if (m_asset.Type == (sbyte)AssetType.Clothing || |
505 | m_asset.Type == (sbyte)AssetType.Bodypart) | 534 | m_asset.Type == (sbyte)AssetType.Bodypart) |
506 | { | 535 | { |
536 | const uint texturesfullPermMask = (uint)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy); | ||
507 | string content = System.Text.Encoding.ASCII.GetString(m_asset.Data); | 537 | string content = System.Text.Encoding.ASCII.GetString(m_asset.Data); |
508 | string[] lines = content.Split(new char[] {'\n'}); | 538 | string[] lines = content.Split(new char[] {'\n'}); |
509 | 539 | ||
510 | List<string> validated = new List<string>(); | 540 | // on current requiriment of full rigths assume old assets where accepted |
511 | |||
512 | Dictionary<int, UUID> allowed = ExtractTexturesFromOldData(); | 541 | Dictionary<int, UUID> allowed = ExtractTexturesFromOldData(); |
513 | 542 | ||
514 | int textures = 0; | 543 | int textures = 0; |
@@ -518,10 +547,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
518 | try | 547 | try |
519 | { | 548 | { |
520 | if (line.StartsWith("textures ")) | 549 | if (line.StartsWith("textures ")) |
521 | { | ||
522 | textures = Convert.ToInt32(line.Substring(9)); | 550 | textures = Convert.ToInt32(line.Substring(9)); |
523 | validated.Add(line); | 551 | |
524 | } | ||
525 | else if (textures > 0) | 552 | else if (textures > 0) |
526 | { | 553 | { |
527 | string[] parts = line.Split(new char[] {' '}); | 554 | string[] parts = line.Split(new char[] {' '}); |
@@ -532,42 +559,35 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
532 | if (defaultIDs.Contains(tx) || tx == UUID.Zero || | 559 | if (defaultIDs.Contains(tx) || tx == UUID.Zero || |
533 | (allowed.ContainsKey(id) && allowed[id] == tx)) | 560 | (allowed.ContainsKey(id) && allowed[id] == tx)) |
534 | { | 561 | { |
535 | validated.Add(parts[0] + " " + tx.ToString()); | 562 | continue; |
536 | } | 563 | } |
537 | else | 564 | else |
538 | { | 565 | { |
539 | int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx); | 566 | uint perms = (uint)m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx); |
540 | int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy); | ||
541 | 567 | ||
542 | if ((perms & full) != full) | 568 | if ((perms & texturesfullPermMask) != texturesfullPermMask) |
543 | { | 569 | { |
544 | m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); | 570 | m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); |
545 | validated.Add(parts[0] + " " + UUID.Zero.ToString()); | 571 | return 0; |
546 | } | 572 | } |
547 | else | 573 | else |
548 | { | 574 | { |
549 | validated.Add(line); | 575 | retPerms &= perms; |
550 | } | 576 | } |
551 | } | 577 | } |
552 | textures--; | 578 | textures--; |
553 | } | 579 | } |
554 | else | ||
555 | { | ||
556 | validated.Add(line); | ||
557 | } | ||
558 | } | 580 | } |
559 | catch | 581 | catch |
560 | { | 582 | { |
561 | // If it's malformed, skip it | 583 | // If it's malformed, skip it |
562 | } | 584 | } |
563 | } | 585 | } |
564 | |||
565 | string final = String.Join("\n", validated.ToArray()); | ||
566 | |||
567 | m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final); | ||
568 | } | 586 | } |
587 | return retPerms; | ||
569 | } | 588 | } |
570 | 589 | ||
590 | /* not in use | ||
571 | /// <summary> | 591 | /// <summary> |
572 | /// Get the asset data uploaded in this transfer. | 592 | /// Get the asset data uploaded in this transfer. |
573 | /// </summary> | 593 | /// </summary> |
@@ -582,7 +602,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
582 | 602 | ||
583 | return null; | 603 | return null; |
584 | } | 604 | } |
585 | 605 | */ | |
586 | public void SetOldData(byte[] d) | 606 | public void SetOldData(byte[] d) |
587 | { | 607 | { |
588 | m_oldData = d; | 608 | m_oldData = d; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index f1409bb..788ed1c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -299,15 +299,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
299 | else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet) | 299 | else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet) |
300 | { | 300 | { |
301 | AnimationSet animSet = new AnimationSet(data); | 301 | AnimationSet animSet = new AnimationSet(data); |
302 | if (!animSet.Validate(x => { | 302 | uint res = animSet.Validate(x => { |
303 | const int required = (int)(PermissionMask.Transfer | PermissionMask.Copy); | ||
303 | int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x); | 304 | int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x); |
304 | int required = (int)(PermissionMask.Transfer | PermissionMask.Copy); | 305 | // enforce previus perm rule |
305 | if ((perms & required) != required) | 306 | if ((perms & required) != required) |
306 | return false; | 307 | return 0; |
307 | return true; | 308 | return (uint) perms; |
308 | })) | 309 | }); |
310 | if(res == 0) | ||
309 | { | 311 | { |
310 | data = animSet.ToBytes(); | 312 | remoteClient.SendAgentAlertMessage("Not enought permissions on asset(s) referenced by animation set '{0}', update failed", false); |
313 | return UUID.Zero; | ||
311 | } | 314 | } |
312 | } | 315 | } |
313 | 316 | ||