aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-05 06:44:32 +0000
committerTeravus Ovares2007-12-05 06:44:32 +0000
commitbb824eadeeb2b35025954d0c97f15123c6fd0cbe (patch)
treeafca518b8e5b806cd2e7ab7965d34765d4b18bc4 /OpenSim/Region/Environment
parentfixed a few compiler warnings under mono (committed from a train, with adjohn... (diff)
downloadopensim-SC-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.zip
opensim-SC-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.gz
opensim-SC-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.bz2
opensim-SC-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.xz
* Refactored Permissions into ScenePresence as requested by MW
* Un-hackerized generating the client_flags * Now handling the ObjectPermissions Update packet * Warning: Backup your prim before updating. If you fail to do so and something goes wrong then, All Yr prim are belong to us!
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs52
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs49
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs33
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs270
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs9
7 files changed, 286 insertions, 132 deletions
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index 9911792..573fc29 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Region.Environment
164 if (user == objectOwner) 164 if (user == objectOwner)
165 permission = true; 165 permission = true;
166 166
167 // If the 'anybody can move' flag is set then allow anyone to move it 167 // If the 'anybody can move' flag is set then allow anyone to copy it
168 if ((objectflags & (uint)LLObject.ObjectFlags.ObjectCopy ) != 0) 168 if ((objectflags & (uint)LLObject.ObjectFlags.ObjectCopy ) != 0)
169 permission = true; 169 permission = true;
170 170
@@ -212,7 +212,7 @@ namespace OpenSim.Region.Environment
212 // Added this because at this point in time it wouldn't be wise for 212 // Added this because at this point in time it wouldn't be wise for
213 // the administrator object permissions to take effect. 213 // the administrator object permissions to take effect.
214 LLUUID objectOwner = task.OwnerID; 214 LLUUID objectOwner = task.OwnerID;
215 uint objectflags = task.RootPart.ObjectFlags; 215 uint objectflags = task.RootPart.EveryoneMask;
216 216
217 // Object owners should be able to edit their own content 217 // Object owners should be able to edit their own content
218 if (user == objectOwner) 218 if (user == objectOwner)
@@ -242,6 +242,54 @@ namespace OpenSim.Region.Environment
242 return permission; 242 return permission;
243 243
244 } 244 }
245 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)
246 {
247 if (!m_scene.Entities.ContainsKey(objID))
248 {
249 return 0;
250 }
251
252 // If it's not an object, we cant edit it.
253 if (!(m_scene.Entities[objID] is SceneObjectGroup))
254 {
255 return 0;
256 }
257
258 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID];
259 LLUUID taskOwner = null;
260 // Added this because at this point in time it wouldn't be wise for
261 // the administrator object permissions to take effect.
262 LLUUID objectOwner = task.OwnerID;
263 uint OwnerMask = task.RootPart.ObjectFlags | task.RootPart.OwnerMask;
264 uint GroupMask = task.RootPart.ObjectFlags | task.RootPart.GroupMask;
265 uint EveryoneMask = task.RootPart.ObjectFlags | task.RootPart.EveryoneMask;
266
267 if (m_bypassPermissions)
268 return OwnerMask;
269
270 // Object owners should be able to edit their own content
271 if (user == objectOwner)
272 return OwnerMask;
273
274 // Users should be able to edit what is over their land.
275 if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
276 user)
277 return OwnerMask;
278
279 // Estate users should be able to edit anything in the sim
280 if (IsEstateManager(user))
281 return OwnerMask;
282
283 // Admin objects should not be editable by the above
284 if (IsAdministrator(taskOwner))
285 return EveryoneMask;
286
287 // Admin should be able to edit anything in the sim (including admin objects)
288 if (IsAdministrator(user))
289 return OwnerMask;
290
291 return 0;
292 }
245 293
246 protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) 294 protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId)
247 { 295 {
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 2511baf..4c168b3 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -555,7 +555,7 @@ namespace OpenSim.Region.Environment.Scenes
555 555
556 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 556 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
557 { 557 {
558 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) 558 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID) || PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, objectID))
559 { 559 {
560 SceneObjectGroup group = GetGroupByPrim(objectID); 560 SceneObjectGroup group = GetGroupByPrim(objectID);
561 if (group != null) 561 if (group != null)
@@ -729,7 +729,7 @@ namespace OpenSim.Region.Environment.Scenes
729 729
730 if (originPrim != null) 730 if (originPrim != null)
731 { 731 {
732 if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID)) 732 if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID) || PermissionsMngr.AnyoneCanCopyPermission(AgentID, originPrim.UUID))
733 { 733 {
734 SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID); 734 SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID);
735 copy.AbsolutePosition = copy.AbsolutePosition + offset; 735 copy.AbsolutePosition = copy.AbsolutePosition + offset;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index f518d63..cf845a6 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -543,6 +543,7 @@ namespace OpenSim.Region.Environment.Scenes
543 AddEntity(group); 543 AddEntity(group);
544 group.AbsolutePosition = pos; 544 group.AbsolutePosition = pos;
545 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 545 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
546 rootPart.ApplySanePermissions();
546 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); 547 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim);
547 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 548 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
548 { 549 {
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index f9cace2..1f43f53 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -733,20 +733,8 @@ namespace OpenSim.Region.Environment.Scenes
733 { 733 {
734 AddEntityFromStorage(prim); 734 AddEntityFromStorage(prim);
735 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 735 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
736 if (m_permissions) 736 rootPart.ApplySanePermissions();
737 { 737
738 rootPart.EveryoneMask = rootPart.ObjectFlags;
739 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
740 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
741 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
742 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
743 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
744 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
745 }
746 else
747 {
748 rootPart.EveryoneMask = rootPart.ObjectFlags;
749 }
750 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 738 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
751 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 739 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
752 rootPart.PhysActor = PhysicsScene.AddPrimShape( 740 rootPart.PhysActor = PhysicsScene.AddPrimShape(
@@ -839,6 +827,7 @@ namespace OpenSim.Region.Environment.Scenes
839 AddEntity(sceneOb); 827 AddEntity(sceneOb);
840 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); 828 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
841 // if grass or tree, make phantom 829 // if grass or tree, make phantom
830 //rootPart.ApplySanePermissions();
842 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) 831 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
843 { 832 {
844 rootPart.AddFlag(LLObject.ObjectFlags.Phantom); 833 rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
@@ -983,6 +972,7 @@ namespace OpenSim.Region.Environment.Scenes
983 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 972 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
984 client.OnRequestGodlikePowers += handleRequestGodlikePowers; 973 client.OnRequestGodlikePowers += handleRequestGodlikePowers;
985 client.OnGodKickUser += handleGodlikeKickUser; 974 client.OnGodKickUser += handleGodlikeKickUser;
975 client.OnObjectPermissions += HandleObjectPermissionsUpdate;
986 976
987 client.OnCreateNewInventoryItem += CreateNewInventoryItem; 977 client.OnCreateNewInventoryItem += CreateNewInventoryItem;
988 client.OnCreateNewInventoryFolder += CommsManager.UserProfileCacheService.HandleCreateInventoryFolder; 978 client.OnCreateNewInventoryFolder += CommsManager.UserProfileCacheService.HandleCreateInventoryFolder;
@@ -1404,16 +1394,16 @@ namespace OpenSim.Region.Environment.Scenes
1404 { 1394 {
1405 if (godid == RegionInfo.MasterAvatarAssignedUUID) 1395 if (godid == RegionInfo.MasterAvatarAssignedUUID)
1406 { 1396 {
1407 if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb")) 1397 if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb"))
1408 { 1398 {
1409 1399
1410 ClientManager.ForEachClient(delegate (IClientAPI controller) 1400 ClientManager.ForEachClient(delegate(IClientAPI controller)
1411 { 1401 {
1412 ScenePresence p = GetScenePresence(controller.AgentId); 1402 ScenePresence p = GetScenePresence(controller.AgentId);
1413 bool childagent = false; 1403 bool childagent = false;
1414 if (!p.Equals(null)) 1404 if (!p.Equals(null))
1415 if (p.IsChildAgent) 1405 if (p.IsChildAgent)
1416 childagent=true; 1406 childagent = true;
1417 if (controller.AgentId != godid && !childagent) // Do we really want to kick the initiator of this madness? 1407 if (controller.AgentId != godid && !childagent) // Do we really want to kick the initiator of this madness?
1418 { 1408 {
1419 controller.Kick(Helpers.FieldToUTF8String(reason)); 1409 controller.Kick(Helpers.FieldToUTF8String(reason));
@@ -1424,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes
1424 // This is a bit crude. It seems the client will be null before it actually stops the thread 1414 // This is a bit crude. It seems the client will be null before it actually stops the thread
1425 // The thread will kill itself eventually :/ 1415 // The thread will kill itself eventually :/
1426 // Is there another way to make sure *all* clients get this 'inter region' message? 1416 // Is there another way to make sure *all* clients get this 'inter region' message?
1427 ClientManager.ForEachClient(delegate (IClientAPI controller) 1417 ClientManager.ForEachClient(delegate(IClientAPI controller)
1428 { 1418 {
1429 ScenePresence p = GetScenePresence(controller.AgentId); 1419 ScenePresence p = GetScenePresence(controller.AgentId);
1430 bool childagent = false; 1420 bool childagent = false;
@@ -1439,7 +1429,7 @@ namespace OpenSim.Region.Environment.Scenes
1439 } 1429 }
1440 ); 1430 );
1441 } 1431 }
1442 else 1432 else
1443 { 1433 {
1444 m_scenePresences[agentid].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); 1434 m_scenePresences[agentid].ControllingClient.Kick(Helpers.FieldToUTF8String(reason));
1445 m_scenePresences[agentid].ControllingClient.Close(); 1435 m_scenePresences[agentid].ControllingClient.Close();
@@ -1452,7 +1442,26 @@ namespace OpenSim.Region.Environment.Scenes
1452 } 1442 }
1453 } 1443 }
1454 } 1444 }
1445 public void HandleObjectPermissionsUpdate (IClientAPI controller, LLUUID AgentID, LLUUID SessionID, List<libsecondlife.Packets.ObjectPermissionsPacket.ObjectDataBlock> permChanges)
1446 {
1447 // Check for spoofing.. since this is permissions we're talking about here!
1448 if ((controller.SessionId == SessionID) && (controller.AgentId == AgentID))
1449 {
1450 for (int i = 0; i < permChanges.Count; i++)
1451 {
1452
1453 // Tell the object to do permission update
1454 byte field = permChanges[i].Field;
1455 uint localID = permChanges[i].ObjectLocalID;
1456 uint mask = permChanges[i].Mask;
1457 byte addRemTF = permChanges[i].Set;
1458 SceneObjectGroup chObjectGroup = GetGroupByPrim(localID);
1459 chObjectGroup.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
1455 1460
1461 }
1462 }
1463
1464 }
1456 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 1465 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
1457 { 1466 {
1458 foreach (ScenePresence presence in m_scenePresences.Values) 1467 foreach (ScenePresence presence in m_scenePresences.Values)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index fe135de..d2cf2a3 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -283,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes
283 AddPart(part); 283 AddPart(part);
284 part.RegionHandle = m_regionHandle; 284 part.RegionHandle = m_regionHandle;
285 285
286 part.ApplyPermissions(); 286 part.ApplySanePermissions();
287 } 287 }
288 break; 288 break;
289 case XmlNodeType.EndElement: 289 case XmlNodeType.EndElement:
@@ -530,7 +530,7 @@ namespace OpenSim.Region.Environment.Scenes
530 dupe.m_regionHandle = m_regionHandle; 530 dupe.m_regionHandle = m_regionHandle;
531 531
532 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID); 532 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID);
533 533 dupe.m_rootPart.ApplySanePermissions();
534 534
535 /// may need to create a new Physics actor. 535 /// may need to create a new Physics actor.
536 if (dupe.RootPart.PhysActor != null) 536 if (dupe.RootPart.PhysActor != null)
@@ -555,6 +555,8 @@ namespace OpenSim.Region.Environment.Scenes
555 // So, we have to make a copy of this one, set it in it's place then set the owner on this one 555 // So, we have to make a copy of this one, set it in it's place then set the owner on this one
556 556
557 SetRootPartOwner(m_rootPart, cAgentID, cGroupID); 557 SetRootPartOwner(m_rootPart, cAgentID, cGroupID);
558
559
558 m_rootPart.ScheduleFullUpdate(); 560 m_rootPart.ScheduleFullUpdate();
559 561
560 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values); 562 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values);
@@ -592,6 +594,15 @@ namespace OpenSim.Region.Environment.Scenes
592 part.LastOwnerID = part.OwnerID; 594 part.LastOwnerID = part.OwnerID;
593 part.OwnerID = cAgentID; 595 part.OwnerID = cAgentID;
594 part.GroupID = cGroupID; 596 part.GroupID = cGroupID;
597
598
599 if (part.OwnerID != cAgentID)
600 {
601 // Apply Next Owner Permissions if we're not bypassing permissions
602 if (!m_scene.PermissionsMngr.BypassPermissions)
603 m_rootPart.ApplyNextOwnerPermissions();
604 }
605
595 part.ScheduleFullUpdate(); 606 part.ScheduleFullUpdate();
596 } 607 }
597 608
@@ -1224,6 +1235,14 @@ namespace OpenSim.Region.Environment.Scenes
1224 } 1235 }
1225 } 1236 }
1226 1237
1238 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1239 {
1240 SceneObjectPart updatePart = GetChildPart(localID);
1241 updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF);
1242 }
1243
1244
1245
1227 #endregion 1246 #endregion
1228 1247
1229 #region Shape 1248 #region Shape
@@ -1514,13 +1533,13 @@ namespace OpenSim.Region.Environment.Scenes
1514 1533
1515 #region Client Updating 1534 #region Client Updating
1516 1535
1517 public void SendFullUpdateToClient(IClientAPI remoteClient) 1536 public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientFlags)
1518 { 1537 {
1519 lock (m_parts) 1538 lock (m_parts)
1520 { 1539 {
1521 foreach (SceneObjectPart part in m_parts.Values) 1540 foreach (SceneObjectPart part in m_parts.Values)
1522 { 1541 {
1523 SendPartFullUpdate(remoteClient, part); 1542 SendPartFullUpdate(remoteClient, part, clientFlags);
1524 } 1543 }
1525 } 1544 }
1526 } 1545 }
@@ -1530,15 +1549,15 @@ namespace OpenSim.Region.Environment.Scenes
1530 /// </summary> 1549 /// </summary>
1531 /// <param name="remoteClient"></param> 1550 /// <param name="remoteClient"></param>
1532 /// <param name="part"></param> 1551 /// <param name="part"></param>
1533 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part) 1552 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1534 { 1553 {
1535 if (m_rootPart.UUID == part.UUID) 1554 if (m_rootPart.UUID == part.UUID)
1536 { 1555 {
1537 part.SendFullUpdateToClient(remoteClient, AbsolutePosition); 1556 part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
1538 } 1557 }
1539 else 1558 else
1540 { 1559 {
1541 part.SendFullUpdateToClient(remoteClient); 1560 part.SendFullUpdateToClient(remoteClient, clientFlags);
1542 } 1561 }
1543 } 1562 }
1544 1563
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 19405fc..238e78a 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -44,8 +44,12 @@ namespace OpenSim.Region.Environment.Scenes
44{ 44{
45 public class SceneObjectPart : IScriptHost 45 public class SceneObjectPart : IScriptHost
46 { 46 {
47 private const uint FULL_MASK_PERMISSIONS = 2147483647; 47 private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer;
48 48 private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner;
49 private const uint OBJNEXT_OWNER = 2147483647;
50
51 private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
52 private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
49 private string m_inventoryFileName = ""; 53 private string m_inventoryFileName = "";
50 private LLUUID m_folderID = LLUUID.Zero; 54 private LLUUID m_folderID = LLUUID.Zero;
51 55
@@ -64,11 +68,13 @@ namespace OpenSim.Region.Environment.Scenes
64 public Int32 CreationDate; 68 public Int32 CreationDate;
65 public uint ParentID = 0; 69 public uint ParentID = 0;
66 70
67 public uint OwnerMask = FULL_MASK_PERMISSIONS; 71 // Main grid has default permissions as follows
68 public uint NextOwnerMask = FULL_MASK_PERMISSIONS; 72 //
69 public uint GroupMask = FULL_MASK_PERMISSIONS; 73 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
70 public uint EveryoneMask = FULL_MASK_PERMISSIONS; 74 public uint NextOwnerMask = OBJNEXT_OWNER;
71 public uint BaseMask = FULL_MASK_PERMISSIONS; 75 public uint GroupMask = (uint) LLObject.ObjectFlags.None;
76 public uint EveryoneMask = (uint) LLObject.ObjectFlags.None;
77 public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER;
72 78
73 protected byte[] m_particleSystem = new byte[0]; 79 protected byte[] m_particleSystem = new byte[0];
74 80
@@ -463,17 +469,11 @@ namespace OpenSim.Region.Environment.Scenes
463 m_folderID = LLUUID.Random(); 469 m_folderID = LLUUID.Random();
464 470
465 m_flags = 0; 471 m_flags = 0;
466 m_flags |= LLObject.ObjectFlags.ObjectModify | 472 m_flags |= LLObject.ObjectFlags.Touch |
467 LLObject.ObjectFlags.ObjectCopy | 473 LLObject.ObjectFlags.AllowInventoryDrop |
468 LLObject.ObjectFlags.ObjectYouOwner | 474 LLObject.ObjectFlags.CreateSelected;
469 LLObject.ObjectFlags.Touch | 475
470 LLObject.ObjectFlags.ObjectMove | 476 ApplySanePermissions();
471 LLObject.ObjectFlags.AllowInventoryDrop |
472 LLObject.ObjectFlags.ObjectTransfer |
473 LLObject.ObjectFlags.CreateSelected |
474 LLObject.ObjectFlags.ObjectOwnerModify;
475
476 ApplyPermissions();
477 477
478 ScheduleFullUpdate(); 478 ScheduleFullUpdate();
479 } 479 }
@@ -511,7 +511,7 @@ namespace OpenSim.Region.Environment.Scenes
511 RotationOffset = rotation; 511 RotationOffset = rotation;
512 ObjectFlags = flags; 512 ObjectFlags = flags;
513 513
514 ApplyPermissions(); 514 ApplySanePermissions();
515 // ApplyPhysics(); 515 // ApplyPhysics();
516 516
517 ScheduleFullUpdate(); 517 ScheduleFullUpdate();
@@ -552,24 +552,99 @@ namespace OpenSim.Region.Environment.Scenes
552 552
553 DoPhysicsPropertyUpdate(usePhysics, true); 553 DoPhysicsPropertyUpdate(usePhysics, true);
554 } 554 }
555 public void ApplyNextOwnerPermissions()
556 {
557 BaseMask = NextOwnerMask;
558 OwnerMask = NextOwnerMask;
559 }
560 public void ApplySanePermissions()
561 {
562 // These are some flags that The OwnerMask should never have
563 OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
564 OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
565 OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
566 OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
567 OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
568 OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
569 OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
570 OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
571 OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
572 OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
573 OwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
574 OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
575 OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
576 OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
577
578
579 // These are some flags that the next owner mask should never have
580 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
581 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
582 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
583 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
584 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
585 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
586 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
587 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
588 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
589 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
590 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
591 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
592 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
593 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
594 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
595 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
596 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
597
598
599 // These are some flags that the GroupMask should never have
600 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
601 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
602 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
603 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
604 GroupMask &= ~(uint)LLObject.ObjectFlags.Physics;
605 GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom;
606 GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted;
607 GroupMask &= ~(uint)LLObject.ObjectFlags.Touch;
608 GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary;
609 GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
610 GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
611 GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
612 GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
613 GroupMask &= ~(uint)LLObject.ObjectFlags.Money;
614 GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
615 GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
616 GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
617
618
619 // These are some flags that EveryoneMask should never have
620 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
621 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
622 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
623 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
624 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics;
625 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom;
626 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted;
627 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch;
628 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary;
629 EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
630 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
631 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
632 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
633 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money;
634 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
635 EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
636 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
637
638
639 // These are some flags that ObjectFlags (m_flags) should never have
640 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
641 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
642 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
643 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
644 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
645 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
646 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
555 647
556 public void ApplyPermissions()
557 {
558 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
559 {
560 EveryoneMask = ObjectFlags;
561 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
562 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
563 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
564 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
565 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
566 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
567 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
568 }
569 else
570 {
571 EveryoneMask = ObjectFlags;
572 }
573 } 648 }
574 649
575 /// <summary> 650 /// <summary>
@@ -774,9 +849,7 @@ namespace OpenSim.Region.Environment.Scenes
774 { 849 {
775 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); 850 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
776 m_flags |= flag; 851 m_flags |= flag;
777 BaseMask |= (uint)flag; 852
778 GroupMask |= (uint)flag;
779 EveryoneMask |= (uint)flag;
780 } 853 }
781 uint currflag = (uint)m_flags; 854 uint currflag = (uint)m_flags;
782 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 855 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
@@ -790,9 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
790 { 863 {
791 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); 864 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
792 m_flags &= ~flag; 865 m_flags &= ~flag;
793 BaseMask &= ~(uint)flag; 866
794 GroupMask &= ~(uint)flag;
795 EveryoneMask &= ~(uint)flag;
796 } 867 }
797 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 868 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
798 //ScheduleFullUpdate(); 869 //ScheduleFullUpdate();
@@ -1198,6 +1269,51 @@ namespace OpenSim.Region.Environment.Scenes
1198 1269
1199 #endregion 1270 #endregion
1200 1271
1272 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1273 {
1274 // Are we the owner?
1275 if (AgentID == OwnerID)
1276 {
1277 MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString());
1278
1279 //Field 8 = EveryoneMask
1280 if (field == (byte)8)
1281 {
1282 MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask));
1283 if (addRemTF == (byte)0)
1284 {
1285 //EveryoneMask = (uint)0;
1286 EveryoneMask &= ~mask;
1287 //EveryoneMask &= ~(uint)57344;
1288
1289
1290 }
1291 else
1292 {
1293 //EveryoneMask = (uint)0;
1294 EveryoneMask |= mask;
1295 //EveryoneMask |= (uint)57344;
1296
1297 }
1298 ScheduleFullUpdate();
1299 }
1300 //Field 16 = NextownerMask
1301 if (field == (byte)16)
1302 {
1303 if (addRemTF == (byte)0)
1304 {
1305 NextOwnerMask &= ~mask;
1306 }
1307 else
1308 {
1309 NextOwnerMask |= mask;
1310 }
1311 ScheduleFullUpdate();
1312 }
1313
1314 }
1315 }
1316
1201 #region Client Update Methods 1317 #region Client Update Methods
1202 1318
1203 public void AddFullUpdateToAllAvatars() 1319 public void AddFullUpdateToAllAvatars()
@@ -1222,7 +1338,8 @@ namespace OpenSim.Region.Environment.Scenes
1222 List<ScenePresence> avatars = m_parentGroup.GetScenePresences(); 1338 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1223 for (int i = 0; i < avatars.Count; i++) 1339 for (int i = 0; i < avatars.Count; i++)
1224 { 1340 {
1225 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); 1341 // Ugly reference :(
1342 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID));
1226 } 1343 }
1227 } 1344 }
1228 1345
@@ -1230,20 +1347,20 @@ namespace OpenSim.Region.Environment.Scenes
1230 /// 1347 ///
1231 /// </summary> 1348 /// </summary>
1232 /// <param name="remoteClient"></param> 1349 /// <param name="remoteClient"></param>
1233 public void SendFullUpdate(IClientAPI remoteClient) 1350 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
1234 { 1351 {
1235 m_parentGroup.SendPartFullUpdate(remoteClient, this); 1352 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
1236 } 1353 }
1237 1354
1238 /// <summary> 1355 /// <summary>
1239 /// 1356 ///
1240 /// </summary> 1357 /// </summary>
1241 /// <param name="remoteClient"></param> 1358 /// <param name="remoteClient"></param>
1242 public void SendFullUpdateToClient(IClientAPI remoteClient) 1359 public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
1243 { 1360 {
1244 LLVector3 lPos; 1361 LLVector3 lPos;
1245 lPos = OffsetPosition; 1362 lPos = OffsetPosition;
1246 SendFullUpdateToClient(remoteClient, lPos); 1363 SendFullUpdateToClient(remoteClient, lPos, clientflags);
1247 } 1364 }
1248 1365
1249 /// <summary> 1366 /// <summary>
@@ -1251,56 +1368,13 @@ namespace OpenSim.Region.Environment.Scenes
1251 /// </summary> 1368 /// </summary>
1252 /// <param name="remoteClient"></param> 1369 /// <param name="remoteClient"></param>
1253 /// <param name="lPos"></param> 1370 /// <param name="lPos"></param>
1254 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) 1371 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
1255 { 1372 {
1256 LLQuaternion lRot; 1373 LLQuaternion lRot;
1257 lRot = RotationOffset; 1374 lRot = RotationOffset;
1258 uint clientFlags = ObjectFlags & ~(uint)LLObject.ObjectFlags.CreateSelected; 1375 if (remoteClient.AgentId == OwnerID)
1259
1260 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1261 foreach (ScenePresence s in avatars)
1262 { 1376 {
1263 if (s.m_uuid == OwnerID) 1377 clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected;
1264 {
1265 if (s.ControllingClient == remoteClient)
1266 {
1267 clientFlags = ObjectFlags;
1268 m_flags &= ~LLObject.ObjectFlags.CreateSelected;
1269 }
1270 break;
1271 }
1272 }
1273 // If you can't edit it, send the base permissions minus the flag to edit
1274
1275
1276 // We're going to be moving this into ScenePresence and the PermissionsManager itself.
1277 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
1278 {
1279 if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID))
1280 {
1281 // we should be merging the objectflags with the ownermask here.
1282 // TODO: Future refactoring here.
1283 clientFlags = ObjectFlags;
1284
1285 }
1286 else
1287 {
1288 //clientFlags = ObjectFlags;
1289 clientFlags = EveryoneMask;
1290 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID))
1291 {
1292 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
1293 }
1294
1295 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID))
1296 {
1297 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
1298 }
1299
1300 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
1301 clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1302 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1303 }
1304 } 1378 }
1305 1379
1306 1380
@@ -1479,11 +1553,11 @@ namespace OpenSim.Region.Environment.Scenes
1479 public LLUUID item_id = LLUUID.Zero; 1553 public LLUUID item_id = LLUUID.Zero;
1480 public LLUUID parent_id = LLUUID.Zero; //parent folder id 1554 public LLUUID parent_id = LLUUID.Zero; //parent folder id
1481 1555
1482 public uint base_mask = FULL_MASK_PERMISSIONS; 1556 public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL;
1483 public uint owner_mask = FULL_MASK_PERMISSIONS; 1557 public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
1484 public uint group_mask = FULL_MASK_PERMISSIONS; 1558 public uint group_mask = FULL_MASK_PERMISSIONS_GENERAL;
1485 public uint everyone_mask = FULL_MASK_PERMISSIONS; 1559 public uint everyone_mask = FULL_MASK_PERMISSIONS_GENERAL;
1486 public uint next_owner_mask = FULL_MASK_PERMISSIONS; 1560 public uint next_owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
1487 public LLUUID creator_id = LLUUID.Zero; 1561 public LLUUID creator_id = LLUUID.Zero;
1488 public LLUUID owner_id = LLUUID.Zero; 1562 public LLUUID owner_id = LLUUID.Zero;
1489 public LLUUID last_owner_id = LLUUID.Zero; 1563 public LLUUID last_owner_id = LLUUID.Zero;
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 524fb60..2f00515 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -343,7 +343,10 @@ namespace OpenSim.Region.Environment.Scenes
343 } 343 }
344 // } 344 // }
345 } 345 }
346 346 public uint GenerateClientFlags(LLUUID ObjectID)
347 {
348 return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID);
349 }
347 public void SendPrimUpdates() 350 public void SendPrimUpdates()
348 { 351 {
349 // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode) 352 // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode)
@@ -380,7 +383,7 @@ namespace OpenSim.Region.Environment.Scenes
380 if (update.LastFullUpdateTime < part.TimeStampFull) 383 if (update.LastFullUpdateTime < part.TimeStampFull)
381 { 384 {
382 //need to do a full update 385 //need to do a full update
383 part.SendFullUpdate(ControllingClient); 386 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
384 387
385 // We'll update to the part's timestamp rather than the current to 388 // We'll update to the part's timestamp rather than the current to
386 // avoid the race condition whereby the next tick occurs while we are 389 // avoid the race condition whereby the next tick occurs while we are
@@ -403,7 +406,7 @@ namespace OpenSim.Region.Environment.Scenes
403 else 406 else
404 { 407 {
405 //never been sent to client before so do full update 408 //never been sent to client before so do full update
406 part.SendFullUpdate(ControllingClient); 409 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
407 ScenePartUpdate update = new ScenePartUpdate(); 410 ScenePartUpdate update = new ScenePartUpdate();
408 update.FullID = part.UUID; 411 update.FullID = part.UUID;
409 update.LastFullUpdateTime = part.TimeStampFull; 412 update.LastFullUpdateTime = part.TimeStampFull;