aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs47
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs1622
-rw-r--r--OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs3
11 files changed, 1064 insertions, 726 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8b8ac20..cf188aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -481,14 +481,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
482// group.Name, group.LocalId, sp.Name, attachmentPt, silent); 482// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
483 483
484 if (sp.GetAttachments().Contains(group))
485 {
486// m_log.WarnFormat(
487// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
488// group.Name, group.LocalId, sp.Name, AttachmentPt);
489
490 return false;
491 }
492 484
493 if (group.GetSittingAvatarsCount() != 0) 485 if (group.GetSittingAvatarsCount() != 0)
494 { 486 {
@@ -500,6 +492,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
500 return false; 492 return false;
501 } 493 }
502 494
495 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
496 if (attachments.Contains(group))
497 {
498// if (DebugLevel > 0)
499// m_log.WarnFormat(
500// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
501// group.Name, group.LocalId, sp.Name, attachmentPt);
502
503 return false;
504 }
505
503 Vector3 attachPos = group.AbsolutePosition; 506 Vector3 attachPos = group.AbsolutePosition;
504 507
505 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 508 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@@ -533,7 +536,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
533 { 536 {
534 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; 537 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint;
535 attachPos = group.RootPart.AttachedPos; 538 attachPos = group.RootPart.AttachedPos;
536 group.HasGroupChanged = true;
537 } 539 }
538 540
539 // if we still didn't find a suitable attachment point....... 541 // if we still didn't find a suitable attachment point.......
@@ -544,18 +546,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
544 attachPos = Vector3.Zero; 546 attachPos = Vector3.Zero;
545 } 547 }
546 548
547 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
548
549 if (attachments.Contains(group))
550 {
551 if (DebugLevel > 0)
552 m_log.WarnFormat(
553 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
554 group.Name, group.LocalId, sp.Name, attachmentPt);
555
556 return false;
557 }
558
559 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones 549 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
560 while (attachments.Count >= 5) 550 while (attachments.Count >= 5)
561 { 551 {
@@ -579,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
579 lock (sp.AttachmentsSyncLock) 569 lock (sp.AttachmentsSyncLock)
580 { 570 {
581 group.AttachmentPoint = attachmentPt; 571 group.AttachmentPoint = attachmentPt;
582 group.AbsolutePosition = attachPos; 572 group.RootPart.AttachedPos = attachPos;
583 573
584 if (addToInventory && sp.PresenceType != PresenceType.Npc) 574 if (addToInventory && sp.PresenceType != PresenceType.Npc)
585 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 575 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
@@ -956,7 +946,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
956 m_scene.DeleteFromStorage(so.UUID); 946 m_scene.DeleteFromStorage(so.UUID);
957 m_scene.EventManager.TriggerParcelPrimCountTainted(); 947 m_scene.EventManager.TriggerParcelPrimCountTainted();
958 948
959 so.AttachedAvatar = sp.UUID;
960 949
961 foreach (SceneObjectPart part in so.Parts) 950 foreach (SceneObjectPart part in so.Parts)
962 { 951 {
@@ -969,11 +958,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
969 } 958 }
970 } 959 }
971 960
972 so.AbsolutePosition = attachOffset;
973 so.RootPart.AttachedPos = attachOffset;
974 so.IsAttachment = true;
975 so.RootPart.SetParentLocalId(sp.LocalId); 961 so.RootPart.SetParentLocalId(sp.LocalId);
962 so.AttachedAvatar = sp.UUID;
976 so.AttachmentPoint = attachmentpoint; 963 so.AttachmentPoint = attachmentpoint;
964 so.RootPart.AttachedPos = attachOffset;
965 so.AbsolutePosition = attachOffset;
966 so.IsAttachment = true;
977 967
978 sp.AddAttachment(so); 968 sp.AddAttachment(so);
979 969
@@ -1322,7 +1312,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1322 if (part == null) 1312 if (part == null)
1323 return; 1313 return;
1324 1314
1325 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 1315 SceneObjectGroup group = part.ParentGroup;
1316
1317 if (!m_scene.Permissions.CanTakeObject(group, sp))
1326 { 1318 {
1327 remoteClient.SendAgentAlertMessage( 1319 remoteClient.SendAgentAlertMessage(
1328 "You don't have sufficient permissions to attach this object", false); 1320 "You don't have sufficient permissions to attach this object", false);
@@ -1334,7 +1326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1334 AttachmentPt &= 0x7f; 1326 AttachmentPt &= 0x7f;
1335 1327
1336 // Calls attach with a Zero position 1328 // Calls attach with a Zero position
1337 SceneObjectGroup group = part.ParentGroup;
1338 if (AttachObject(sp, group , AttachmentPt, false, true, append)) 1329 if (AttachObject(sp, group , AttachmentPt, false, true, append))
1339 { 1330 {
1340 if (DebugLevel > 0) 1331 if (DebugLevel > 0)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 6dc982b..92485a1 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -2620,7 +2620,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2620 { 2620 {
2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete 2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete
2622 // it 2622 // it
2623 if (!Scene.Permissions.CanObjectEntry(so.UUID, true, so.AbsolutePosition)) 2623 if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition))
2624 { 2624 {
2625 // Deny non attachments based on parcel settings 2625 // Deny non attachments based on parcel settings
2626 // 2626 //
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 95e7456..ba3a7c9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -541,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
541 541
542 #region Permissions 542 #region Permissions
543 543
544 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 544 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
545 { 545 {
546 if (m_bypassPermissions) return true; 546 if (m_bypassPermissions) return true;
547 547
548 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) 548 if(sp == null || sog == null)
549 return false;
550
551 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID))
549 { 552 {
550 SceneObjectGroup sog = null; 553 if (sog.OwnerID == sp.UUID)
551 if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer)
552 return true; 554 return true;
553
554 return false; 555 return false;
555 } 556 }
556 557
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index b37744d..67c847b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -427,20 +427,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
427 originalRotations[objectGroup.UUID] = inventoryStoredRotation; 427 originalRotations[objectGroup.UUID] = inventoryStoredRotation;
428 428
429 // Restore attachment data after trip through the sim 429 // Restore attachment data after trip through the sim
430 if (objectGroup.RootPart.AttachPoint > 0) 430 if (objectGroup.AttachmentPoint > 0)
431 { 431 {
432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos; 432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos;
433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation; 433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
434 } 434 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
435 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
436 objectGroup.RootPart.Shape.LastAttachPoint = (byte)objectGroup.AttachmentPoint;
435 437
436 // Trees could be attached and it's been done, but it makes
437 // no sense. State must be preserved because it's the tree type
438 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
439 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
440 {
441 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
442 if (objectGroup.RootPart.AttachPoint > 0)
443 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
444 } 438 }
445 439
446 objectGroup.AbsolutePosition = inventoryStoredPosition; 440 objectGroup.AbsolutePosition = inventoryStoredPosition;
@@ -1139,8 +1133,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1139 foreach (SceneObjectPart part in so.Parts) 1133 foreach (SceneObjectPart part in so.Parts)
1140 { 1134 {
1141 part.GroupMask = 0; // DO NOT propagate here 1135 part.GroupMask = 0; // DO NOT propagate here
1142 1136 if( part.OwnerID != part.GroupID)
1143 part.LastOwnerID = part.OwnerID; 1137 part.LastOwnerID = part.OwnerID;
1144 part.OwnerID = item.Owner; 1138 part.OwnerID = item.Owner;
1145 part.RezzerID = item.Owner; 1139 part.RezzerID = item.Owner;
1146 part.Inventory.ChangeInventoryOwner(item.Owner); 1140 part.Inventory.ChangeInventoryOwner(item.Owner);
@@ -1180,6 +1174,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1180 part.NextOwnerMask = item.NextPermissions & part.BaseMask; 1174 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1181 } 1175 }
1182 } 1176 }
1177
1183 } 1178 }
1184 } 1179 }
1185 else 1180 else
@@ -1198,6 +1193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1198 } 1193 }
1199 1194
1200 rootPart.TrimPermissions(); 1195 rootPart.TrimPermissions();
1196 so.AggregateDeepPerms();
1201 1197
1202 if (isAttachment) 1198 if (isAttachment)
1203 so.FromItemID = item.ID; 1199 so.FromItemID = item.ID;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 5d12f8b..53b9796 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -149,9 +149,11 @@ namespace OpenSim.Region.CoreModules.World.Land
149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache 149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0); 150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
151 151
152 m_scene.EventManager.OnObjectAddedToScene += EventManagerOnParcelPrimCountAdd;
152 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 153 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
153 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 154
154 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; 155 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
156 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
155 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; 157 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
156 158
157 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 159 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
@@ -287,8 +289,10 @@ namespace OpenSim.Region.CoreModules.World.Land
287 289
288 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, 290 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
289 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); 291 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
290 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 292 LandData ldata = fullSimParcel.LandData;
291 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 293 ldata.SimwideArea = ldata.Area;
294 ldata.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
295 ldata.ClaimDate = Util.UnixTimeSinceEpoch();
292 296
293 return AddLandObject(fullSimParcel); 297 return AddLandObject(fullSimParcel);
294 } 298 }
@@ -813,6 +817,9 @@ namespace OpenSim.Region.CoreModules.World.Land
813 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 817 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
814 } 818 }
815 819
820 if(m_landList.Count == 0 || m_landIDList == null)
821 return null;
822
816 lock (m_landIDList) 823 lock (m_landIDList)
817 { 824 {
818 try 825 try
@@ -824,8 +831,6 @@ namespace OpenSim.Region.CoreModules.World.Land
824 return null; 831 return null;
825 } 832 }
826 } 833 }
827
828 return m_landList[m_landIDList[x / 4, y / 4]];
829 } 834 }
830 835
831 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID 836 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
@@ -1576,6 +1581,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1576 } 1581 }
1577 } 1582 }
1578 } 1583 }
1584 FinalizeLandPrimCountUpdate(); // update simarea information
1579 } 1585 }
1580 } 1586 }
1581 1587
@@ -1640,9 +1646,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1640 foreach (HashSet<SceneObjectGroup> objs in returns.Values) 1646 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1641 { 1647 {
1642 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs); 1648 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
1643 if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2)) 1649 if (m_scene.Permissions.CanReturnObjects(null, remoteClient, objs2))
1644 { 1650 {
1645 m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId); 1651 m_scene.returnObjects(objs2.ToArray(), remoteClient);
1646 } 1652 }
1647 else 1653 else
1648 { 1654 {
@@ -2035,7 +2041,7 @@ namespace OpenSim.Region.CoreModules.World.Land
2035 { 2041 {
2036 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 2042 SceneObjectGroup[] objs = new SceneObjectGroup[1];
2037 objs[0] = obj; 2043 objs[0] = obj;
2038 ((Scene)client.Scene).returnObjects(objs, client.AgentId); 2044 ((Scene)client.Scene).returnObjects(objs, client);
2039 } 2045 }
2040 2046
2041 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 2047 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 73b4cb5..9d84e66 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -356,6 +356,7 @@ namespace OpenSim.Region.CoreModules.World.Land
356 } 356 }
357 } 357 }
358 358
359 // the total prims a parcel owner can have on a region
359 public int GetSimulatorMaxPrimCount() 360 public int GetSimulatorMaxPrimCount()
360 { 361 {
361 if (overrideSimulatorMaxPrimCount != null) 362 if (overrideSimulatorMaxPrimCount != null)
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.World.Land
370 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus 371 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus
371 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) 372 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)
372 +0.5 ); 373 +0.5 );
373 374 // sanity check
374 if(simMax > m_scene.RegionInfo.ObjectCapacity) 375 if(simMax > m_scene.RegionInfo.ObjectCapacity)
375 simMax = m_scene.RegionInfo.ObjectCapacity; 376 simMax = m_scene.RegionInfo.ObjectCapacity;
376 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", 377 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}",
@@ -1043,7 +1044,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1043 else 1044 else
1044 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); 1045 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]);
1045 1046
1046 LandData.Area = tempArea * landUnit * landUnit; 1047 tempArea *= landUnit * landUnit;
1048 LandData.Area = tempArea;
1047 } 1049 }
1048 1050
1049 #endregion 1051 #endregion
@@ -1648,7 +1650,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1648 foreach (SceneObjectGroup obj in primsOverMe) 1650 foreach (SceneObjectGroup obj in primsOverMe)
1649 { 1651 {
1650 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero && 1652 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero &&
1651 (obj.GetEffectivePermissions() & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0) 1653 (obj.EffectiveOwnerPerms & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0)
1652 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0); 1654 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0);
1653 } 1655 }
1654 } 1656 }
@@ -1662,7 +1664,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1662 { 1664 {
1663 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 1665 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1664 objs[0] = obj; 1666 objs[0] = obj;
1665 m_scene.returnObjects(objs, obj.OwnerID); 1667 m_scene.returnObjects(objs, null);
1666 } 1668 }
1667 1669
1668 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 1670 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
@@ -1693,6 +1695,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1693 { 1695 {
1694 if (obj.GroupID == LandData.GroupID) 1696 if (obj.GroupID == LandData.GroupID)
1695 { 1697 {
1698 if (obj.OwnerID == LandData.OwnerID)
1699 continue;
1696 if (!returns.ContainsKey(obj.OwnerID)) 1700 if (!returns.ContainsKey(obj.OwnerID))
1697 returns[obj.OwnerID] = 1701 returns[obj.OwnerID] =
1698 new List<SceneObjectGroup>(); 1702 new List<SceneObjectGroup>();
@@ -1734,8 +1738,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1734 1738
1735 foreach (List<SceneObjectGroup> ol in returns.Values) 1739 foreach (List<SceneObjectGroup> ol in returns.Values)
1736 { 1740 {
1737 if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) 1741 if (m_scene.Permissions.CanReturnObjects(this, remote_client, ol))
1738 m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); 1742 m_scene.returnObjects(ol.ToArray(), remote_client);
1739 } 1743 }
1740 } 1744 }
1741 1745
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 857f919..2a720db 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -92,10 +92,8 @@ namespace OpenSim.Region.CoreModules.World.Land
92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this); 92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
93 93
94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; 94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene;
96 OnObjectBeingRemovedFromScene; 96 m_Scene.EventManager.OnParcelPrimCountTainted += OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnParcelPrimCountTainted +=
98 OnParcelPrimCountTainted;
99 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); }; 97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
100 } 98 }
101 99
@@ -215,29 +213,15 @@ namespace OpenSim.Region.CoreModules.World.Land
215 else 213 else
216 parcelCounts.Users[obj.OwnerID] = partCount; 214 parcelCounts.Users[obj.OwnerID] = partCount;
217 215
218 if (obj.IsSelected) 216 if (obj.IsSelected || obj.GetSittingAvatarsCount() > 0)
219 {
220 parcelCounts.Selected += partCount; 217 parcelCounts.Selected += partCount;
221 } 218
219 if (obj.OwnerID == landData.OwnerID)
220 parcelCounts.Owner += partCount;
221 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
222 parcelCounts.Group += partCount;
222 else 223 else
223 { 224 parcelCounts.Others += partCount;
224 if (landData.IsGroupOwned)
225 {
226 if (obj.OwnerID == landData.GroupID)
227 parcelCounts.Owner += partCount;
228 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
229 parcelCounts.Group += partCount;
230 else
231 parcelCounts.Others += partCount;
232 }
233 else
234 {
235 if (obj.OwnerID == landData.OwnerID)
236 parcelCounts.Owner += partCount;
237 else
238 parcelCounts.Others += partCount;
239 }
240 }
241 } 225 }
242 } 226 }
243 227
@@ -393,7 +377,6 @@ namespace OpenSim.Region.CoreModules.World.Land
393 count = counts.Owner; 377 count = counts.Owner;
394 count += counts.Group; 378 count += counts.Group;
395 count += counts.Others; 379 count += counts.Others;
396 count += counts.Selected;
397 } 380 }
398 } 381 }
399 382
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index 0d8ece7..a349aa1 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
151 151
152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); 152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false); 153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); 154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, m_userId, UUID.Zero, Quaternion.Identity, false);
155 155
156 Assert.That(pc.Owner, Is.EqualTo(6)); 156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0)); 157 Assert.That(pc.Group, Is.EqualTo(0));
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2837358..142c8b7 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
98 if (part.OwnerID == part.GroupID) // Group owned 98 if (part.OwnerID == part.GroupID) // Group owned
99 { 99 {
100 // Does the user have the power to put the object on sale? 100 // Does the user have the power to put the object on sale?
101 if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID, m_scene)) 101 if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID))
102 { 102 {
103 client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false); 103 client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false);
104 return; 104 return;
@@ -127,7 +127,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
127 switch (saleType) 127 switch (saleType)
128 { 128 {
129 case 1: // Sell as original (in-place sale) 129 case 1: // Sell as original (in-place sale)
130 uint effectivePerms = group.GetEffectivePermissions(); 130 uint effectivePerms = group.EffectiveOwnerPerms;
131 131
132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
133 { 133 {
@@ -136,8 +136,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
136 return false; 136 return false;
137 } 137 }
138 138
139 group.SetOwnerId(remoteClient.AgentId); 139 group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
140 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
141 140
142 if (m_scene.Permissions.PropagatePermissions()) 141 if (m_scene.Permissions.PropagatePermissions())
143 { 142 {
@@ -147,6 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
147 child.TriggerScriptChangedEvent(Changed.OWNER); 146 child.TriggerScriptChangedEvent(Changed.OWNER);
148 child.ApplyNextOwnerPermissions(); 147 child.ApplyNextOwnerPermissions();
149 } 148 }
149 group.AggregatePerms();
150 } 150 }
151 151
152 part.ObjectSaleType = 0; 152 part.ObjectSaleType = 0;
@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
174 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); 174 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
175 group.AbsolutePosition = originalPosition; 175 group.AbsolutePosition = originalPosition;
176 176
177 uint perms = group.GetEffectivePermissions(); 177 uint perms = group.EffectiveOwnerPerms;
178 178
179 if ((perms & (uint)PermissionMask.Transfer) == 0) 179 if ((perms & (uint)PermissionMask.Transfer) == 0)
180 { 180 {
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index b60cd93..279b966 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected Scene m_scene; 51 protected Scene m_scene;
52 protected ScenePermissions scenePermissions;
52 protected bool m_Enabled; 53 protected bool m_Enabled;
53 54
54 private InventoryFolderImpl m_libraryRootFolder; 55 private InventoryFolderImpl m_libraryRootFolder;
@@ -69,15 +70,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
69 } 70 }
70 71
71 #region Constants 72 #region Constants
72 // These are here for testing. They will be taken out
73
74 //private uint PERM_ALL = (uint)2147483647;
75 private uint PERM_COPY = (uint)32768;
76 //private uint PERM_MODIFY = (uint)16384;
77 private uint PERM_MOVE = (uint)524288;
78 private uint PERM_TRANS = (uint)8192;
79 private uint PERM_LOCKED = (uint)540672;
80
81 /// <value> 73 /// <value>
82 /// Different user set names that come in from the configuration file. 74 /// Different user set names that come in from the configuration file.
83 /// </value> 75 /// </value>
@@ -96,14 +88,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
96 private bool m_bypassPermissionsValue = true; 88 private bool m_bypassPermissionsValue = true;
97 private bool m_propagatePermissions = false; 89 private bool m_propagatePermissions = false;
98 private bool m_debugPermissions = false; 90 private bool m_debugPermissions = false;
99 private bool m_allowGridGods = false; 91 private bool m_allowGridAdmins = false;
100 private bool m_RegionOwnerIsGod = false; 92 private bool m_RegionOwnerIsAdmin = false;
101 private bool m_RegionManagerIsGod = false; 93 private bool m_RegionManagerIsAdmin = false;
102 private bool m_forceGridGodsOnly; 94 private bool m_forceGridAdminsOnly;
103 private bool m_forceGodModeAlwaysOn; 95 private bool m_forceAdminModeAlwaysOn;
104 private bool m_allowGodActionsWithoutGodMode; 96 private bool m_allowAdminActionsWithoutGodMode;
105
106 private bool m_SimpleBuildPermissions = false;
107 97
108 /// <value> 98 /// <value>
109 /// The set of users that are allowed to create scripts. This is only active if permissions are not being 99 /// The set of users that are allowed to create scripts. This is only active if permissions are not being
@@ -172,25 +162,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
172 162
173 string[] sections = new string[] { "Startup", "Permissions" }; 163 string[] sections = new string[] { "Startup", "Permissions" };
174 164
175 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false); 165 m_allowGridAdmins = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false);
176 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true); 166 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true);
177 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true); 167 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true);
178 168
179 m_forceGridGodsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false); 169 m_forceGridAdminsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false);
180 if(!m_forceGridGodsOnly) 170 if(!m_forceGridAdminsOnly)
181 { 171 {
182 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true); 172 m_RegionOwnerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true);
183 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false); 173 m_RegionManagerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false);
184 } 174 }
185 else 175 else
186 m_allowGridGods = true; 176 m_allowGridAdmins = true;
187 177
188 m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false); 178 m_forceAdminModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false);
189 m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false); 179 m_allowAdminActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false);
190 if(m_allowGodActionsWithoutGodMode) 180 if(m_allowAdminActionsWithoutGodMode)
191 m_forceGodModeAlwaysOn = false; 181 m_forceAdminModeAlwaysOn = false;
192
193 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions",sections, false);
194 182
195 m_allowedScriptCreators 183 m_allowedScriptCreators
196 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators); 184 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);
@@ -266,63 +254,75 @@ namespace OpenSim.Region.CoreModules.World.Permissions
266 m_scene = scene; 254 m_scene = scene;
267 255
268 scene.RegisterModuleInterface<IPermissionsModule>(this); 256 scene.RegisterModuleInterface<IPermissionsModule>(this);
257 scenePermissions = m_scene.Permissions;
269 258
270 //Register functions with Scene External Checks! 259 //Register functions with Scene External Checks!
271 m_scene.Permissions.OnBypassPermissions += BypassPermissions; 260 scenePermissions.OnBypassPermissions += BypassPermissions;
272 m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions; 261 scenePermissions.OnSetBypassPermissions += SetBypassPermissions;
273 m_scene.Permissions.OnPropagatePermissions += PropagatePermissions; 262 scenePermissions.OnPropagatePermissions += PropagatePermissions;
274 m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags; 263
275 m_scene.Permissions.OnAbandonParcel += CanAbandonParcel; 264 scenePermissions.OnIsGridGod += IsGridAdministrator;
276 m_scene.Permissions.OnReclaimParcel += CanReclaimParcel; 265 scenePermissions.OnIsAdministrator += IsAdministrator;
277 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 266 scenePermissions.OnIsEstateManager += IsEstateManager;
278 m_scene.Permissions.OnDeedObject += CanDeedObject; 267
279 m_scene.Permissions.OnIsGod += IsGod; 268 scenePermissions.OnGenerateClientFlags += GenerateClientFlags;
280 m_scene.Permissions.OnIsGridGod += IsGridGod; 269
281 m_scene.Permissions.OnIsAdministrator += IsAdministrator; 270 scenePermissions.OnIssueEstateCommand += CanIssueEstateCommand;
282 m_scene.Permissions.OnIsEstateManager += IsEstateManager; 271 scenePermissions.OnRunConsoleCommand += CanRunConsoleCommand;
283 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 272
284 m_scene.Permissions.OnDeleteObject += CanDeleteObject; 273 scenePermissions.OnTeleport += CanTeleport;
285 m_scene.Permissions.OnEditObject += CanEditObject; 274
286 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; 275 scenePermissions.OnInstantMessage += CanInstantMessage;
287 m_scene.Permissions.OnInstantMessage += CanInstantMessage; 276
288 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; 277 scenePermissions.OnAbandonParcel += CanAbandonParcel;
289 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; 278 scenePermissions.OnReclaimParcel += CanReclaimParcel;
290 m_scene.Permissions.OnMoveObject += CanMoveObject; 279 scenePermissions.OnDeedParcel += CanDeedParcel;
291 m_scene.Permissions.OnObjectEntry += CanObjectEntry; 280 scenePermissions.OnSellParcel += CanSellParcel;
292 m_scene.Permissions.OnReturnObjects += CanReturnObjects; 281 scenePermissions.OnEditParcelProperties += CanEditParcelProperties;
293 m_scene.Permissions.OnRezObject += CanRezObject; 282 scenePermissions.OnTerraformLand += CanTerraformLand;
294 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; 283 scenePermissions.OnBuyLand += CanBuyLand;
295 m_scene.Permissions.OnRunScript += CanRunScript; 284
296 m_scene.Permissions.OnCompileScript += CanCompileScript; 285 scenePermissions.OnReturnObjects += CanReturnObjects;
297 m_scene.Permissions.OnSellParcel += CanSellParcel; 286
298 m_scene.Permissions.OnTakeObject += CanTakeObject; 287 scenePermissions.OnRezObject += CanRezObject;
299 m_scene.Permissions.OnSellGroupObject += CanSellGroupObject; 288 scenePermissions.OnObjectEntry += CanObjectEntry;
300 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; 289
301 m_scene.Permissions.OnTerraformLand += CanTerraformLand; 290 scenePermissions.OnDuplicateObject += CanDuplicateObject;
302 m_scene.Permissions.OnLinkObject += CanLinkObject; 291 scenePermissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs;
303 m_scene.Permissions.OnDelinkObject += CanDelinkObject; 292 scenePermissions.OnDeleteObject += CanDeleteObject;
304 m_scene.Permissions.OnBuyLand += CanBuyLand; 293 scenePermissions.OnEditObjectByIDs += CanEditObjectByIDs;
305 294 scenePermissions.OnEditObject += CanEditObject;
306 m_scene.Permissions.OnViewNotecard += CanViewNotecard; 295 scenePermissions.OnInventoryTransfer += CanInventoryTransfer;
307 m_scene.Permissions.OnViewScript += CanViewScript; 296 scenePermissions.OnMoveObject += CanMoveObject;
308 m_scene.Permissions.OnEditNotecard += CanEditNotecard; 297 scenePermissions.OnTakeObject += CanTakeObject;
309 m_scene.Permissions.OnEditScript += CanEditScript; 298 scenePermissions.OnTakeCopyObject += CanTakeCopyObject;
310 299 scenePermissions.OnLinkObject += CanLinkObject;
311 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; 300 scenePermissions.OnDelinkObject += CanDelinkObject;
312 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; 301 scenePermissions.OnDeedObject += CanDeedObject;
313 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; 302 scenePermissions.OnSellGroupObject += CanSellGroupObject;
314 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; 303
315 m_scene.Permissions.OnResetScript += CanResetScript; 304 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory;
316 305 scenePermissions.OnEditObjectInventory += CanEditObjectInventory;
317 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; 306 scenePermissions.OnCopyObjectInventory += CanCopyObjectInventory;
318 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; 307 scenePermissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
319 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; 308 scenePermissions.OnDoObjectInvToObjectInv += CanDoObjectInvToObjectInv;
320 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; 309 scenePermissions.OnDropInObjectInv += CanDropInObjectInv;
321 310
322 m_scene.Permissions.OnTeleport += CanTeleport; 311 scenePermissions.OnViewNotecard += CanViewNotecard;
323 312 scenePermissions.OnViewScript += CanViewScript;
324 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; 313 scenePermissions.OnEditNotecard += CanEditNotecard;
325 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; 314 scenePermissions.OnEditScript += CanEditScript;
315 scenePermissions.OnResetScript += CanResetScript;
316 scenePermissions.OnRunScript += CanRunScript;
317 scenePermissions.OnCompileScript += CanCompileScript;
318
319 scenePermissions.OnCreateUserInventory += CanCreateUserInventory;
320 scenePermissions.OnCopyUserInventory += CanCopyUserInventory;
321 scenePermissions.OnEditUserInventory += CanEditUserInventory;
322 scenePermissions.OnDeleteUserInventory += CanDeleteUserInventory;
323
324 scenePermissions.OnControlPrimMedia += CanControlPrimMedia;
325 scenePermissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
326 326
327 m_scene.AddCommand("Users", this, "bypass permissions", 327 m_scene.AddCommand("Users", this, "bypass permissions",
328 "bypass permissions <true / false>", 328 "bypass permissions <true / false>",
@@ -351,6 +351,73 @@ namespace OpenSim.Region.CoreModules.World.Permissions
351 return; 351 return;
352 352
353 m_scene.UnregisterModuleInterface<IPermissionsModule>(this); 353 m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
354
355 scenePermissions.OnBypassPermissions -= BypassPermissions;
356 scenePermissions.OnSetBypassPermissions -= SetBypassPermissions;
357 scenePermissions.OnPropagatePermissions -= PropagatePermissions;
358
359 scenePermissions.OnIsGridGod -= IsGridAdministrator;
360 scenePermissions.OnIsAdministrator -= IsAdministrator;
361 scenePermissions.OnIsEstateManager -= IsEstateManager;
362
363 scenePermissions.OnGenerateClientFlags -= GenerateClientFlags;
364
365 scenePermissions.OnIssueEstateCommand -= CanIssueEstateCommand;
366 scenePermissions.OnRunConsoleCommand -= CanRunConsoleCommand;
367
368 scenePermissions.OnTeleport -= CanTeleport;
369
370 scenePermissions.OnInstantMessage -= CanInstantMessage;
371
372 scenePermissions.OnAbandonParcel -= CanAbandonParcel;
373 scenePermissions.OnReclaimParcel -= CanReclaimParcel;
374 scenePermissions.OnDeedParcel -= CanDeedParcel;
375 scenePermissions.OnSellParcel -= CanSellParcel;
376 scenePermissions.OnEditParcelProperties -= CanEditParcelProperties;
377 scenePermissions.OnTerraformLand -= CanTerraformLand;
378 scenePermissions.OnBuyLand -= CanBuyLand;
379
380 scenePermissions.OnRezObject -= CanRezObject;
381 scenePermissions.OnObjectEntry -= CanObjectEntry;
382 scenePermissions.OnReturnObjects -= CanReturnObjects;
383
384 scenePermissions.OnDuplicateObject -= CanDuplicateObject;
385 scenePermissions.OnDeleteObjectByIDs -= CanDeleteObjectByIDs;
386 scenePermissions.OnDeleteObject -= CanDeleteObject;
387 scenePermissions.OnEditObjectByIDs -= CanEditObjectByIDs;
388 scenePermissions.OnEditObject -= CanEditObject;
389 scenePermissions.OnInventoryTransfer -= CanInventoryTransfer;
390 scenePermissions.OnMoveObject -= CanMoveObject;
391 scenePermissions.OnTakeObject -= CanTakeObject;
392 scenePermissions.OnTakeCopyObject -= CanTakeCopyObject;
393 scenePermissions.OnLinkObject -= CanLinkObject;
394 scenePermissions.OnDelinkObject -= CanDelinkObject;
395 scenePermissions.OnDeedObject -= CanDeedObject;
396 scenePermissions.OnSellGroupObject -= CanSellGroupObject;
397
398 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory;
399 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory;
400 scenePermissions.OnCopyObjectInventory -= CanCopyObjectInventory;
401 scenePermissions.OnDeleteObjectInventory -= CanDeleteObjectInventory;
402 scenePermissions.OnDoObjectInvToObjectInv -= CanDoObjectInvToObjectInv;
403 scenePermissions.OnDropInObjectInv -= CanDropInObjectInv;
404
405 scenePermissions.OnViewNotecard -= CanViewNotecard;
406 scenePermissions.OnViewScript -= CanViewScript;
407 scenePermissions.OnEditNotecard -= CanEditNotecard;
408 scenePermissions.OnEditScript -= CanEditScript;
409 scenePermissions.OnResetScript -= CanResetScript;
410 scenePermissions.OnRunScript -= CanRunScript;
411 scenePermissions.OnCompileScript -= CanCompileScript;
412
413 scenePermissions.OnCreateUserInventory -= CanCreateUserInventory;
414 scenePermissions.OnCopyUserInventory -= CanCopyUserInventory;
415 scenePermissions.OnEditUserInventory -= CanEditUserInventory;
416 scenePermissions.OnDeleteUserInventory -= CanDeleteUserInventory;
417
418 scenePermissions.OnControlPrimMedia -= CanControlPrimMedia;
419 scenePermissions.OnInteractWithPrimMedia -= CanInteractWithPrimMedia;
420
354 } 421 }
355 422
356 public void Close() 423 public void Close()
@@ -479,32 +546,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
479 546
480 return false; 547 return false;
481 } 548 }
482/* 549
483 private bool CheckGroupPowers(ScenePresence sp, UUID groupID, ulong powersMask) 550 protected bool GroupMemberPowers(UUID groupID, UUID userID, ref ulong powers)
484 { 551 {
485 if(sp == null || sp.ControllingClient == null) 552 powers = 0;
553 if (null == GroupsModule)
486 return false; 554 return false;
487
488 ulong grpPowers = sp.ControllingClient.GetGroupPowers(groupID);
489 555
490 return (grpPowers & powersMask) != 0; 556 GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID);
557
558 if (gmd != null)
559 {
560 powers = gmd.GroupPowers;
561 return true;
562 }
563 return false;
491 } 564 }
492 565
493 private bool CheckActiveGroupPowers(ScenePresence sp, UUID groupID, ulong powersMask) 566 protected bool GroupMemberPowers(UUID groupID, ScenePresence sp, ref ulong powers)
494 { 567 {
495 if(sp == null || sp.ControllingClient == null) 568 powers = 0;
496 return false; 569 IClientAPI client = sp.ControllingClient;
497 570 if (client == null)
498 if(sp.ControllingClient.ActiveGroupId != groupID)
499 return false; 571 return false;
500 // activeGroupPowers only get current selected role powers, at least with xmlgroups.
501 // lets get any role avoiding the extra burden of user also having to change role
502 // ulong grpPowers = sp.ControllingClient.ActiveGroupPowers(groupID);
503 ulong grpPowers = sp.ControllingClient.GetGroupPowers(groupID);
504 572
505 return (grpPowers & powersMask) != 0; 573 if(!client.IsGroupMember(groupID))
574 return false;
575
576 powers = client.GetGroupPowers(groupID);
577 return true;
506 } 578 }
507*/ 579
508 /// <summary> 580 /// <summary>
509 /// Parse a user set configuration setting 581 /// Parse a user set configuration setting
510 /// </summary> 582 /// </summary>
@@ -551,13 +623,13 @@ namespace OpenSim.Region.CoreModules.World.Permissions
551 if (user == UUID.Zero) 623 if (user == UUID.Zero)
552 return false; 624 return false;
553 625
554 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) 626 if (m_RegionOwnerIsAdmin && m_scene.RegionInfo.EstateSettings.EstateOwner == user)
555 return true; 627 return true;
556 628
557 if (IsEstateManager(user) && m_RegionManagerIsGod) 629 if (m_RegionManagerIsAdmin && IsEstateManager(user))
558 return true; 630 return true;
559 631
560 if (IsGridGod(user, null)) 632 if (IsGridAdministrator(user))
561 return true; 633 return true;
562 634
563 return false; 635 return false;
@@ -569,14 +641,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
569 /// <param name="user">The user</param> 641 /// <param name="user">The user</param>
570 /// <param name="scene">Unused, can be null</param> 642 /// <param name="scene">Unused, can be null</param>
571 /// <returns></returns> 643 /// <returns></returns>
572 protected bool IsGridGod(UUID user, Scene scene) 644 protected bool IsGridAdministrator(UUID user)
573 { 645 {
574 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 646 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
575 if (m_bypassPermissions) return m_bypassPermissionsValue; 647 if (m_bypassPermissions) return m_bypassPermissionsValue;
576 648
577 if (user == UUID.Zero) return false; 649 if (user == UUID.Zero)
650 return false;
578 651
579 if (m_allowGridGods) 652 if (m_allowGridAdmins)
580 { 653 {
581 ScenePresence sp = m_scene.GetScenePresence(user); 654 ScenePresence sp = m_scene.GetScenePresence(user);
582 if (sp != null) 655 if (sp != null)
@@ -630,8 +703,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
630 } 703 }
631 704
632 #region Object Permissions 705 #region Object Permissions
633#pragma warning disable 0612 706
634 const uint DEFAULT_FLAGS = (uint)~( 707 const uint DEFAULT_FLAGS = (uint)(
635 PrimFlags.ObjectCopy | // Tells client you can copy the object 708 PrimFlags.ObjectCopy | // Tells client you can copy the object
636 PrimFlags.ObjectModify | // tells client you can modify the object 709 PrimFlags.ObjectModify | // tells client you can modify the object
637 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod) 710 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
@@ -650,7 +723,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
650 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object 723 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
651 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object 724 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
652 ); 725 );
653#pragma warning restore 0612
654 726
655 const uint EXTRAOWNERMASK = (uint)( 727 const uint EXTRAOWNERMASK = (uint)(
656 PrimFlags.ObjectYouOwner | 728 PrimFlags.ObjectYouOwner |
@@ -665,49 +737,71 @@ namespace OpenSim.Region.CoreModules.World.Permissions
665 PrimFlags.ObjectMove 737 PrimFlags.ObjectMove
666 ); 738 );
667 739
668 public uint GenerateClientFlags(ScenePresence sp, uint curEffectivePerms, UUID objID) 740 const uint GOD_FLAGS = (uint)(
669 { 741 PrimFlags.ObjectCopy | // Tells client you can copy the object
670 if(sp == null || curEffectivePerms == 0) 742 PrimFlags.ObjectModify | // tells client you can modify the object
671 return (uint)0; 743 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
744 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
745 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
746 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
747 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
748 );
749
750 const uint LOCKED_GOD_FLAGS = (uint)(
751 PrimFlags.ObjectCopy | // Tells client you can copy the object
752 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
753 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
754 PrimFlags.ObjectAnyOwner // Tells client that someone owns the object
755 );
756
757 const uint SHAREDMASK = (uint)(
758 PermissionMask.Move |
759 PermissionMask.Modify |
760 PermissionMask.Copy
761 );
672 762
673 SceneObjectPart task = m_scene.GetSceneObjectPart(objID); 763 public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
764 {
765 if(sp == null || task == null || curEffectivePerms == 0)
766 return 0;
674 767
675 // this shouldn't ever happen.. return no permissions/objectflags.
676 if (task == null)
677 return (uint)0;
678
679 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 768 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
680 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ; 769 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
681 770
682 uint returnMask; 771 uint returnMask;
683 772
684 // gods have owner rights with Modify and Move always on 773 SceneObjectGroup grp = task.ParentGroup;
774 if(grp == null)
775 return 0;
776
777 UUID taskOwnerID = task.OwnerID;
778 UUID spID = sp.UUID;
779
780 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
781
685 if(sp.IsGod) 782 if(sp.IsGod)
686 { 783 {
687 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); 784 // do locked on objects owned by admin
688 returnMask |= EXTRAGODMASK; 785 if(!unlocked && spID == taskOwnerID)
689 return returnMask; 786 return objflags | LOCKED_GOD_FLAGS;
787 else
788 return objflags | GOD_FLAGS;
690 } 789 }
691 790
692 //bypass option == owner rights 791 //bypass option == owner rights
693 if (m_bypassPermissions) 792 if (m_bypassPermissions)
694 { 793 {
695 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); 794 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); //??
696 returnMask |= EXTRAOWNERMASK; 795 returnMask |= EXTRAOWNERMASK;
697 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 796 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
698 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 797 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
699 return returnMask; 798 return returnMask;
700 } 799 }
701 800
702 bool unlocked = (task.ParentGroup.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
703
704 UUID taskOwnerID = task.OwnerID;
705 UUID spID = sp.UUID;
706
707 // owner 801 // owner
708 if (spID == taskOwnerID) 802 if (spID == taskOwnerID)
709 { 803 {
710 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked); 804 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
711 returnMask |= EXTRAOWNERMASK; 805 returnMask |= EXTRAOWNERMASK;
712 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 806 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
713 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 807 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
@@ -717,19 +811,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
717 // if not god or owner, do attachments as everyone 811 // if not god or owner, do attachments as everyone
718 if(task.ParentGroup.IsAttachment) 812 if(task.ParentGroup.IsAttachment)
719 { 813 {
720 returnMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags, unlocked); 814 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
721 if (taskOwnerID != UUID.Zero) 815 if (taskOwnerID != UUID.Zero)
722 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 816 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
723 return returnMask; 817 return returnMask;
724 } 818 }
725 819
726 UUID taskGroupID = task.GroupID; 820 UUID taskGroupID = task.GroupID;
727 bool groupdOwned = taskOwnerID == taskGroupID; 821 bool notGroupdOwned = taskOwnerID != taskGroupID;
728 822
729 // if friends with rights then owner 823 // if friends with rights then owner
730 if (!groupdOwned && IsFriendWithPerms(spID, taskOwnerID)) 824 if (notGroupdOwned && IsFriendWithPerms(spID, taskOwnerID))
731 { 825 {
732 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked); 826 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
733 returnMask |= EXTRAOWNERMASK; 827 returnMask |= EXTRAOWNERMASK;
734 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 828 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
735 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 829 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
@@ -738,43 +832,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions
738 832
739 // group owned or shared ? 833 // group owned or shared ?
740 IClientAPI client = sp.ControllingClient; 834 IClientAPI client = sp.ControllingClient;
741 if(taskGroupID != UUID.Zero && client != null && client.IsGroupMember(taskGroupID)) 835 ulong powers = 0;
836 if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers))
742 { 837 {
743 if(groupdOwned) 838 if(notGroupdOwned)
744 {
745 // object is owned by group, check role powers
746 if((client.GetGroupPowers(taskGroupID) & (ulong)GroupPowers.ObjectManipulate) != 0)
747 {
748 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked);
749 returnMask |=
750 (uint)PrimFlags.ObjectGroupOwned |
751 (uint)PrimFlags.ObjectAnyOwner;
752 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
753 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
754 return returnMask;
755 }
756 else
757 {
758 // group sharing or everyone
759 returnMask = ApplyObjectModifyMasks(task.GroupMask | task.EveryoneMask, objflags, unlocked);
760 returnMask |=
761 (uint)PrimFlags.ObjectGroupOwned |
762 (uint)PrimFlags.ObjectAnyOwner;
763 return returnMask;
764 }
765 }
766 else
767 { 839 {
768 // group sharing or everyone 840 // group sharing or everyone
769 returnMask = ApplyObjectModifyMasks(task.GroupMask | task.EveryoneMask, objflags, unlocked); 841 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
770 if (taskOwnerID != UUID.Zero) 842 if (taskOwnerID != UUID.Zero)
771 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 843 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
772 return returnMask; 844 return returnMask;
773 } 845 }
846
847 // object is owned by group, check role powers
848 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
849 {
850 // group sharing or everyone
851 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
852 returnMask |=
853 (uint)PrimFlags.ObjectGroupOwned |
854 (uint)PrimFlags.ObjectAnyOwner;
855 return returnMask;
856 }
857
858 // we may have copy without transfer
859 uint grpEffectiveOwnerPerms = grp.EffectiveOwnerPerms;
860 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
861 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
862 returnMask = ApplyObjectModifyMasks(grpEffectiveOwnerPerms, objflags, unlocked);
863 returnMask |=
864 (uint)PrimFlags.ObjectGroupOwned |
865 (uint)PrimFlags.ObjectYouOwner;
866 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
867 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
868 return returnMask;
774 } 869 }
775 870
776 // fallback is everyone rights 871 // fallback is everyone rights
777 returnMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags, unlocked); 872 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
778 if (taskOwnerID != UUID.Zero) 873 if (taskOwnerID != UUID.Zero)
779 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 874 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
780 return returnMask; 875 return returnMask;
@@ -811,7 +906,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
811 return objectFlagsMask; 906 return objectFlagsMask;
812 } 907 }
813 908
814 // OARs need this method that handles offline users 909 // OARs still need this method that handles offline users
815 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj) 910 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj)
816 { 911 {
817 if (obj == null) 912 if (obj == null)
@@ -842,107 +937,182 @@ namespace OpenSim.Region.CoreModules.World.Permissions
842 return PermissionClass.Everyone; 937 return PermissionClass.Everyone;
843 } 938 }
844 939
845 /// <summary> 940 // get effective object permissions using user UUID. User rights will be fixed
846 /// General permissions checks for any operation involving an object. These supplement more specific checks 941 protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked)
847 /// implemented by callers.
848 /// </summary>
849 /// <param name="currentUser"></param>
850 /// <param name="objId">This is a scene object group UUID</param>
851 /// <param name="denyOnLocked"></param>
852 /// <returns></returns>
853 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
854 { 942 {
855 // Default: deny 943 if (group == null)
856 bool permission = false; 944 return 0;
857 bool locked = false;
858
859 SceneObjectPart part = m_scene.GetSceneObjectPart(objId);
860
861 if (part == null)
862 return false;
863 945
864 SceneObjectGroup group = part.ParentGroup; 946 SceneObjectPart root = group.RootPart;
947 if (root == null)
948 return 0;
865 949
866 UUID objectOwner = group.OwnerID; 950 UUID objectOwner = group.OwnerID;
867 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 951 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
868 952
869 // People shouldn't be able to do anything with locked objects, except the Administrator 953 if (IsAdministrator(currentUser))
870 // The 'set permissions' runs through a different permission check, so when an object owner
871 // sets an object locked, the only thing that they can do is unlock it.
872 //
873 // Nobody but the object owner can set permissions on an object
874 //
875 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
876 { 954 {
877 return false; 955 // do lock on admin owned objects
956 if(locked && currentUser == objectOwner)
957 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
958 return (uint)PermissionMask.AllEffective;
878 } 959 }
879 960
880 // Object owners should be able to edit their own content 961 uint lockmask = (uint)PermissionMask.AllEffective;
962 if(locked)
963 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
964
881 if (currentUser == objectOwner) 965 if (currentUser == objectOwner)
882 { 966 return group.EffectiveOwnerPerms & lockmask;
883 // there is no way that later code can change this back to false 967
884 // so just return true immediately and short circuit the more 968 if (group.IsAttachment)
885 // expensive group checks 969 return 0;
886 return true;
887 970
888 //permission = true; 971 UUID sogGroupID = group.GroupID;
889 } 972 bool notgroudOwned = sogGroupID != objectOwner;
890 else if (group.IsAttachment)
891 {
892 permission = false;
893 }
894 973
895// m_log.DebugFormat( 974 if (notgroudOwned && IsFriendWithPerms(currentUser, objectOwner))
896// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", 975 return group.EffectiveOwnerPerms & lockmask;
897// group.GroupID,
898// m_scene.GetSceneObjectPart(objId).GroupMask,
899// IsGroupMember(group.GroupID, currentUser, 0),
900// currentUser);
901
902 // Group members should be able to edit group objects
903 if ((group.GroupID != UUID.Zero)
904 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
905 && IsGroupMember(group.GroupID, currentUser, 0))
906 {
907 // Return immediately, so that the administrator can shares group objects
908 return true;
909 }
910 976
911 // Friends with benefits should be able to edit the objects too 977 ulong powers = 0;
912 if (IsFriendWithPerms(currentUser, objectOwner)) 978 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, currentUser, ref powers))
913 { 979 {
914 // Return immediately, so that the administrator can share objects with friends 980 if(notgroudOwned)
915 return true; 981 return group.EffectiveGroupOrEveryOnePerms & lockmask;
982
983 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
984 return group.EffectiveGroupOrEveryOnePerms & lockmask;
985
986 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
987 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
988 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
989 return grpEffectiveOwnerPerms;
916 } 990 }
917 991
918 // Users should be able to edit what is over their land. 992 return group.EffectiveEveryOnePerms & lockmask;
919 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); 993 }
920 if ((parcel != null) && (parcel.LandData.OwnerID == currentUser)) 994
995 // get effective object permissions using present presence. So some may depend on requested rights (ie God)
996 protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked)
997 {
998 if (sp == null || sp.IsDeleted || group == null || group.IsDeleted)
999 return 0;
1000
1001 SceneObjectPart root = group.RootPart;
1002 if (root == null)
1003 return 0;
1004
1005 UUID spID = sp.UUID;
1006 UUID objectOwner = group.OwnerID;
1007
1008 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
1009
1010 if (sp.IsGod)
921 { 1011 {
922 permission = true; 1012 if(locked && spID == objectOwner)
1013 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
1014 return (uint)PermissionMask.AllEffective;
923 } 1015 }
924 1016
925 // Estate users should be able to edit anything in the sim 1017 uint lockmask = (uint)PermissionMask.AllEffective;
926 if (IsEstateManager(currentUser)) 1018 if(locked)
1019 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
1020
1021 if (spID == objectOwner)
1022 return group.EffectiveOwnerPerms & lockmask;
1023
1024 if (group.IsAttachment)
1025 return 0;
1026
1027 UUID sogGroupID = group.GroupID;
1028 bool notgroudOwned = sogGroupID != objectOwner;
1029
1030 if (notgroudOwned && IsFriendWithPerms(spID, objectOwner))
1031 return group.EffectiveOwnerPerms & lockmask;
1032
1033 ulong powers = 0;
1034 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, sp, ref powers))
927 { 1035 {
928 permission = true; 1036 if(notgroudOwned)
1037 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1038
1039 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
1040 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1041
1042 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
1043 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1044 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
1045 return grpEffectiveOwnerPerms;
929 } 1046 }
930 1047
931 // Admin objects should not be editable by the above 1048 return group.EffectiveEveryOnePerms & lockmask;
932 if (IsAdministrator(objectOwner)) 1049 }
1050
1051 private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti)
1052 {
1053 UUID tiOwnerID = ti.OwnerID;
1054 if(tiOwnerID == userID)
1055 return ti.CurrentPermissions;
1056
1057 if(IsAdministrator(userID))
1058 return (uint)PermissionMask.AllEffective;
1059 // ??
1060 if (IsFriendWithPerms(userID, tiOwnerID))
1061 return ti.CurrentPermissions;
1062
1063 UUID tiGroupID = ti.GroupID;
1064 if(tiGroupID != UUID.Zero)
933 { 1065 {
934 permission = false; 1066 ulong powers = 0;
1067 if(GroupMemberPowers(tiGroupID, userID, ref powers))
1068 {
1069 if(tiGroupID == ti.OwnerID)
1070 {
1071 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1072 return ti.CurrentPermissions;
1073 }
1074 return ti.GroupPermissions;
1075 }
935 } 1076 }
936 1077
937 // Admin should be able to edit anything in the sim (including admin objects) 1078 return 0;
938 if (IsAdministrator(currentUser)) 1079 }
1080
1081 private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone)
1082 {
1083 UUID tiOwnerID = ti.OwnerID;
1084 UUID spID = sp.UUID;
1085
1086 if(tiOwnerID == spID)
1087 return ti.CurrentPermissions;
1088
1089 // ??
1090 if (IsFriendWithPerms(spID, tiOwnerID))
1091 return ti.CurrentPermissions;
1092
1093 UUID tiGroupID = ti.GroupID;
1094 if(tiGroupID != UUID.Zero)
939 { 1095 {
940 permission = true; 1096 ulong powers = 0;
1097 if(GroupMemberPowers(tiGroupID, spID, ref powers))
1098 {
1099 if(tiGroupID == ti.OwnerID)
1100 {
1101 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1102 return ti.CurrentPermissions;
1103 }
1104 uint p = ti.GroupPermissions;
1105 if(!notEveryone)
1106 p |= ti.EveryonePermissions;
1107 return p;
1108 }
941 } 1109 }
942 1110
943 return permission; 1111 if(notEveryone)
944 } 1112 return 0;
945 1113
1114 return ti.EveryonePermissions;
1115 }
946 #endregion 1116 #endregion
947 1117
948 #region Generic Permissions 1118 #region Generic Permissions
@@ -967,89 +1137,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
967 1137
968 public bool GenericEstatePermission(UUID user) 1138 public bool GenericEstatePermission(UUID user)
969 { 1139 {
970 // Default: deny
971 bool permission = false;
972
973 // Estate admins should be able to use estate tools 1140 // Estate admins should be able to use estate tools
974 if (IsEstateManager(user)) 1141 if (IsEstateManager(user))
975 permission = true; 1142 return true;
976 1143
977 // Administrators always have permission 1144 // Administrators always have permission
978 if (IsAdministrator(user)) 1145 if (IsAdministrator(user))
979 permission = true; 1146 return true;
980
981 return permission;
982 }
983
984 protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
985 {
986 bool permission = false;
987
988 if (parcel.LandData.OwnerID == user)
989 {
990 permission = true;
991 }
992
993 if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
994 {
995 permission = true;
996 }
997
998 if (IsEstateManager(user))
999 {
1000 permission = true;
1001 }
1002
1003 if (IsAdministrator(user))
1004 {
1005 permission = true;
1006 }
1007
1008 if (m_SimpleBuildPermissions &&
1009 (parcel.LandData.Flags & (uint)ParcelFlags.UseAccessList) == 0 && parcel.IsInLandAccessList(user))
1010 permission = true;
1011 1147
1012 return permission; 1148 return false;
1013 } 1149 }
1014 1150
1015 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager) 1151 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager)
1016 { 1152 {
1017 if (parcel.LandData.OwnerID == user) 1153 if (parcel.LandData.OwnerID == user)
1018 {
1019 // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
1020 // the subsequent redundant checks when using lParcelMediaCommandList()
1021 // See http://opensimulator.org/mantis/view.php?id=3999 for more details
1022 return true; 1154 return true;
1023 }
1024 1155
1025 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers)) 1156 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
1026 {
1027 return true; 1157 return true;
1028 }
1029 1158
1030 if (allowEstateManager && IsEstateManager(user)) 1159 if (allowEstateManager && IsEstateManager(user))
1031 {
1032 return true; 1160 return true;
1033 }
1034 1161
1035 if (IsAdministrator(user)) 1162 if (IsAdministrator(user))
1036 {
1037 return true; 1163 return true;
1038 }
1039 1164
1040 return false; 1165 return false;
1041 } 1166 }
1042
1043 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
1044 {
1045 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1046 if (parcel == null) return false;
1047 return GenericParcelPermission(user, parcel, groupPowers);
1048 }
1049#endregion 1167#endregion
1050 1168
1051 #region Permission Checks 1169 #region Permission Checks
1052 private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) 1170 private bool CanAbandonParcel(UUID user, ILandObject parcel)
1053 { 1171 {
1054 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1172 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1055 if (m_bypassPermissions) return m_bypassPermissionsValue; 1173 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1057,7 +1175,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1057 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false); 1175 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false);
1058 } 1176 }
1059 1177
1060 private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) 1178 private bool CanReclaimParcel(UUID user, ILandObject parcel)
1061 { 1179 {
1062 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1180 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1063 if (m_bypassPermissions) return m_bypassPermissionsValue; 1181 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1065,108 +1183,223 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1065 return GenericParcelOwnerPermission(user, parcel, 0,true); 1183 return GenericParcelOwnerPermission(user, parcel, 0,true);
1066 } 1184 }
1067 1185
1068 private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) 1186 private bool CanDeedParcel(UUID user, ILandObject parcel)
1069 { 1187 {
1070 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1188 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1071 if (m_bypassPermissions) return m_bypassPermissionsValue; 1189 if (m_bypassPermissions) return m_bypassPermissionsValue;
1072 1190
1191 if(parcel.LandData.GroupID == UUID.Zero)
1192 return false;
1193
1194 if (IsAdministrator(user))
1195 return true;
1196
1073 if (parcel.LandData.OwnerID != user) // Only the owner can deed! 1197 if (parcel.LandData.OwnerID != user) // Only the owner can deed!
1074 return false; 1198 return false;
1075 1199
1076 ScenePresence sp = scene.GetScenePresence(user); 1200 ScenePresence sp = m_scene.GetScenePresence(user);
1077 IClientAPI client = sp.ControllingClient; 1201 if(sp == null)
1202 return false;
1078 1203
1204 IClientAPI client = sp.ControllingClient;
1079 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) 1205 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
1080 return false; 1206 return false;
1081 1207
1082 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); 1208 return true;
1083 } 1209 }
1084 1210
1085 private bool CanDeedObject(UUID user, UUID group, Scene scene) 1211 private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
1086 { 1212 {
1087 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1213 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1088 if (m_bypassPermissions) return m_bypassPermissionsValue; 1214 if (m_bypassPermissions) return m_bypassPermissionsValue;
1089 1215
1090 ScenePresence sp = scene.GetScenePresence(user); 1216 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted || targetGroupID == UUID.Zero)
1091 IClientAPI client = sp.ControllingClient; 1217 return false;
1092 1218
1093 if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) 1219 // object has group already?
1220 if(sog.GroupID != targetGroupID)
1221 return false;
1222
1223 // is effectivelly shared?
1224 if(sog.EffectiveGroupPerms == 0)
1225 return false;
1226
1227 if(sp.IsGod)
1228 return true;
1229
1230 // owned by requester?
1231 if(sog.OwnerID != sp.UUID)
1232 return false;
1233
1234 // owner can transfer?
1235 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1236 return false;
1237
1238 // group member ?
1239 ulong powers = 0;
1240 if(!GroupMemberPowers(targetGroupID, sp, ref powers))
1241 return false;
1242
1243 // has group rights?
1244 if ((powers & (ulong)GroupPowers.DeedObject) == 0)
1094 return false; 1245 return false;
1095 1246
1096 return true; 1247 return true;
1097 } 1248 }
1098 1249
1099 private bool IsGod(UUID user, Scene scene) 1250 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
1100 { 1251 {
1101 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1252 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1102 if (m_bypassPermissions) return m_bypassPermissionsValue; 1253 if (m_bypassPermissions) return m_bypassPermissionsValue;
1103 1254
1104 return IsAdministrator(user); 1255 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1256 return false;
1257
1258 uint perms = GetObjectPermissions(sp, sog, false);
1259 if((perms & (uint)PermissionMask.Copy) == 0)
1260 return false;
1261
1262 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1263 return false;
1264
1265 //If they can rez, they can duplicate
1266 return CanRezObject(0, sp.UUID, sog.AbsolutePosition);
1105 } 1267 }
1106 1268
1107 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition) 1269 private bool CanDeleteObject(SceneObjectGroup sog, ScenePresence sp)
1108 { 1270 {
1271 // ignoring locked. viewers should warn and ask for confirmation
1272
1109 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1273 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1110 if (m_bypassPermissions) return m_bypassPermissionsValue; 1274 if (m_bypassPermissions) return m_bypassPermissionsValue;
1111 1275
1112 if (!GenericObjectPermission(owner, objectID, true)) 1276 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1113 {
1114 //They can't even edit the object
1115 return false; 1277 return false;
1116 }
1117 1278
1118 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1279 if(sog.IsAttachment)
1119 if (part == null)
1120 return false; 1280 return false;
1121 1281
1122 if (part.OwnerID == owner) 1282 UUID sogOwnerID = sog.OwnerID;
1283 UUID spID = sp.UUID;
1284
1285 if(sogOwnerID == spID)
1286 return true;
1287
1288 if (sp.IsGod)
1289 return true;
1290
1291 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1292 return true;
1293
1294 UUID sogGroupID = sog.GroupID;
1295 if (sogGroupID != UUID.Zero)
1123 { 1296 {
1124 if ((part.OwnerMask & PERM_COPY) == 0) 1297 ulong powers = 0;
1125 return false; 1298 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1299 {
1300 if(sogGroupID == sogOwnerID)
1301 {
1302 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1303 return true;
1304 }
1305 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1306 }
1126 } 1307 }
1127 else if (part.GroupID != UUID.Zero) 1308 return false;
1128 { 1309 }
1129 if ((part.OwnerID == part.GroupID) && ((owner != part.LastOwnerID) || ((part.GroupMask & PERM_TRANS) == 0)))
1130 return false;
1131 1310
1132 if ((part.GroupMask & PERM_COPY) == 0) 1311 private bool CanDeleteObjectByIDs(UUID objectID, UUID userID)
1133 return false; 1312 {
1134 } 1313 // ignoring locked. viewers should warn and ask for confirmation
1135 1314
1136 //If they can rez, they can duplicate 1315 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1137 return CanRezObject(objectCount, owner, objectPosition, scene); 1316 if (m_bypassPermissions) return m_bypassPermissionsValue;
1317
1318 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1319 if (sog == null)
1320 return false;
1321
1322 if(sog.IsAttachment)
1323 return false;
1324
1325 UUID sogOwnerID = sog.OwnerID;
1326
1327 if(sogOwnerID == userID)
1328 return true;
1329
1330 if (IsAdministrator(userID))
1331 return true;
1332
1333 if (IsFriendWithPerms(objectID, sogOwnerID))
1334 return true;
1335
1336 UUID sogGroupID = sog.GroupID;
1337 if (sogGroupID != UUID.Zero)
1338 {
1339 ulong powers = 0;
1340 if(GroupMemberPowers(sogGroupID, userID, ref powers))
1341 {
1342 if(sogGroupID == sogOwnerID)
1343 {
1344 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1345 return true;
1346 }
1347 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1348 }
1349 }
1350 return false;
1138 } 1351 }
1139 1352
1140 private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene) 1353 private bool CanEditObjectByIDs(UUID objectID, UUID userID)
1141 { 1354 {
1142 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1355 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1143 if (m_bypassPermissions) return m_bypassPermissionsValue; 1356 if (m_bypassPermissions) return m_bypassPermissionsValue;
1144 1357
1145 return GenericObjectPermission(deleter, objectID, false); 1358 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1359 if (sog == null)
1360 return false;
1361
1362 uint perms = GetObjectPermissions(userID, sog, true);
1363 if((perms & (uint)PermissionMask.Modify) == 0)
1364 return false;
1365 return true;
1146 } 1366 }
1147 1367
1148 private bool CanEditObject(UUID objectID, UUID editorID, Scene scene) 1368 private bool CanEditObject(SceneObjectGroup sog, ScenePresence sp)
1149 { 1369 {
1150 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1370 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1151 if (m_bypassPermissions) return m_bypassPermissionsValue; 1371 if (m_bypassPermissions) return m_bypassPermissionsValue;
1152 1372
1153 return GenericObjectPermission(editorID, objectID, false); 1373 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1374 return false;
1375
1376 uint perms = GetObjectPermissions(sp, sog, true);
1377 if((perms & (uint)PermissionMask.Modify) == 0)
1378 return false;
1379 return true;
1154 } 1380 }
1155 1381
1156 private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene) 1382 private bool CanEditObjectInventory(UUID objectID, UUID userID)
1157 { 1383 {
1158 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1384 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1159 if (m_bypassPermissions) return m_bypassPermissionsValue; 1385 if (m_bypassPermissions) return m_bypassPermissionsValue;
1160 1386
1161 return GenericObjectPermission(editorID, objectID, false); 1387 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1388 if (sog == null)
1389 return false;
1390
1391 uint perms = GetObjectPermissions(userID, sog, true);
1392 if((perms & (uint)PermissionMask.Modify) == 0)
1393 return false;
1394 return true;
1162 } 1395 }
1163 1396
1164 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager) 1397 private bool CanEditParcelProperties(UUID userID, ILandObject parcel, GroupPowers p, bool allowManager)
1165 { 1398 {
1166 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1399 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1167 if (m_bypassPermissions) return m_bypassPermissionsValue; 1400 if (m_bypassPermissions) return m_bypassPermissionsValue;
1168 1401
1169 return GenericParcelOwnerPermission(user, parcel, (ulong)p, false); 1402 return GenericParcelOwnerPermission(userID, parcel, (ulong)p, false);
1170 } 1403 }
1171 1404
1172 /// <summary> 1405 /// <summary>
@@ -1177,18 +1410,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1177 /// <param name="user"></param> 1410 /// <param name="user"></param>
1178 /// <param name="scene"></param> 1411 /// <param name="scene"></param>
1179 /// <returns></returns> 1412 /// <returns></returns>
1180 private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene) 1413 private bool CanEditScript(UUID script, UUID objectID, UUID userID)
1181 { 1414 {
1182 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1415 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1183 if (m_bypassPermissions) return m_bypassPermissionsValue; 1416 if (m_bypassPermissions) return m_bypassPermissionsValue;
1184 1417
1185 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user)) 1418 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(userID))
1186 return false; 1419 return false;
1187 1420
1188 // Ordinarily, if you can view it, you can edit it 1421 // Ordinarily, if you can view it, you can edit it
1189 // There is no viewing a no mod script 1422 // There is no viewing a no mod script
1190 // 1423 //
1191 return CanViewScript(script, objectID, user, scene); 1424 return CanViewScript(script, objectID, userID);
1192 } 1425 }
1193 1426
1194 /// <summary> 1427 /// <summary>
@@ -1199,7 +1432,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1199 /// <param name="user"></param> 1432 /// <param name="user"></param>
1200 /// <param name="scene"></param> 1433 /// <param name="scene"></param>
1201 /// <returns></returns> 1434 /// <returns></returns>
1202 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 1435 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user)
1203 { 1436 {
1204 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1437 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1205 if (m_bypassPermissions) return m_bypassPermissionsValue; 1438 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1230,69 +1463,68 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1230 } 1463 }
1231 else // Prim inventory 1464 else // Prim inventory
1232 { 1465 {
1233 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1466 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1234
1235 if (part == null) 1467 if (part == null)
1236 return false; 1468 return false;
1237 1469
1238 if (part.OwnerID != user) 1470 SceneObjectGroup sog = part.ParentGroup;
1239 { 1471 if (sog == null)
1240 if (part.GroupID == UUID.Zero) 1472 return false;
1241 return false;
1242
1243 if (!IsGroupMember(part.GroupID, user, 0))
1244 return false;
1245 1473
1246 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1474 // check object mod right
1247 return false; 1475 uint perms = GetObjectPermissions(user, sog, true);
1248 } 1476 if((perms & (uint)PermissionMask.Modify) == 0)
1249 else
1250 {
1251 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1252 return false; 1477 return false;
1253 }
1254 1478
1255 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 1479 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1256
1257 if (ti == null) 1480 if (ti == null)
1258 return false; 1481 return false;
1259 1482
1260 if (ti.OwnerID != user) 1483 if (ti.OwnerID != user)
1261 { 1484 {
1262 if (ti.GroupID == UUID.Zero) 1485 UUID tiGroupID = ti.GroupID;
1486 if (tiGroupID == UUID.Zero)
1263 return false; 1487 return false;
1264 1488
1265 if (!IsGroupMember(ti.GroupID, user, 0)) 1489 ulong powers = 0;
1490 if(!GroupMemberPowers(tiGroupID, user, ref powers))
1266 return false; 1491 return false;
1492
1493 if(tiGroupID == ti.OwnerID && (powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1494 {
1495 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1496 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1497 return true;
1498 }
1499 if ((ti.GroupPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1500 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1501 return true;
1502 return false;
1267 } 1503 }
1268 1504
1269 // Require full perms 1505 // Require full perms
1270 if ((ti.CurrentPermissions & 1506 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) !=
1271 ((uint)PermissionMask.Modify | 1507 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1272 (uint)PermissionMask.Copy)) !=
1273 ((uint)PermissionMask.Modify |
1274 (uint)PermissionMask.Copy))
1275 return false; 1508 return false;
1276 } 1509 }
1277
1278 return true; 1510 return true;
1279 } 1511 }
1280 1512
1281 private bool CanInstantMessage(UUID user, UUID target, Scene startScene) 1513 private bool CanInstantMessage(UUID user, UUID target)
1282 { 1514 {
1283 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1515 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1284 if (m_bypassPermissions) return m_bypassPermissionsValue; 1516 if (m_bypassPermissions) return m_bypassPermissionsValue;
1285 1517
1286 // If the sender is an object, check owner instead 1518 // If the sender is an object, check owner instead
1287 // 1519 //
1288 SceneObjectPart part = startScene.GetSceneObjectPart(user); 1520 SceneObjectPart part = m_scene.GetSceneObjectPart(user);
1289 if (part != null) 1521 if (part != null)
1290 user = part.OwnerID; 1522 user = part.OwnerID;
1291 1523
1292 return GenericCommunicationPermission(user, target); 1524 return GenericCommunicationPermission(user, target);
1293 } 1525 }
1294 1526
1295 private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene) 1527 private bool CanInventoryTransfer(UUID user, UUID target)
1296 { 1528 {
1297 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1529 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1298 if (m_bypassPermissions) return m_bypassPermissionsValue; 1530 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1300,7 +1532,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1300 return GenericCommunicationPermission(user, target); 1532 return GenericCommunicationPermission(user, target);
1301 } 1533 }
1302 1534
1303 private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand) 1535 private bool CanIssueEstateCommand(UUID user, bool ownerCommand)
1304 { 1536 {
1305 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1537 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1306 if (m_bypassPermissions) return m_bypassPermissionsValue; 1538 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1308,178 +1540,113 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1308 if (IsAdministrator(user)) 1540 if (IsAdministrator(user))
1309 return true; 1541 return true;
1310 1542
1311 if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
1312 return true;
1313
1314 if (ownerCommand) 1543 if (ownerCommand)
1315 return false; 1544 return m_scene.RegionInfo.EstateSettings.IsEstateOwner(user);
1316 1545
1317 return GenericEstatePermission(user); 1546 return IsEstateManager(user);
1318 } 1547 }
1319 1548
1320 private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene) 1549 private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
1321 { 1550 {
1322 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1551 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1323 if (m_bypassPermissions)
1324 {
1325 SceneObjectPart part = scene.GetSceneObjectPart(objectID);
1326 if (part.OwnerID != moverID)
1327 {
1328 if (!part.ParentGroup.IsDeleted)
1329 {
1330 if (part.ParentGroup.IsAttachment)
1331 return false;
1332 }
1333 }
1334 return m_bypassPermissionsValue;
1335 }
1336
1337 bool permission = GenericObjectPermission(moverID, objectID, true);
1338 if (!permission)
1339 {
1340 if (!m_scene.Entities.ContainsKey(objectID))
1341 {
1342 return false;
1343 }
1344
1345 // The client
1346 // may request to edit linked parts, and therefore, it needs
1347 // to also check for SceneObjectPart
1348
1349 // If it's not an object, we cant edit it.
1350 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1351 {
1352 return false;
1353 }
1354
1355
1356 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
1357
1358 1552
1359 // UUID taskOwner = null; 1553 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1360 // Added this because at this point in time it wouldn't be wise for 1554 return false;
1361 // the administrator object permissions to take effect.
1362 // UUID objectOwner = task.OwnerID;
1363
1364 // Anyone can move
1365 if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0)
1366 permission = true;
1367 1555
1368 // Locked 1556 if (m_bypassPermissions)
1369 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
1370 permission = false;
1371 }
1372 else
1373 { 1557 {
1374 bool locked = false; 1558 if (sog.OwnerID != sp.UUID && sog.IsAttachment)
1375 if (!m_scene.Entities.ContainsKey(objectID))
1376 {
1377 return false;
1378 }
1379
1380 // If it's not an object, we cant edit it.
1381 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1382 {
1383 return false;
1384 }
1385
1386 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID];
1387
1388 UUID objectOwner = group.OwnerID;
1389 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
1390
1391 // This is an exception to the generic object permission.
1392 // Administrators who lock their objects should not be able to move them,
1393 // however generic object permission should return true.
1394 // This keeps locked objects from being affected by random click + drag actions by accident
1395 // and allows the administrator to grab or delete a locked object.
1396
1397 // Administrators and estate managers are still able to click+grab locked objects not
1398 // owned by them in the scene
1399 // This is by design.
1400
1401 if (locked && (moverID == objectOwner))
1402 return false; 1559 return false;
1560 return m_bypassPermissionsValue;
1403 } 1561 }
1404 return permission; 1562
1563 uint perms = GetObjectPermissions(sp, sog, true);
1564 if((perms & (uint)PermissionMask.Move) == 0)
1565 return false;
1566 return true;
1405 } 1567 }
1406 1568
1407 private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 1569 private bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
1408 { 1570 {
1409 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1571 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1410 if (m_bypassPermissions) return m_bypassPermissionsValue;
1411 1572
1573 float newX = newPoint.X;
1574 float newY = newPoint.Y;
1412 1575
1413 // allow outide region?? 1576 // allow outside region this is needed for crossings
1414 if (newPoint.X < -1f || newPoint.Y < -1f) 1577 if (newX < -1f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
1578 newY < -1f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
1415 return true; 1579 return true;
1416 if (newPoint.X > scene.RegionInfo.RegionSizeX + 1.0f || newPoint.Y > scene.RegionInfo.RegionSizeY + 1.0f)
1417 {
1418 return true;
1419 }
1420 1580
1421 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1581 if(sog == null || sog.IsDeleted)
1582 return false;
1422 1583
1423 ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 1584 if (m_bypassPermissions)
1585 return m_bypassPermissionsValue;
1586
1587 ILandObject parcel = m_scene.LandChannel.GetLandObject(newX, newY);
1588 if (parcel == null)
1589 return false;
1590
1591 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0)
1592 return true;
1424 1593
1425 if (!enteringRegion) 1594 if (!enteringRegion)
1426 { 1595 {
1427 ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); 1596 Vector3 oldPoint = sog.AbsolutePosition;
1428 1597 ILandObject fromparcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
1429 if (fromland == land) // Not entering 1598 if (fromparcel != null && fromparcel.Equals(parcel)) // it already entered parcel ????
1430 return true; 1599 return true;
1431 } 1600 }
1432 1601
1433 if (land == null) 1602 UUID userID = sog.OwnerID;
1434 { 1603 LandData landdata = parcel.LandData;
1435 return false;
1436 }
1437 1604
1438 if ((land.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0) 1605 if (landdata.OwnerID == userID)
1439 {
1440 return true; 1606 return true;
1441 }
1442 1607
1443 if (!m_scene.Entities.ContainsKey(objectID)) 1608 if (IsAdministrator(userID))
1444 { 1609 return true;
1445 return false;
1446 }
1447 1610
1448 // If it's not an object, we cant edit it. 1611 UUID landGroupID = landdata.GroupID;
1449 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1612 if (landGroupID != UUID.Zero)
1450 { 1613 {
1451 return false; 1614 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowGroupObjectEntry)) != 0)
1452 } 1615 return IsGroupMember(landGroupID, userID, 0);
1453
1454 1616
1455 if (GenericParcelPermission(task.OwnerID, newPoint, 0)) 1617 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1456 { 1618 return true;
1457 return true;
1458 } 1619 }
1459 1620
1460 //Otherwise, false! 1621 //Otherwise, false!
1461 return false; 1622 return false;
1462 } 1623 }
1463 1624
1464 private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) 1625 private bool CanReturnObjects(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects)
1465 { 1626 {
1466 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1627 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1467 if (m_bypassPermissions) return m_bypassPermissionsValue; 1628 if (m_bypassPermissions) return m_bypassPermissionsValue;
1468 1629
1469 GroupPowers powers; 1630 if(sp == null)
1470 ILandObject l; 1631 return true; // assuming that in this case rights are as owner
1471 1632
1472 ScenePresence sp = scene.GetScenePresence(user); 1633 UUID userID = sp.UUID;
1473 if (sp == null) 1634 bool isPrivUser = sp.IsGod || IsEstateManager(userID);
1474 return false;
1475 1635
1476 IClientAPI client = sp.ControllingClient; 1636 IClientAPI client = sp.ControllingClient;
1477 1637
1638 ulong powers = 0;
1639 ILandObject l;
1640
1478 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects)) 1641 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
1479 { 1642 {
1480 // Any user can return their own objects at any time 1643 if(g.IsAttachment)
1481 // 1644 {
1482 if (GenericObjectPermission(user, g.UUID, false)) 1645 objects.Remove(g);
1646 continue;
1647 }
1648
1649 if (isPrivUser || g.OwnerID == userID)
1483 continue; 1650 continue;
1484 1651
1485 // This is a short cut for efficiency. If land is non-null, 1652 // This is a short cut for efficiency. If land is non-null,
@@ -1493,39 +1660,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1493 else 1660 else
1494 { 1661 {
1495 Vector3 pos = g.AbsolutePosition; 1662 Vector3 pos = g.AbsolutePosition;
1496 1663 l = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1497 l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
1498 } 1664 }
1499 1665
1500 // If it's not over any land, then we can't do a thing 1666 // If it's not over any land, then we can't do a thing
1501 if (l == null) 1667 if (l == null || l.LandData == null)
1502 { 1668 {
1503 objects.Remove(g); 1669 objects.Remove(g);
1504 continue; 1670 continue;
1505 } 1671 }
1506 1672
1673 LandData ldata = l.LandData;
1507 // If we own the land outright, then allow 1674 // If we own the land outright, then allow
1508 // 1675 //
1509 if (l.LandData.OwnerID == user) 1676 if (ldata.OwnerID == userID)
1510 continue; 1677 continue;
1511 1678
1512 // Group voodoo 1679 // Group voodoo
1513 // 1680 //
1514 if (l.LandData.IsGroupOwned) 1681 if (ldata.IsGroupOwned)
1515 { 1682 {
1516 powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); 1683 UUID lGroupID = ldata.GroupID;
1517 // Not a group member, or no rights at all 1684 // Not a group member, or no rights at all
1518 // 1685 //
1519 if (powers == (GroupPowers)0) 1686 powers = client.GetGroupPowers(lGroupID);
1687 if(powers == 0)
1520 { 1688 {
1521 objects.Remove(g); 1689 objects.Remove(g);
1522 continue; 1690 continue;
1523 } 1691 }
1524 1692
1525 // Group deeded object? 1693 // Group deeded object?
1526 // 1694 //
1527 if (g.OwnerID == l.LandData.GroupID && 1695 if (g.OwnerID == lGroupID &&
1528 (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) 1696 (powers & (ulong)GroupPowers.ReturnGroupOwned) == 0)
1529 { 1697 {
1530 objects.Remove(g); 1698 objects.Remove(g);
1531 continue; 1699 continue;
@@ -1533,14 +1701,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1533 1701
1534 // Group set object? 1702 // Group set object?
1535 // 1703 //
1536 if (g.GroupID == l.LandData.GroupID && 1704 if (g.GroupID == lGroupID &&
1537 (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) 1705 (powers & (ulong)GroupPowers.ReturnGroupSet) == 0)
1538 { 1706 {
1539 objects.Remove(g); 1707 objects.Remove(g);
1540 continue; 1708 continue;
1541 } 1709 }
1542 1710
1543 if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) 1711 if ((powers & (ulong)GroupPowers.ReturnNonGroup) == 0)
1544 { 1712 {
1545 objects.Remove(g); 1713 objects.Remove(g);
1546 continue; 1714 continue;
@@ -1563,7 +1731,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1563 return true; 1731 return true;
1564 } 1732 }
1565 1733
1566 private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) 1734 private bool CanRezObject(int objectCount, UUID userID, Vector3 objectPosition)
1567 { 1735 {
1568 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1736 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1569 if (m_bypassPermissions) 1737 if (m_bypassPermissions)
@@ -1576,28 +1744,28 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1576 return false; 1744 return false;
1577 1745
1578 LandData landdata = parcel.LandData; 1746 LandData landdata = parcel.LandData;
1579 if ((owner == landdata.OwnerID)) 1747 if ((userID == landdata.OwnerID))
1580 return true; 1748 return true;
1581 1749
1582 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0) 1750 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0)
1583 return true; 1751 return true;
1584 1752
1585 if(IsAdministrator(owner)) 1753 if(IsAdministrator(userID))
1586 return true; 1754 return true;
1587 1755
1588 if(landdata.GroupID != UUID.Zero) 1756 if(landdata.GroupID != UUID.Zero)
1589 { 1757 {
1590 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0) 1758 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1591 return IsGroupMember(landdata.GroupID, owner, 0); 1759 return IsGroupMember(landdata.GroupID, userID, 0);
1592 1760
1593 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, owner, (ulong)GroupPowers.AllowRez)) 1761 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowRez))
1594 return true; 1762 return true;
1595 } 1763 }
1596 1764
1597 return false; 1765 return false;
1598 } 1766 }
1599 1767
1600 private bool CanRunConsoleCommand(UUID user, Scene requestFromScene) 1768 private bool CanRunConsoleCommand(UUID user)
1601 { 1769 {
1602 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1770 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1603 if (m_bypassPermissions) return m_bypassPermissionsValue; 1771 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1606,15 +1774,43 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1606 return IsAdministrator(user); 1774 return IsAdministrator(user);
1607 } 1775 }
1608 1776
1609 private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene) 1777 private bool CanRunScript(TaskInventoryItem scriptitem, SceneObjectPart part)
1610 { 1778 {
1611 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1779 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1612 if (m_bypassPermissions) return m_bypassPermissionsValue; 1780 if (m_bypassPermissions) return m_bypassPermissionsValue;
1613 1781
1614 return true; 1782 if(scriptitem == null || part == null)
1783 return false;
1784
1785 SceneObjectGroup sog = part.ParentGroup;
1786 if(sog == null)
1787 return false;
1788
1789 Vector3 pos = sog.AbsolutePosition;
1790 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1791 if (parcel == null)
1792 return false;
1793
1794 LandData ldata = parcel.LandData;
1795 if(ldata == null)
1796 return false;
1797
1798 uint lflags = ldata.Flags;
1799
1800 if ((lflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
1801 return true;
1802
1803 if ((part.OwnerID == ldata.OwnerID))
1804 return true;
1805
1806 if (((lflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
1807 && (ldata.GroupID != UUID.Zero) && (ldata.GroupID == part.GroupID))
1808 return true;
1809
1810 return GenericEstatePermission(part.OwnerID);
1615 } 1811 }
1616 1812
1617 private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) 1813 private bool CanSellParcel(UUID user, ILandObject parcel)
1618 { 1814 {
1619 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1815 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1620 if (m_bypassPermissions) return m_bypassPermissionsValue; 1816 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1622,7 +1818,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1622 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true); 1818 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true);
1623 } 1819 }
1624 1820
1625 private bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 1821 private bool CanSellGroupObject(UUID userID, UUID groupID)
1626 { 1822 {
1627 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1823 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1628 if (m_bypassPermissions) return m_bypassPermissionsValue; 1824 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1630,66 +1826,79 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1630 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale); 1826 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1631 } 1827 }
1632 1828
1633 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 1829 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
1634 { 1830 {
1831 // ignore locked, viewers shell ask for confirmation
1635 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1832 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1636 if (m_bypassPermissions) return m_bypassPermissionsValue; 1833 if (m_bypassPermissions) return m_bypassPermissionsValue;
1637 1834
1638 return GenericObjectPermission(stealer,objectID, false); 1835 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1639 } 1836 return false;
1640 1837
1641 private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene) 1838 // take is not a attachment op
1642 { 1839 if(sog.IsAttachment)
1643 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1840 return false;
1644 if (m_bypassPermissions) return m_bypassPermissionsValue;
1645 1841
1646 bool permission = GenericObjectPermission(userID, objectID, false); 1842 UUID sogOwnerID = sog.OwnerID;
1843 UUID spID = sp.UUID;
1647 1844
1648 SceneObjectGroup so = (SceneObjectGroup)m_scene.Entities[objectID]; 1845 if(sogOwnerID == spID)
1846 return true;
1649 1847
1650 if (!permission) 1848 if (sp.IsGod)
1849 return true;
1850
1851 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1852 return false;
1853
1854 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1855 return true;
1856
1857 UUID sogGroupID = sog.GroupID;
1858 if (sogGroupID != UUID.Zero)
1651 { 1859 {
1652 if (!m_scene.Entities.ContainsKey(objectID)) 1860 ulong powers = 0;
1861 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1653 { 1862 {
1654 return false; 1863 if(sogGroupID == sogOwnerID)
1655 } 1864 {
1865 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1866 return true;
1867 }
1868 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1869 }
1870 }
1871 return false;
1872 }
1656 1873
1657 // If it's not an object, we cant edit it. 1874 private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
1658 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1875 {
1659 { 1876 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1660 return false; 1877 if (m_bypassPermissions) return m_bypassPermissionsValue;
1661 }
1662 1878
1663 // UUID taskOwner = null; 1879 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1664 // Added this because at this point in time it wouldn't be wise for 1880 return false;
1665 // the administrator object permissions to take effect.
1666 // UUID objectOwner = task.OwnerID;
1667 1881
1668 if ((so.RootPart.EveryoneMask & PERM_COPY) != 0) 1882 // refuse on attachments
1669 permission = true; 1883 if(sog.IsAttachment && !sp.IsGod)
1670 } 1884 return false;
1671 1885
1672 if (so.OwnerID != userID) 1886 uint perms = GetObjectPermissions(sp, sog, true);
1673 { 1887 if((perms & (uint)PermissionMask.Copy) == 0)
1674 if ((so.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) 1888 return false;
1675 permission = false;
1676 }
1677 else
1678 {
1679 if ((so.GetEffectivePermissions() & PERM_COPY) != PERM_COPY)
1680 permission = false;
1681 }
1682 1889
1683 return permission; 1890 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1891 return false;
1892 return true;
1684 } 1893 }
1685 1894
1686 private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene) 1895 private bool CanTerraformLand(UUID userID, Vector3 position)
1687 { 1896 {
1688 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1897 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1689 if (m_bypassPermissions) return m_bypassPermissionsValue; 1898 if (m_bypassPermissions) return m_bypassPermissionsValue;
1690 1899
1691 // Estate override 1900 // Estate override
1692 if (GenericEstatePermission(user)) 1901 if (GenericEstatePermission(userID))
1693 return true; 1902 return true;
1694 1903
1695 float X = position.X; 1904 float X = position.X;
@@ -1707,13 +1916,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1707 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); 1916 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
1708 if (parcel == null) 1917 if (parcel == null)
1709 return false; 1918 return false;
1710 1919
1711 // Others allowed to terraform? 1920 LandData landdata = parcel.LandData;
1712 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowTerraform)) != 0) 1921 if (landdata == null)
1922 return false;
1923
1924 if ((landdata.Flags & ((int)ParcelFlags.AllowTerraform)) != 0)
1713 return true; 1925 return true;
1714 1926
1715 // Land owner can terraform too 1927 if(landdata.OwnerID == userID)
1716 if (parcel != null && GenericParcelPermission(user, parcel, (ulong)GroupPowers.AllowEditLand)) 1928 return true;
1929
1930 if (landdata.IsGroupOwned && parcel.LandData.GroupID != UUID.Zero &&
1931 IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowEditLand))
1717 return true; 1932 return true;
1718 1933
1719 return false; 1934 return false;
@@ -1727,7 +1942,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1727 /// <param name="user"></param> 1942 /// <param name="user"></param>
1728 /// <param name="scene"></param> 1943 /// <param name="scene"></param>
1729 /// <returns></returns> 1944 /// <returns></returns>
1730 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) 1945 private bool CanViewScript(UUID script, UUID objectID, UUID userID)
1731 { 1946 {
1732 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1947 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1733 if (m_bypassPermissions) return m_bypassPermissionsValue; 1948 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1735,7 +1950,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1735 if (objectID == UUID.Zero) // User inventory 1950 if (objectID == UUID.Zero) // User inventory
1736 { 1951 {
1737 IInventoryService invService = m_scene.InventoryService; 1952 IInventoryService invService = m_scene.InventoryService;
1738 InventoryItemBase assetRequestItem = invService.GetItem(user, script); 1953 InventoryItemBase assetRequestItem = invService.GetItem(userID, script);
1739 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 1954 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1740 { 1955 {
1741 assetRequestItem = LibraryRootFolder.FindItem(script); 1956 assetRequestItem = LibraryRootFolder.FindItem(script);
@@ -1755,60 +1970,53 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1755 // readable only if it's really full perms 1970 // readable only if it's really full perms
1756 // 1971 //
1757 if ((assetRequestItem.CurrentPermissions & 1972 if ((assetRequestItem.CurrentPermissions &
1973/*
1758 ((uint)PermissionMask.Modify | 1974 ((uint)PermissionMask.Modify |
1759 (uint)PermissionMask.Copy | 1975 (uint)PermissionMask.Copy |
1760 (uint)PermissionMask.Transfer)) != 1976 (uint)PermissionMask.Transfer)) !=
1761 ((uint)PermissionMask.Modify | 1977 ((uint)PermissionMask.Modify |
1762 (uint)PermissionMask.Copy | 1978 (uint)PermissionMask.Copy |
1763 (uint)PermissionMask.Transfer)) 1979 (uint)PermissionMask.Transfer))
1980*/
1981 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
1982 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1764 return false; 1983 return false;
1765 } 1984 }
1766 else // Prim inventory 1985 else // Prim inventory
1767 { 1986 {
1768 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1987 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1769
1770 if (part == null) 1988 if (part == null)
1771 return false; 1989 return false;
1772 1990
1773 if (part.OwnerID != user) 1991 SceneObjectGroup sog = part.ParentGroup;
1774 { 1992 if (sog == null)
1775 if (part.GroupID == UUID.Zero) 1993 return false;
1776 return false;
1777
1778 if (!IsGroupMember(part.GroupID, user, 0))
1779 return false;
1780 1994
1781 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1995 uint perms = GetObjectPermissions(userID, sog, true);
1782 return false; 1996 if((perms & (uint)PermissionMask.Modify) == 0)
1783 } 1997 return false;
1784 else
1785 {
1786 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1787 return false;
1788 }
1789 1998
1790 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); 1999 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
1791 2000
1792 if (ti == null) 2001// if (ti == null || ti.InvType != (int)InventoryType.LSL)
2002 if (ti == null) // legacy may not have type
1793 return false; 2003 return false;
1794 2004
1795 if (ti.OwnerID != user) 2005 uint itperms = GetObjectItemPermissions(userID, ti);
1796 {
1797 if (ti.GroupID == UUID.Zero)
1798 return false;
1799
1800 if (!IsGroupMember(ti.GroupID, user, 0))
1801 return false;
1802 }
1803 2006
1804 // Require full perms 2007 // Require full perms
1805 if ((ti.CurrentPermissions & 2008
1806 ((uint)PermissionMask.Modify | 2009 if ((itperms &
2010/*
2011 ((uint)(PermissionMask.Modify |
1807 (uint)PermissionMask.Copy | 2012 (uint)PermissionMask.Copy |
1808 (uint)PermissionMask.Transfer)) != 2013 (uint)PermissionMask.Transfer)) !=
1809 ((uint)PermissionMask.Modify | 2014 ((uint)PermissionMask.Modify |
1810 (uint)PermissionMask.Copy | 2015 (uint)PermissionMask.Copy |
1811 (uint)PermissionMask.Transfer)) 2016 (uint)PermissionMask.Transfer))
2017*/
2018 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2019 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1812 return false; 2020 return false;
1813 } 2021 }
1814 2022
@@ -1823,7 +2031,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1823 /// <param name="user"></param> 2031 /// <param name="user"></param>
1824 /// <param name="scene"></param> 2032 /// <param name="scene"></param>
1825 /// <returns></returns> 2033 /// <returns></returns>
1826 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 2034 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID userID)
1827 { 2035 {
1828 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2036 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1829 if (m_bypassPermissions) return m_bypassPermissionsValue; 2037 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1831,7 +2039,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1831 if (objectID == UUID.Zero) // User inventory 2039 if (objectID == UUID.Zero) // User inventory
1832 { 2040 {
1833 IInventoryService invService = m_scene.InventoryService; 2041 IInventoryService invService = m_scene.InventoryService;
1834 InventoryItemBase assetRequestItem = invService.GetItem(user, notecard); 2042 InventoryItemBase assetRequestItem = invService.GetItem(userID, notecard);
1835 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2043 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1836 { 2044 {
1837 assetRequestItem = LibraryRootFolder.FindItem(notecard); 2045 assetRequestItem = LibraryRootFolder.FindItem(notecard);
@@ -1849,40 +2057,29 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1849 } 2057 }
1850 else // Prim inventory 2058 else // Prim inventory
1851 { 2059 {
1852 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2060 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1853
1854 if (part == null) 2061 if (part == null)
1855 return false; 2062 return false;
1856 2063
1857 if (part.OwnerID != user) 2064 SceneObjectGroup sog = part.ParentGroup;
1858 { 2065 if (sog == null)
1859 if (part.GroupID == UUID.Zero) 2066 return false;
1860 return false;
1861
1862 if (!IsGroupMember(part.GroupID, user, 0))
1863 return false;
1864 }
1865 2067
1866 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 2068 uint perms = GetObjectPermissions(userID, sog, true);
2069 if((perms & (uint)PermissionMask.Modify) == 0)
1867 return false; 2070 return false;
1868 2071
1869 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 2072 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1870 2073
2074// if (ti == null || ti.InvType != (int)InventoryType.Notecard)
1871 if (ti == null) 2075 if (ti == null)
1872 return false; 2076 return false;
1873 2077
1874 if (ti.OwnerID != user) 2078 uint itperms = GetObjectItemPermissions(userID, ti);
1875 {
1876 if (ti.GroupID == UUID.Zero)
1877 return false;
1878
1879 if (!IsGroupMember(ti.GroupID, user, 0))
1880 return false;
1881 }
1882 2079
1883 // Notecards are always readable unless no copy 2080 // Notecards are always readable unless no copy
1884 // 2081 //
1885 if ((ti.CurrentPermissions & 2082 if ((itperms &
1886 (uint)PermissionMask.Copy) != 2083 (uint)PermissionMask.Copy) !=
1887 (uint)PermissionMask.Copy) 2084 (uint)PermissionMask.Copy)
1888 return false; 2085 return false;
@@ -1898,7 +2095,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1898 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2095 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1899 if (m_bypassPermissions) return m_bypassPermissionsValue; 2096 if (m_bypassPermissions) return m_bypassPermissionsValue;
1900 2097
1901 return GenericObjectPermission(userID, objectID, false); 2098 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2099 if (sog == null)
2100 return false;
2101
2102 uint perms = GetObjectPermissions(userID, sog, true);
2103 if((perms & (uint)PermissionMask.Modify) == 0)
2104 return false;
2105 return true;
1902 } 2106 }
1903 2107
1904 private bool CanDelinkObject(UUID userID, UUID objectID) 2108 private bool CanDelinkObject(UUID userID, UUID objectID)
@@ -1906,10 +2110,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1906 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2110 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1907 if (m_bypassPermissions) return m_bypassPermissionsValue; 2111 if (m_bypassPermissions) return m_bypassPermissionsValue;
1908 2112
1909 return GenericObjectPermission(userID, objectID, false); 2113 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2114 if (sog == null)
2115 return false;
2116
2117 uint perms = GetObjectPermissions(userID, sog, true);
2118 if((perms & (uint)PermissionMask.Modify) == 0)
2119 return false;
2120 return true;
1910 } 2121 }
1911 2122
1912 private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene) 2123 private bool CanBuyLand(UUID userID, ILandObject parcel)
1913 { 2124 {
1914 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2125 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1915 if (m_bypassPermissions) return m_bypassPermissionsValue; 2126 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1922,6 +2133,130 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1922 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2133 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1923 if (m_bypassPermissions) return m_bypassPermissionsValue; 2134 if (m_bypassPermissions) return m_bypassPermissionsValue;
1924 2135
2136 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2137 if (part == null)
2138 return false;
2139
2140 SceneObjectGroup sog = part.ParentGroup;
2141 if (sog == null)
2142 return false;
2143
2144 uint perms = GetObjectPermissions(userID, sog, true);
2145 if((perms & (uint)PermissionMask.Modify) == 0)
2146 return false;
2147
2148 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2149 if(ti == null)
2150 return false;
2151
2152 uint itperms = GetObjectItemPermissions(userID, ti);
2153
2154 if((itperms & (uint)PermissionMask.Copy) == 0)
2155 return false;
2156
2157 if(sog.OwnerID != userID && (itperms & (uint)PermissionMask.Transfer) == 0)
2158 return false;
2159
2160 return true;
2161 }
2162
2163 // object inventory to object inventory item drag and drop
2164 private bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
2165 {
2166 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2167
2168 if (sourcePart == null || destPart == null || item == null)
2169 return false;
2170
2171 if (m_bypassPermissions)
2172 return m_bypassPermissionsValue;
2173
2174 SceneObjectGroup srcsog = sourcePart.ParentGroup;
2175 SceneObjectGroup destsog = destPart.ParentGroup;
2176 if (srcsog == null || destsog == null)
2177 return false;
2178
2179 // dest is locked
2180 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2181 return false;
2182
2183 uint itperms = item.CurrentPermissions;
2184
2185 // if item is no copy the source is modifed
2186 if((itperms & (uint)PermissionMask.Copy) == 0 && (srcsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2187 return false;
2188
2189 UUID srcOwner = srcsog.OwnerID;
2190 UUID destOwner = destsog.OwnerID;
2191 bool notSameOwner = srcOwner != destOwner;
2192
2193 if(notSameOwner)
2194 {
2195 if((itperms & (uint)PermissionMask.Transfer) == 0)
2196 return false;
2197
2198 // scripts can't be droped
2199 if(item.InvType == (int)InventoryType.LSL)
2200 return false;
2201
2202 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
2203 return false;
2204 }
2205 else
2206 {
2207 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0 &&
2208 (destsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2209 return false;
2210 }
2211
2212 return true;
2213 }
2214
2215 private bool CanDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart)
2216 {
2217 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2218
2219 if (sp == null || sp.IsDeleted || destPart == null || item == null)
2220 return false;
2221
2222 SceneObjectGroup destsog = destPart.ParentGroup;
2223 if (destsog == null || destsog.IsDeleted)
2224 return false;
2225
2226 if (m_bypassPermissions)
2227 return m_bypassPermissionsValue;
2228
2229 if(sp.IsGod)
2230 return true;
2231
2232 // dest is locked
2233 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2234 return false;
2235
2236 UUID destOwner = destsog.OwnerID;
2237 UUID spID = sp.UUID;
2238 bool spNotOwner = spID != destOwner;
2239
2240 // scripts can't be droped
2241 if(spNotOwner && item.InvType == (int)InventoryType.LSL)
2242 return false;
2243
2244 if(spNotOwner || item.Owner != destOwner)
2245 {
2246 // no copy item will be moved if it has transfer
2247 uint itperms = item.CurrentPermissions;
2248 if((itperms & (uint)PermissionMask.Transfer) == 0)
2249 return false;
2250 }
2251
2252 // allowdrop is a root part thing and does bypass modify rights
2253 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
2254 return true;
2255
2256 uint perms = GetObjectPermissions(spID, destsog, true);
2257 if((perms & (uint)PermissionMask.Modify) == 0)
2258 return false;
2259
1925 return true; 2260 return true;
1926 } 2261 }
1927 2262
@@ -1930,6 +2265,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1930 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2265 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1931 if (m_bypassPermissions) return m_bypassPermissionsValue; 2266 if (m_bypassPermissions) return m_bypassPermissionsValue;
1932 2267
2268 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2269 if (part == null)
2270 return false;
2271
2272 SceneObjectGroup sog = part.ParentGroup;
2273 if (sog == null)
2274 return false;
2275
2276 uint perms = GetObjectPermissions(userID, sog, true);
2277 if((perms & (uint)PermissionMask.Modify) == 0)
2278 return false;
2279
2280 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2281 if(ti == null)
2282 return false;
2283
2284 //TODO item perm ?
1933 return true; 2285 return true;
1934 } 2286 }
1935 2287
@@ -1946,26 +2298,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1946 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2298 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1947 if (m_bypassPermissions) return m_bypassPermissionsValue; 2299 if (m_bypassPermissions) return m_bypassPermissionsValue;
1948 2300
1949 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1950 ScenePresence p = m_scene.GetScenePresence(userID); 2301 ScenePresence p = m_scene.GetScenePresence(userID);
1951 2302
1952 if (part == null || p == null) 2303 if (p == null)
1953 return false; 2304 return false;
1954 2305
1955 if (!IsAdministrator(userID)) 2306 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2307 if (sog == null)
2308 return false;
2309
2310 uint perms = GetObjectPermissions(userID, sog, true);
2311 if((perms & (uint)PermissionMask.Modify) == 0)
2312 return false;
2313
2314 if ((int)InventoryType.LSL == invType)
1956 { 2315 {
1957 if (part.OwnerID != userID) 2316 if (m_allowedScriptCreators == UserSet.Administrators)
1958 { 2317 return false;
1959 // Group permissions
1960 if ((part.GroupID == UUID.Zero) || (p.ControllingClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
1961 return false;
1962 } else {
1963 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1964 return false;
1965 }
1966 if ((int)InventoryType.LSL == invType)
1967 if (m_allowedScriptCreators == UserSet.Administrators)
1968 return false;
1969 } 2318 }
1970 2319
1971 return true; 2320 return true;
@@ -2039,22 +2388,22 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2039 return true; 2388 return true;
2040 } 2389 }
2041 2390
2042 private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene) 2391 private bool CanResetScript(UUID primID, UUID script, UUID agentID)
2043 { 2392 {
2044 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2393 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2045 if (m_bypassPermissions) return m_bypassPermissionsValue; 2394 if (m_bypassPermissions) return m_bypassPermissionsValue;
2046 2395
2047 SceneObjectPart part = m_scene.GetSceneObjectPart(prim); 2396 SceneObjectGroup sog = m_scene.GetGroupByPrim(primID);
2048 2397 if (sog == null)
2049 // If we selected a sub-prim to reset, prim won't represent the object, but only a part. 2398 return false;
2050 // We have to check the permissions of the object, though.
2051 if (part.ParentID != 0) prim = part.ParentUUID;
2052 2399
2053 // You can reset the scripts in any object you can edit 2400 uint perms = GetObjectPermissions(agentID, sog, false);
2054 return GenericObjectPermission(agentID, prim, false); 2401 if((perms & (uint)PermissionMask.Modify) == 0) // ??
2402 return false;
2403 return true;
2055 } 2404 }
2056 2405
2057 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) 2406 private bool CanCompileScript(UUID ownerUUID, int scriptType)
2058 { 2407 {
2059 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); 2408 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
2060 switch (scriptType) { 2409 switch (scriptType) {
@@ -2112,7 +2461,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2112// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 2461// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
2113// agentID, primID, face, me.ControlPermissions); 2462// agentID, primID, face, me.ControlPermissions);
2114 2463
2115 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true); 2464 SceneObjectGroup sog = part.ParentGroup;
2465 if (sog == null)
2466 return false;
2467
2468 uint perms = GetObjectPermissions(agentID, sog, false);
2469 if((perms & (uint)PermissionMask.Modify) == 0)
2470 return false;
2471 return true;
2116 } 2472 }
2117 2473
2118 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 2474 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index 04b6f00..167f6b5 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -105,8 +105,9 @@ namespace OpenSim.Region.CoreModules.World.Vegetation
105 if (rootPart.Shape.PCode != (byte)PCode.Grass) 105 if (rootPart.Shape.PCode != (byte)PCode.Grass)
106 AdaptTree(ref shape); 106 AdaptTree(ref shape);
107 107
108 m_scene.AddNewSceneObject(sceneObject, true);
109 sceneObject.SetGroup(groupID, null); 108 sceneObject.SetGroup(groupID, null);
109 m_scene.AddNewSceneObject(sceneObject, true);
110 sceneObject.AggregatePerms();
110 111
111 return sceneObject; 112 return sceneObject;
112 } 113 }