aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-07-14 17:13:04 +0100
committerJustin Clark-Casey (justincc)2010-07-14 17:13:04 +0100
commit0080c3b1f4467224885323e7198c91d7e221f75b (patch)
tree82fcfd5dd7fd3c9df8c467e5a423b792357384b3 /OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
parentFix obvious bug in XInventoryService.GetFolderItems() which was preventing th... (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-0080c3b1f4467224885323e7198c91d7e221f75b.zip
opensim-SC-0080c3b1f4467224885323e7198c91d7e221f75b.tar.gz
opensim-SC-0080c3b1f4467224885323e7198c91d7e221f75b.tar.bz2
opensim-SC-0080c3b1f4467224885323e7198c91d7e221f75b.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs141
1 files changed, 106 insertions, 35 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9ba13ae..2578685 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -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;
467
468 // Mask the base permissions. This is a conservative
469 // approach altering only the three main perms
470 basePerms &= nextPerms;
402 471
403 // Need slam bit on xfer 472 // Assign to the actual item. Make sure the slam bit is
404 itemCopy.CurrentPermissions |= 8; 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
@@ -903,7 +980,7 @@ namespace OpenSim.Region.Framework.Scenes
903 else 980 else
904 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 981 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
905 982
906 agentItem.CurrentPermissions |= 8; 983 agentItem.CurrentPermissions |= 16; // Slam
907 agentItem.NextPermissions = taskItem.NextPermissions; 984 agentItem.NextPermissions = taskItem.NextPermissions;
908 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 985 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
909 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 986 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
@@ -1094,7 +1171,7 @@ namespace OpenSim.Region.Framework.Scenes
1094 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1171 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1095 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1172 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1096 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1173 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1097 destTaskItem.CurrentPermissions |= 8; // Slam! 1174 destTaskItem.CurrentPermissions |= 16; // Slam!
1098 } 1175 }
1099 } 1176 }
1100 1177
@@ -1478,7 +1555,7 @@ namespace OpenSim.Region.Framework.Scenes
1478 srcTaskItem.NextPermissions; 1555 srcTaskItem.NextPermissions;
1479 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1556 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1480 srcTaskItem.NextPermissions; 1557 srcTaskItem.NextPermissions;
1481 destTaskItem.CurrentPermissions |= 8; // Slam! 1558 destTaskItem.CurrentPermissions |= 16; // Slam!
1482 } 1559 }
1483 } 1560 }
1484 1561
@@ -1864,17 +1941,14 @@ namespace OpenSim.Region.Framework.Scenes
1864 1941
1865 group.SetGroup(sourcePart.GroupID, null); 1942 group.SetGroup(sourcePart.GroupID, null);
1866 1943
1867 if (rootPart.OwnerID != item.OwnerID) 1944 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1868 { 1945 {
1869 if (Permissions.PropagatePermissions()) 1946 if (Permissions.PropagatePermissions())
1870 { 1947 {
1871 if ((item.CurrentPermissions & 8) != 0) 1948 foreach (SceneObjectPart part in partList)
1872 { 1949 {
1873 foreach (SceneObjectPart part in partList) 1950 part.EveryoneMask = item.EveryonePermissions;
1874 { 1951 part.NextOwnerMask = item.NextPermissions;
1875 part.EveryoneMask = item.EveryonePermissions;
1876 part.NextOwnerMask = item.NextPermissions;
1877 }
1878 } 1952 }
1879 group.ApplyNextOwnerPermissions(); 1953 group.ApplyNextOwnerPermissions();
1880 } 1954 }
@@ -1882,17 +1956,14 @@ namespace OpenSim.Region.Framework.Scenes
1882 1956
1883 foreach (SceneObjectPart part in partList) 1957 foreach (SceneObjectPart part in partList)
1884 { 1958 {
1885 if (part.OwnerID != item.OwnerID) 1959 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1886 { 1960 {
1887 part.LastOwnerID = part.OwnerID; 1961 part.LastOwnerID = part.OwnerID;
1888 part.OwnerID = item.OwnerID; 1962 part.OwnerID = item.OwnerID;
1889 part.Inventory.ChangeInventoryOwner(item.OwnerID); 1963 part.Inventory.ChangeInventoryOwner(item.OwnerID);
1890 } 1964 }
1891 else if ((item.CurrentPermissions & 8) != 0) // Slam! 1965 part.EveryoneMask = item.EveryonePermissions;
1892 { 1966 part.NextOwnerMask = item.NextPermissions;
1893 part.EveryoneMask = item.EveryonePermissions;
1894 part.NextOwnerMask = item.NextPermissions;
1895 }
1896 } 1967 }
1897 1968
1898 rootPart.TrimPermissions(); 1969 rootPart.TrimPermissions();