aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs209
1 files changed, 167 insertions, 42 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f9da341..01edf51 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes
73 IMoneyModule money=RequestModuleInterface<IMoneyModule>(); 73 IMoneyModule money=RequestModuleInterface<IMoneyModule>();
74 if (money != null) 74 if (money != null)
75 { 75 {
76 money.ApplyUploadCharge(agentID); 76 money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload");
77 } 77 }
78 78
79 AddInventoryItem(agentID, item); 79 AddInventoryItem(agentID, item);
@@ -265,6 +265,10 @@ namespace OpenSim.Region.Framework.Scenes
265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
266 UUID itemID, InventoryItemBase itemUpd) 266 UUID itemID, InventoryItemBase itemUpd)
267 { 267 {
268 // This one will let people set next perms on items in agent
269 // inventory. Rut-Roh. Whatever. Make this secure. Yeah.
270 //
271 // Passing something to another avatar or a an object will already
268 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 272 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
269 item = InventoryService.GetItem(item); 273 item = InventoryService.GetItem(item);
270 274
@@ -274,11 +278,9 @@ namespace OpenSim.Region.Framework.Scenes
274 { 278 {
275 item.Name = itemUpd.Name; 279 item.Name = itemUpd.Name;
276 item.Description = itemUpd.Description; 280 item.Description = itemUpd.Description;
277 item.NextPermissions = itemUpd.NextPermissions; 281 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
278 item.CurrentPermissions |= 8; // Slam! 282 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
279 item.EveryOnePermissions = itemUpd.EveryOnePermissions; 283 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
280 item.GroupPermissions = itemUpd.GroupPermissions;
281
282 item.GroupID = itemUpd.GroupID; 284 item.GroupID = itemUpd.GroupID;
283 item.GroupOwned = itemUpd.GroupOwned; 285 item.GroupOwned = itemUpd.GroupOwned;
284 item.CreationDate = itemUpd.CreationDate; 286 item.CreationDate = itemUpd.CreationDate;
@@ -384,28 +386,103 @@ namespace OpenSim.Region.Framework.Scenes
384 386
385 if (Permissions.PropagatePermissions() && recipient != senderId) 387 if (Permissions.PropagatePermissions() && recipient != senderId)
386 { 388 {
387 // First, make sore base is limited to the next perms 389 // Trying to do this right this time. This is evil. If
388 itemCopy.BasePermissions = item.BasePermissions & (item.NextPermissions | (uint)PermissionMask.Move); 390 // you believe in Good, go elsewhere. Vampires and other
389 // By default, current equals base 391 // evil creatores only beyond this point. You have been
390 itemCopy.CurrentPermissions = itemCopy.BasePermissions & item.CurrentPermissions; 392 // warned.
391 393
392 // If this is an object, replace current perms 394 // We're going to mask a lot of things by the next perms
393 // with folded perms 395 // Tweak the next perms to be nicer to our data
396 //
397 // In this mask, all the bits we do NOT want to mess
398 // with are set. These are:
399 //
400 // Transfer
401 // Copy
402 // Modufy
403 uint permsMask = ~ ((uint)PermissionMask.Copy |
404 (uint)PermissionMask.Transfer |
405 (uint)PermissionMask.Modify);
406
407 // Now, reduce the next perms to the mask bits
408 // relevant to the operation
409 uint nextPerms = permsMask | (item.NextPermissions &
410 ((uint)PermissionMask.Copy |
411 (uint)PermissionMask.Transfer |
412 (uint)PermissionMask.Modify));
413
414 // nextPerms now has all bits set, except for the actual
415 // next permission bits.
416
417 // This checks for no mod, no copy, no trans.
418 // This indicates an error or messed up item. Do it like
419 // SL and assume trans
420 if (nextPerms == permsMask)
421 nextPerms |= (uint)PermissionMask.Transfer;
422
423 // Inventory owner perms are the logical AND of the
424 // folded perms and the root prim perms, however, if
425 // the root prim is mod, the inventory perms will be
426 // mod. This happens on "take" and is of little concern
427 // here, save for preventing escalation
428
429 // This hack ensures that items previously permalocked
430 // get unlocked when they're passed or rezzed
431 uint basePerms = item.BasePermissions |
432 (uint)PermissionMask.Move;
433 uint ownerPerms = item.CurrentPermissions;
434
435 // If this is an object, root prim perms may be more
436 // permissive than folded perms. Use folded perms as
437 // a mask
394 if (item.InvType == (int)InventoryType.Object) 438 if (item.InvType == (int)InventoryType.Object)
395 { 439 {
396 itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); 440 // Create a safe mask for the current perms
397 itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13; 441 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
442 foldedPerms |= permsMask;
443
444 bool isRootMod = (item.CurrentPermissions &
445 (uint)PermissionMask.Modify) != 0 ?
446 true : false;
447
448 // Mask the owner perms to the folded perms
449 ownerPerms &= foldedPerms;
450 basePerms &= foldedPerms;
451
452 // If the root was mod, let the mask reflect that
453 // We also need to adjust the base here, because
454 // we should be able to edit in-inventory perms
455 // for the root prim, if it's mod.
456 if (isRootMod)
457 {
458 ownerPerms |= (uint)PermissionMask.Modify;
459 basePerms |= (uint)PermissionMask.Modify;
460 }
398 } 461 }
399 462
400 // Ensure there is no escalation 463 // These will be applied to the root prim at next rez.
401 itemCopy.CurrentPermissions &= (item.NextPermissions | (uint)PermissionMask.Move); 464 // The slam bit (bit 3) and folded permission (bits 0-2)
465 // are preserved due to the above mangling
466 ownerPerms &= nextPerms;
402 467
403 // Need slam bit on xfer 468 // Mask the base permissions. This is a conservative
404 itemCopy.CurrentPermissions |= 8; 469 // approach altering only the three main perms
470 basePerms &= nextPerms;
471
472 // Assign to the actual item. Make sure the slam bit is
473 // set, if it wasn't set before.
474 itemCopy.BasePermissions = basePerms;
475 itemCopy.CurrentPermissions = ownerPerms | 16; // Slam
405 476
406 itemCopy.NextPermissions = item.NextPermissions; 477 itemCopy.NextPermissions = item.NextPermissions;
407 478
408 itemCopy.EveryOnePermissions = 0; 479 // This preserves "everyone can move"
480 itemCopy.EveryOnePermissions = item.EveryOnePermissions &
481 nextPerms;
482
483 // Intentionally killing "share with group" here, as
484 // the recipient will not have the group this is
485 // set to
409 itemCopy.GroupPermissions = 0; 486 itemCopy.GroupPermissions = 0;
410 } 487 }
411 else 488 else
@@ -839,6 +916,9 @@ namespace OpenSim.Region.Framework.Scenes
839 SceneObjectGroup group = part.ParentGroup; 916 SceneObjectGroup group = part.ParentGroup;
840 if (group != null) 917 if (group != null)
841 { 918 {
919 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
920 return;
921
842 TaskInventoryItem item = group.GetInventoryItem(localID, itemID); 922 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
843 if (item == null) 923 if (item == null)
844 return; 924 return;
@@ -903,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes
903 else 983 else
904 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 984 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
905 985
906 agentItem.CurrentPermissions |= 8; 986 agentItem.CurrentPermissions |= 16; // Slam
907 agentItem.NextPermissions = taskItem.NextPermissions; 987 agentItem.NextPermissions = taskItem.NextPermissions;
908 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 988 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
909 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 989 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
@@ -978,9 +1058,21 @@ namespace OpenSim.Region.Framework.Scenes
978 return; 1058 return;
979 } 1059 }
980 1060
981 // Only owner can copy 1061 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemId);
982 if (remoteClient.AgentId != taskItem.OwnerID) 1062 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
983 return; 1063 {
1064 // If the item to be moved is no copy, we need to be able to
1065 // edit the prim.
1066 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1067 return;
1068 }
1069 else
1070 {
1071 // If the item is copiable, then we just need to have perms
1072 // on it. The delete check is a pure rights check
1073 if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId))
1074 return;
1075 }
984 1076
985 MoveTaskInventoryItem(remoteClient, folderId, part, itemId); 1077 MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
986 } 1078 }
@@ -1094,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes
1094 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1186 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1095 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1187 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1096 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1188 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1097 destTaskItem.CurrentPermissions |= 8; // Slam! 1189 destTaskItem.CurrentPermissions |= 16; // Slam!
1098 } 1190 }
1099 } 1191 }
1100 1192
@@ -1263,10 +1355,48 @@ namespace OpenSim.Region.Framework.Scenes
1263 { 1355 {
1264 agentTransactions.HandleTaskItemUpdateFromTransaction( 1356 agentTransactions.HandleTaskItemUpdateFromTransaction(
1265 remoteClient, part, transactionID, currentItem); 1357 remoteClient, part, transactionID, currentItem);
1358
1359 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1360 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1361 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1362 remoteClient.SendAgentAlertMessage("Script saved", false);
1363 else
1364 remoteClient.SendAgentAlertMessage("Item saved", false);
1365 }
1366
1367 // Base ALWAYS has move
1368 currentItem.BasePermissions |= (uint)PermissionMask.Move;
1369
1370 // Check if we're allowed to mess with permissions
1371 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god
1372 {
1373 if (remoteClient.AgentId != part.OwnerID) // Not owner
1374 {
1375 // Friends and group members can't change any perms
1376 itemInfo.BasePermissions = currentItem.BasePermissions;
1377 itemInfo.EveryonePermissions = currentItem.EveryonePermissions;
1378 itemInfo.GroupPermissions = currentItem.GroupPermissions;
1379 itemInfo.NextPermissions = currentItem.NextPermissions;
1380 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1381 }
1382 else
1383 {
1384 // Owner can't change base, and can change other
1385 // only up to base
1386 itemInfo.BasePermissions = currentItem.BasePermissions;
1387 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1388 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1389 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1390 itemInfo.NextPermissions &= currentItem.BasePermissions;
1391 }
1392
1266 } 1393 }
1394
1395 // Next ALWAYS has move
1396 itemInfo.NextPermissions |= (uint)PermissionMask.Move;
1397
1267 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1398 if (part.Inventory.UpdateInventoryItem(itemInfo))
1268 { 1399 {
1269 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1270 part.GetProperties(remoteClient); 1400 part.GetProperties(remoteClient);
1271 } 1401 }
1272 } 1402 }
@@ -1478,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes
1478 srcTaskItem.NextPermissions; 1608 srcTaskItem.NextPermissions;
1479 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1609 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1480 srcTaskItem.NextPermissions; 1610 srcTaskItem.NextPermissions;
1481 destTaskItem.CurrentPermissions |= 8; // Slam! 1611 destTaskItem.CurrentPermissions |= 16; // Slam!
1482 } 1612 }
1483 } 1613 }
1484 1614
@@ -1597,7 +1727,7 @@ namespace OpenSim.Region.Framework.Scenes
1597 } 1727 }
1598 1728
1599 // Handle god perms 1729 // Handle god perms
1600 if (Permissions.IsGod(remoteClient.AgentId)) 1730 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1601 { 1731 {
1602 permissionToTake = true; 1732 permissionToTake = true;
1603 permissionToTakeCopy = true; 1733 permissionToTakeCopy = true;
@@ -1608,7 +1738,7 @@ namespace OpenSim.Region.Framework.Scenes
1608 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1738 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1609 permissionToDelete = false; 1739 permissionToDelete = false;
1610 1740
1611 // if we want to take a copy,, we also don't want to delete 1741 // if we want to take a copy, we also don't want to delete
1612 // Note: after this point, the permissionToTakeCopy flag 1742 // Note: after this point, the permissionToTakeCopy flag
1613 // becomes irrelevant. It already includes the permissionToTake 1743 // becomes irrelevant. It already includes the permissionToTake
1614 // permission and after excluding no copy items here, we can 1744 // permission and after excluding no copy items here, we can
@@ -1619,6 +1749,7 @@ namespace OpenSim.Region.Framework.Scenes
1619 if (!permissionToTakeCopy) 1749 if (!permissionToTakeCopy)
1620 return; 1750 return;
1621 1751
1752 permissionToTake = true;
1622 // Don't delete 1753 // Don't delete
1623 permissionToDelete = false; 1754 permissionToDelete = false;
1624 } 1755 }
@@ -1863,17 +1994,14 @@ namespace OpenSim.Region.Framework.Scenes
1863 1994
1864 group.SetGroup(sourcePart.GroupID, null); 1995 group.SetGroup(sourcePart.GroupID, null);
1865 1996
1866 if (rootPart.OwnerID != item.OwnerID) 1997 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1867 { 1998 {
1868 if (Permissions.PropagatePermissions()) 1999 if (Permissions.PropagatePermissions())
1869 { 2000 {
1870 if ((item.CurrentPermissions & 8) != 0) 2001 foreach (SceneObjectPart part in partList)
1871 { 2002 {
1872 foreach (SceneObjectPart part in partList) 2003 part.EveryoneMask = item.EveryonePermissions;
1873 { 2004 part.NextOwnerMask = item.NextPermissions;
1874 part.EveryoneMask = item.EveryonePermissions;
1875 part.NextOwnerMask = item.NextPermissions;
1876 }
1877 } 2005 }
1878 group.ApplyNextOwnerPermissions(); 2006 group.ApplyNextOwnerPermissions();
1879 } 2007 }
@@ -1881,17 +2009,14 @@ namespace OpenSim.Region.Framework.Scenes
1881 2009
1882 foreach (SceneObjectPart part in partList) 2010 foreach (SceneObjectPart part in partList)
1883 { 2011 {
1884 if (part.OwnerID != item.OwnerID) 2012 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1885 { 2013 {
1886 part.LastOwnerID = part.OwnerID; 2014 part.LastOwnerID = part.OwnerID;
1887 part.OwnerID = item.OwnerID; 2015 part.OwnerID = item.OwnerID;
1888 part.Inventory.ChangeInventoryOwner(item.OwnerID); 2016 part.Inventory.ChangeInventoryOwner(item.OwnerID);
1889 } 2017 }
1890 else if ((item.CurrentPermissions & 8) != 0) // Slam! 2018 part.EveryoneMask = item.EveryonePermissions;
1891 { 2019 part.NextOwnerMask = item.NextPermissions;
1892 part.EveryoneMask = item.EveryonePermissions;
1893 part.NextOwnerMask = item.NextPermissions;
1894 }
1895 } 2020 }
1896 2021
1897 rootPart.TrimPermissions(); 2022 rootPart.TrimPermissions();