aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-01-10 20:19:38 +0000
committerJustin Clark-Casey (justincc)2014-01-10 20:19:38 +0000
commit5e72de19088a753b0607454d59039d5b54f64695 (patch)
tree59dab06d7a41aff10ba595f814caa9b1823564c6 /OpenSim
parentMerge branch 'justincc-master' (diff)
parentWhen creating a coalesced object, set its permissions to the lowest-common-de... (diff)
downloadopensim-SC_OLD-5e72de19088a753b0607454d59039d5b54f64695.zip
opensim-SC_OLD-5e72de19088a753b0607454d59039d5b54f64695.tar.gz
opensim-SC_OLD-5e72de19088a753b0607454d59039d5b54f64695.tar.bz2
opensim-SC_OLD-5e72de19088a753b0607454d59039d5b54f64695.tar.xz
Merge branch 'justincc-master'
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs12
-rw-r--r--OpenSim/Framework/PermissionsUtil.cs87
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs115
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs58
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs85
8 files changed, 240 insertions, 145 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 354f587..811781c 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -2763,15 +2763,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2763 /// </summary> 2763 /// </summary>
2764 private void ApplyNextOwnerPermissions(InventoryItemBase item) 2764 private void ApplyNextOwnerPermissions(InventoryItemBase item)
2765 { 2765 {
2766 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 2766 if (item.InvType == (int)InventoryType.Object)
2767 { 2767 {
2768 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 2768 uint perms = item.CurrentPermissions;
2769 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 2769 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
2770 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 2770 item.CurrentPermissions = perms;
2771 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
2772 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
2773 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
2774 } 2771 }
2772
2775 item.CurrentPermissions &= item.NextPermissions; 2773 item.CurrentPermissions &= item.NextPermissions;
2776 item.BasePermissions &= item.NextPermissions; 2774 item.BasePermissions &= item.NextPermissions;
2777 item.EveryOnePermissions &= item.NextPermissions; 2775 item.EveryOnePermissions &= item.NextPermissions;
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
new file mode 100644
index 0000000..d785a78
--- /dev/null
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33
34namespace OpenSim.Framework
35{
36 public static class PermissionsUtil
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 /// <summary>
41 /// Logs permissions flags. Useful when debugging permission problems.
42 /// </summary>
43 /// <param name="message"></param>
44 public static void LogPermissions(String name, String message, uint basePerm, uint curPerm, uint nextPerm)
45 {
46 m_log.DebugFormat("Permissions of \"{0}\" at \"{1}\": Base {2} ({3:X4}), Current {4} ({5:X4}), NextOwner {6} ({7:X4})",
47 name, message,
48 PermissionsToString(basePerm), basePerm, PermissionsToString(curPerm), curPerm, PermissionsToString(nextPerm), nextPerm);
49 }
50
51 /// <summary>
52 /// Converts a permissions bit-mask to a string (e.g., "MCT").
53 /// </summary>
54 private static string PermissionsToString(uint perms)
55 {
56 string str = "";
57 if ((perms & (int)PermissionMask.Modify) != 0)
58 str += "M";
59 if ((perms & (int)PermissionMask.Copy) != 0)
60 str += "C";
61 if ((perms & (int)PermissionMask.Transfer) != 0)
62 str += "T";
63 if (str == "")
64 str = ".";
65 return str;
66 }
67
68 /// <summary>
69 /// Applies an object's folded permissions to its regular permissions.
70 /// </summary>
71 /// <param name="foldedPerms">The folded permissions. Only the lowest 7 bits are examined.</param>
72 /// <param name="mainPerms">The permissions variable to modify.</param>
73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
74 {
75 if ((foldedPerms & 7) == 0)
76 return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
77
78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
79 mainPerms &= ~(uint)PermissionMask.Copy;
80 if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0)
81 mainPerms &= ~(uint)PermissionMask.Transfer;
82 if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0)
83 mainPerms &= ~(uint)PermissionMask.Modify;
84 }
85
86 }
87}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 831922e..781cc69 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -412,17 +412,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
412 412
413 if (item == null) 413 if (item == null)
414 return null; 414 return null;
415
416 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
417 item.CreatorData = objlist[0].RootPart.CreatorData;
415 418
416 // Can't know creator is the same, so null it in inventory
417 if (objlist.Count > 1) 419 if (objlist.Count > 1)
418 { 420 {
419 item.CreatorId = UUID.Zero.ToString();
420 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; 421 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
422
423 // If the objects have different creators then don't specify a creator at all
424 foreach (SceneObjectGroup objectGroup in objlist)
425 {
426 if ((objectGroup.RootPart.CreatorID.ToString() != item.CreatorId)
427 || (objectGroup.RootPart.CreatorData.ToString() != item.CreatorData))
428 {
429 item.CreatorId = UUID.Zero.ToString();
430 item.CreatorData = string.Empty;
431 break;
432 }
433 }
421 } 434 }
422 else 435 else
423 { 436 {
424 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
425 item.CreatorData = objlist[0].RootPart.CreatorData;
426 item.SaleType = objlist[0].RootPart.ObjectSaleType; 437 item.SaleType = objlist[0].RootPart.ObjectSaleType;
427 item.SalePrice = objlist[0].RootPart.SalePrice; 438 item.SalePrice = objlist[0].RootPart.SalePrice;
428 } 439 }
@@ -443,13 +454,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
443 } 454 }
444 else 455 else
445 { 456 {
446 AddPermissions(item, objlist[0], objlist, remoteClient);
447
448 item.CreationDate = Util.UnixTimeSinceEpoch(); 457 item.CreationDate = Util.UnixTimeSinceEpoch();
449 item.Description = asset.Description; 458 item.Description = asset.Description;
450 item.Name = asset.Name; 459 item.Name = asset.Name;
451 item.AssetType = asset.Type; 460 item.AssetType = asset.Type;
452 461
462 AddPermissions(item, objlist[0], objlist, remoteClient);
463
453 m_Scene.AddInventoryItem(item); 464 m_Scene.AddInventoryItem(item);
454 465
455 if (remoteClient != null && item.Owner == remoteClient.AgentId) 466 if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -491,39 +502,42 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
491 IClientAPI remoteClient) 502 IClientAPI remoteClient)
492 { 503 {
493 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; 504 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
505 uint allObjectsNextOwnerPerms = 0x7fffffff;
506 uint allObjectsEveryOnePerms = 0x7fffffff;
507 uint allObjectsGroupPerms = 0x7fffffff;
508
494 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 509 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
510 {
495 effectivePerms &= grp.GetEffectivePermissions(); 511 effectivePerms &= grp.GetEffectivePermissions();
512 allObjectsNextOwnerPerms &= grp.RootPart.NextOwnerMask;
513 allObjectsEveryOnePerms &= grp.RootPart.EveryoneMask;
514 allObjectsGroupPerms &= grp.RootPart.GroupMask;
515 }
496 effectivePerms |= (uint)PermissionMask.Move; 516 effectivePerms |= (uint)PermissionMask.Move;
497 517
518 //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
519
498 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 520 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
499 { 521 {
500 uint perms = effectivePerms; 522 uint perms = effectivePerms;
501 uint nextPerms = (perms & 7) << 13; 523 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
502 if ((nextPerms & (uint)PermissionMask.Copy) == 0) 524
503 perms &= ~(uint)PermissionMask.Copy; 525 item.BasePermissions = perms & allObjectsNextOwnerPerms;
504 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
505 perms &= ~(uint)PermissionMask.Transfer;
506 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
507 perms &= ~(uint)PermissionMask.Modify;
508
509 item.BasePermissions = perms & so.RootPart.NextOwnerMask;
510 item.CurrentPermissions = item.BasePermissions; 526 item.CurrentPermissions = item.BasePermissions;
511 item.NextPermissions = perms & so.RootPart.NextOwnerMask; 527 item.NextPermissions = perms & allObjectsNextOwnerPerms;
512 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; 528 item.EveryOnePermissions = allObjectsEveryOnePerms & allObjectsNextOwnerPerms;
513 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; 529 item.GroupPermissions = allObjectsGroupPerms & allObjectsNextOwnerPerms;
514 530
515 // Magic number badness. Maybe this deserves an enum. 531 // apply next owner perms on rez
516 // bit 4 (16) is the "Slam" bit, it means treat as passed 532 item.CurrentPermissions |= SceneObjectGroup.SLAM;
517 // and apply next owner perms on rez
518 item.CurrentPermissions |= 16; // Slam!
519 } 533 }
520 else 534 else
521 { 535 {
522 item.BasePermissions = effectivePerms; 536 item.BasePermissions = effectivePerms;
523 item.CurrentPermissions = effectivePerms; 537 item.CurrentPermissions = effectivePerms;
524 item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; 538 item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms;
525 item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; 539 item.EveryOnePermissions = allObjectsEveryOnePerms & effectivePerms;
526 item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; 540 item.GroupPermissions = allObjectsGroupPerms & effectivePerms;
527 541
528 item.CurrentPermissions &= 542 item.CurrentPermissions &=
529 ((uint)PermissionMask.Copy | 543 ((uint)PermissionMask.Copy |
@@ -532,8 +546,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
532 (uint)PermissionMask.Move | 546 (uint)PermissionMask.Move |
533 (uint)PermissionMask.Export | 547 (uint)PermissionMask.Export |
534 7); // Preserve folded permissions 548 7); // Preserve folded permissions
535 } 549 }
536 550
551 //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
552
537 return item; 553 return item;
538 } 554 }
539 555
@@ -809,11 +825,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
809 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; 825 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint;
810 } 826 }
811 827
812 foreach (SceneObjectPart part in group.Parts) 828 if (item == null)
813 { 829 {
814 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. 830 // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here.
815 part.LastOwnerID = part.OwnerID; 831 foreach (SceneObjectPart part in group.Parts)
816 part.OwnerID = remoteClient.AgentId; 832 {
833 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset.
834 part.LastOwnerID = part.OwnerID;
835 part.OwnerID = remoteClient.AgentId;
836 }
817 } 837 }
818 838
819 if (!attachment) 839 if (!attachment)
@@ -969,44 +989,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
969// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", 989// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
970// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 990// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
971 991
972 if ((rootPart.OwnerID != item.Owner) || 992 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0)
973 (item.CurrentPermissions & 16) != 0)
974 { 993 {
975 //Need to kill the for sale here 994 //Need to kill the for sale here
976 rootPart.ObjectSaleType = 0; 995 rootPart.ObjectSaleType = 0;
977 rootPart.SalePrice = 10; 996 rootPart.SalePrice = 10;
978
979 if (m_Scene.Permissions.PropagatePermissions())
980 {
981 foreach (SceneObjectPart part in so.Parts)
982 {
983 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
984 {
985 part.EveryoneMask = item.EveryOnePermissions;
986 part.NextOwnerMask = item.NextPermissions;
987 }
988 part.GroupMask = 0; // DO NOT propagate here
989 }
990
991 so.ApplyNextOwnerPermissions();
992 }
993 } 997 }
994 998
995 foreach (SceneObjectPart part in so.Parts) 999 foreach (SceneObjectPart part in so.Parts)
996 { 1000 {
997 part.FromUserInventoryItemID = fromUserInventoryItemId; 1001 part.FromUserInventoryItemID = fromUserInventoryItemId;
998 1002 part.ApplyPermissionsOnRez(item, true, m_Scene);
999 if ((part.OwnerID != item.Owner) ||
1000 (item.CurrentPermissions & 16) != 0)
1001 {
1002 part.Inventory.ChangeInventoryOwner(item.Owner);
1003 part.GroupMask = 0; // DO NOT propagate here
1004 }
1005
1006 part.EveryoneMask = item.EveryOnePermissions;
1007 part.NextOwnerMask = item.NextPermissions;
1008 } 1003 }
1009 1004
1010 rootPart.TrimPermissions(); 1005 rootPart.TrimPermissions();
1011 1006
1012 if (isAttachment) 1007 if (isAttachment)
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 22a53a8..0cb574a 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -198,13 +198,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
198 item.InvType = (int)InventoryType.Object; 198 item.InvType = (int)InventoryType.Object;
199 item.Folder = categoryID; 199 item.Folder = categoryID;
200 200
201 uint nextPerms=(perms & 7) << 13; 201 PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
202 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
203 perms &= ~(uint)PermissionMask.Copy;
204 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
205 perms &= ~(uint)PermissionMask.Transfer;
206 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
207 perms &= ~(uint)PermissionMask.Modify;
208 202
209 item.BasePermissions = perms & part.NextOwnerMask; 203 item.BasePermissions = perms & part.NextOwnerMask;
210 item.CurrentPermissions = perms & part.NextOwnerMask; 204 item.CurrentPermissions = perms & part.NextOwnerMask;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 65536db..9cc5cde 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -669,17 +669,13 @@ namespace OpenSim.Region.Framework.Scenes
669 // a mask 669 // a mask
670 if (item.InvType == (int)InventoryType.Object) 670 if (item.InvType == (int)InventoryType.Object)
671 { 671 {
672 // Create a safe mask for the current perms
673 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
674 foldedPerms |= permsMask;
675
676 bool isRootMod = (item.CurrentPermissions & 672 bool isRootMod = (item.CurrentPermissions &
677 (uint)PermissionMask.Modify) != 0 ? 673 (uint)PermissionMask.Modify) != 0 ?
678 true : false; 674 true : false;
679 675
680 // Mask the owner perms to the folded perms 676 // Mask the owner perms to the folded perms
681 ownerPerms &= foldedPerms; 677 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms);
682 basePerms &= foldedPerms; 678 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms);
683 679
684 // If the root was mod, let the mask reflect that 680 // If the root was mod, let the mask reflect that
685 // We also need to adjust the base here, because 681 // We also need to adjust the base here, because
@@ -1209,9 +1205,16 @@ namespace OpenSim.Region.Framework.Scenes
1209 { 1205 {
1210 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1206 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
1211 if (taskItem.InvType == (int)InventoryType.Object) 1207 if (taskItem.InvType == (int)InventoryType.Object)
1212 agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move)); 1208 {
1209 uint perms = taskItem.CurrentPermissions;
1210 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
1211 agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1212 agentItem.CurrentPermissions = agentItem.BasePermissions;
1213 }
1213 else 1214 else
1215 {
1214 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 1216 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
1217 }
1215 1218
1216 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 1219 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
1217 agentItem.NextPermissions = taskItem.NextPermissions; 1220 agentItem.NextPermissions = taskItem.NextPermissions;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index a2e4417..9548200 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -109,6 +109,9 @@ namespace OpenSim.Region.Framework.Scenes
109 STATUS_ROTATE_Z = 0x008, 109 STATUS_ROTATE_Z = 0x008,
110 } 110 }
111 111
112 // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm
113 public static readonly uint SLAM = 16;
114
112 // private PrimCountTaintedDelegate handlerPrimCountTainted = null; 115 // private PrimCountTaintedDelegate handlerPrimCountTainted = null;
113 116
114 /// <summary> 117 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ea9d0d8..1cf7726 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4800,6 +4800,64 @@ namespace OpenSim.Region.Framework.Scenes
4800 { 4800 {
4801 ParentGroup.AddScriptLPS(count); 4801 ParentGroup.AddScriptLPS(count);
4802 } 4802 }
4803
4804 /// <summary>
4805 /// Sets a prim's owner and permissions when it's rezzed.
4806 /// </summary>
4807 /// <param name="item">The inventory item from which the item was rezzed</param>
4808 /// <param name="userInventory">True: the item is being rezzed from the user's inventory. False: from a prim's inventory.</param>
4809 /// <param name="scene">The scene the prim is being rezzed into</param>
4810 public void ApplyPermissionsOnRez(InventoryItemBase item, bool userInventory, Scene scene)
4811 {
4812 if ((OwnerID != item.Owner) || ((item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) || ((item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0))
4813 {
4814 if (scene.Permissions.PropagatePermissions())
4815 {
4816 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
4817 {
4818 // Apply the item's permissions to the object
4819 //LogPermissions("Before applying item permissions");
4820 if (userInventory)
4821 {
4822 EveryoneMask = item.EveryOnePermissions;
4823 NextOwnerMask = item.NextPermissions;
4824 }
4825 else
4826 {
4827 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
4828 EveryoneMask = item.EveryOnePermissions;
4829 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
4830 NextOwnerMask = item.NextPermissions;
4831 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
4832 GroupMask = item.GroupPermissions;
4833 }
4834 //LogPermissions("After applying item permissions");
4835 }
4836 }
4837
4838 GroupMask = 0; // DO NOT propagate here
4839 }
4840
4841 if (OwnerID != item.Owner)
4842 {
4843 //LogPermissions("Before ApplyNextOwnerPermissions");
4844 ApplyNextOwnerPermissions();
4845 //LogPermissions("After ApplyNextOwnerPermissions");
4846
4847 LastOwnerID = OwnerID;
4848 OwnerID = item.Owner;
4849 Inventory.ChangeInventoryOwner(item.Owner);
4850 }
4851 }
4852
4853 /// <summary>
4854 /// Logs the prim's permissions. Useful when debugging permission problems.
4855 /// </summary>
4856 /// <param name="message"></param>
4857 private void LogPermissions(String message)
4858 {
4859 PermissionsUtil.LogPermissions(Name, message, BaseMask, OwnerMask, NextOwnerMask);
4860 }
4803 4861
4804 public void ApplyNextOwnerPermissions() 4862 public void ApplyNextOwnerPermissions()
4805 { 4863 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 380e402..fb8ecd5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -764,48 +764,27 @@ namespace OpenSim.Region.Framework.Scenes
764 // Since renaming the item in the inventory does not affect the name stored 764 // Since renaming the item in the inventory does not affect the name stored
765 // in the serialization, transfer the correct name from the inventory to the 765 // in the serialization, transfer the correct name from the inventory to the
766 // object itself before we rez. 766 // object itself before we rez.
767 rootPart.Name = item.Name; 767 // Only do these for the first object if we are rezzing a coalescence.
768 rootPart.Description = item.Description; 768 if (i == 0)
769
770 SceneObjectPart[] partList = group.Parts;
771
772 group.SetGroup(m_part.GroupID, null);
773
774 // TODO: Remove magic number badness
775 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
776 { 769 {
777 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) 770 rootPart.Name = item.Name;
778 { 771 rootPart.Description = item.Description;
779 foreach (SceneObjectPart part in partList)
780 {
781 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
782 part.EveryoneMask = item.EveryonePermissions;
783 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
784 part.NextOwnerMask = item.NextPermissions;
785 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
786 part.GroupMask = item.GroupPermissions;
787 }
788
789 group.ApplyNextOwnerPermissions();
790 }
791 } 772 }
792 773
793 foreach (SceneObjectPart part in partList) 774 group.SetGroup(m_part.GroupID, null);
794 {
795 // TODO: Remove magic number badness
796 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
797 {
798 part.LastOwnerID = part.OwnerID;
799 part.OwnerID = item.OwnerID;
800 part.Inventory.ChangeInventoryOwner(item.OwnerID);
801 }
802 775
803 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 776 foreach (SceneObjectPart part in group.Parts)
804 part.EveryoneMask = item.EveryonePermissions; 777 {
805 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) 778 // Convert between InventoryItem classes. You can never have too many similar but slightly different classes :)
806 part.NextOwnerMask = item.NextPermissions; 779 InventoryItemBase dest = new InventoryItemBase(item.ItemID, item.OwnerID);
807 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) 780 dest.BasePermissions = item.BasePermissions;
808 part.GroupMask = item.GroupPermissions; 781 dest.CurrentPermissions = item.CurrentPermissions;
782 dest.EveryOnePermissions = item.EveryonePermissions;
783 dest.GroupPermissions = item.GroupPermissions;
784 dest.NextPermissions = item.NextPermissions;
785 dest.Flags = item.Flags;
786
787 part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene);
809 } 788 }
810 789
811 rootPart.TrimPermissions(); 790 rootPart.TrimPermissions();
@@ -1130,25 +1109,6 @@ namespace OpenSim.Region.Framework.Scenes
1130 mask &= ~((uint)PermissionMask.Transfer >> 13); 1109 mask &= ~((uint)PermissionMask.Transfer >> 13);
1131 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) 1110 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
1132 mask &= ~((uint)PermissionMask.Modify >> 13); 1111 mask &= ~((uint)PermissionMask.Modify >> 13);
1133
1134 if (item.InvType != (int)InventoryType.Object)
1135 {
1136 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
1137 mask &= ~((uint)PermissionMask.Copy >> 13);
1138 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
1139 mask &= ~((uint)PermissionMask.Transfer >> 13);
1140 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
1141 mask &= ~((uint)PermissionMask.Modify >> 13);
1142 }
1143 else
1144 {
1145 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1146 mask &= ~((uint)PermissionMask.Copy >> 13);
1147 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
1148 mask &= ~((uint)PermissionMask.Transfer >> 13);
1149 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1150 mask &= ~((uint)PermissionMask.Modify >> 13);
1151 }
1152 1112
1153 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1113 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1154 mask &= ~(uint)PermissionMask.Copy; 1114 mask &= ~(uint)PermissionMask.Copy;
@@ -1172,14 +1132,11 @@ namespace OpenSim.Region.Framework.Scenes
1172// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", 1132// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}",
1173// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); 1133// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions);
1174 1134
1175 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 1135 if (item.InvType == (int)InventoryType.Object)
1176 { 1136 {
1177 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 1137 uint perms = item.CurrentPermissions;
1178 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 1138 PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
1179 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 1139 item.CurrentPermissions = perms;
1180 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
1181 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1182 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1183 } 1140 }
1184 1141
1185 item.CurrentPermissions &= item.NextPermissions; 1142 item.CurrentPermissions &= item.NextPermissions;