From 57f666497bef6a68df9cc6e37ccf288c462a37b5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 7 Dec 2007 07:42:03 +0000 Subject: * Added hacked support for 'anyone can move' and 'anyone can copy'. * BACKUP YOUR PRIM BEFORE UPDATING TO THIS and then double check the prim permissions after applying it with a different avatar (then the master avatar or the prim owner avatar). * Also, beware that any objects created under the old permission scheme may react oddly. They may automatically allow anyone to modify them, (which you'll then have to un-set). * It's hacked support because when 'anyone can move is set', any avatar can modify the prim (texture, shape, scale, etc) --- OpenSim/Region/ClientStack/ClientView.cs | 38 +++-- OpenSim/Region/Environment/PermissionManager.cs | 189 +++++++++------------ OpenSim/Region/Environment/Scenes/InnerScene.cs | 101 ++++++++--- .../Region/Environment/Scenes/Scene.Inventory.cs | 3 + .../Region/Environment/Scenes/SceneObjectPart.cs | 7 +- 5 files changed, 186 insertions(+), 152 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 5a3e4b7..284a2de 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -1092,11 +1092,13 @@ namespace OpenSim.Region.ClientStack descend.ItemData[i].SaleType = 0; descend.ItemData[i].Type = (sbyte) item.assetType; descend.ItemData[i].CRC = - Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, - descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, + + Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, + descend.ItemData[i].InvType, descend.ItemData[i].Type, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, - descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, - 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, + descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); i++; count++; @@ -1168,13 +1170,15 @@ namespace OpenSim.Region.ClientStack inventoryReply.InventoryData[0].SaleType = 0; inventoryReply.InventoryData[0].Type = (sbyte) item.assetType; inventoryReply.InventoryData[0].CRC = - Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, + Helpers.InventoryCRC(inventoryReply.InventoryData[0].CreationDate, inventoryReply.InventoryData[0].SaleType, + inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, - inventoryReply.InventoryData[0].GroupID, 100, + inventoryReply.InventoryData[0].GroupID, inventoryReply.InventoryData[0].SalePrice, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, - FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, - FULL_MASK_PERMISSIONS); + inventoryReply.InventoryData[0].EveryoneMask, inventoryReply.InventoryData[0].Flags, + inventoryReply.InventoryData[0].NextOwnerMask, inventoryReply.InventoryData[0].GroupMask, + inventoryReply.InventoryData[0].OwnerMask); OutPacket(inventoryReply, ThrottleOutPacketType.Asset); } @@ -1209,13 +1213,16 @@ namespace OpenSim.Region.ClientStack InventoryReply.InventoryData[0].SaleType = 0; InventoryReply.InventoryData[0].Type = (sbyte) Item.assetType; InventoryReply.InventoryData[0].CRC = - Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, + Helpers.InventoryCRC(InventoryReply.InventoryData[0].CreationDate, InventoryReply.InventoryData[0].SaleType, + InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, - InventoryReply.InventoryData[0].GroupID, 100, + InventoryReply.InventoryData[0].GroupID, InventoryReply.InventoryData[0].SalePrice, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, - FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, - FULL_MASK_PERMISSIONS); + InventoryReply.InventoryData[0].EveryoneMask, InventoryReply.InventoryData[0].Flags, + InventoryReply.InventoryData[0].NextOwnerMask, InventoryReply.InventoryData[0].GroupMask, + InventoryReply.InventoryData[0].OwnerMask); + OutPacket(InventoryReply, ThrottleOutPacketType.Asset); } @@ -1595,6 +1602,7 @@ namespace OpenSim.Region.ClientStack outPacket.ObjectData[0].ClickAction = clickAction; //outPacket.ObjectData[0].Flags = 0; outPacket.ObjectData[0].Radius = 20; + byte[] pb = pos.GetBytes(); Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); @@ -2039,7 +2047,7 @@ namespace OpenSim.Region.ClientStack for (int i = 0; i < multipleupdate.ObjectData.Length; i++) { - if (tScene.PermissionsMngr.CanEditObject(simClient.AgentId, tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID)) + if (tScene.PermissionsMngr.CanEditObjectPosition(simClient.AgentId, tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID)) { #region position @@ -2896,7 +2904,7 @@ namespace OpenSim.Region.ClientStack { if (OnObjectDescription != null) { - OnObjectDescription(objDes.ObjectData[i].LocalID, + OnObjectDescription(this,objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); } } @@ -2907,7 +2915,7 @@ namespace OpenSim.Region.ClientStack { if (OnObjectName != null) { - OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); + OnObjectName(this,objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); } } break; diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 573fc29..37df180 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -35,7 +35,13 @@ namespace OpenSim.Region.Environment public class PermissionManager { protected Scene m_scene; - + + // These are here for testing. They will be taken out + private uint PERM_ALL = (uint)2147483647; + private uint PERM_COPY = (uint)32768; + private uint PERM_MODIFY = (uint)16384; + private uint PERM_MOVE = (uint)524288; + private uint PERM_TRANS = (uint)8192; // Bypasses the permissions engine (always returns OK) // disable in any production environment // TODO: Change this to false when permissions are a desired default @@ -136,112 +142,7 @@ namespace OpenSim.Region.Environment #region Object Permissions - public virtual bool AnyoneCanCopyPermission(LLUUID user, LLUUID objId) - { - - // Default: deny - bool permission = false; - - if (!m_scene.Entities.ContainsKey(objId)) - { - return false; - } - - // If it's not an object, we cant edit it. - if (!(m_scene.Entities[objId] is SceneObjectGroup)) - { - return false; - } - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; - LLUUID taskOwner = null; - // Added this because at this point in time it wouldn't be wise for - // the administrator object permissions to take effect. - LLUUID objectOwner = task.OwnerID; - uint objectflags = task.RootPart.EveryoneMask; - - // Object owners should be able to edit their own content - if (user == objectOwner) - permission = true; - - // If the 'anybody can move' flag is set then allow anyone to copy it - if ((objectflags & (uint)LLObject.ObjectFlags.ObjectCopy ) != 0) - permission = true; - - // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == - user) - permission = true; - - // Estate users should be able to edit anything in the sim - if (IsEstateManager(user)) - permission = true; - - // Admin objects should not be editable by the above - if (IsAdministrator(taskOwner)) - permission = false; - - // Admin should be able to edit anything in the sim (including admin objects) - if (IsAdministrator(user)) - permission = true; - - return permission; - - } - - - public virtual bool AnyoneCanMovePermission(LLUUID user, LLUUID objId) - { - - // Default: deny - bool permission = false; - - if (!m_scene.Entities.ContainsKey(objId)) - { - return false; - } - - // If it's not an object, we cant edit it. - if (!(m_scene.Entities[objId] is SceneObjectGroup)) - { - return false; - } - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; - LLUUID taskOwner = null; - // Added this because at this point in time it wouldn't be wise for - // the administrator object permissions to take effect. - LLUUID objectOwner = task.OwnerID; - uint objectflags = task.RootPart.EveryoneMask; - - // Object owners should be able to edit their own content - if (user == objectOwner) - permission = true; - - // If the 'anybody can move' flag is set then allow anyone to move it - if ((objectflags & (uint)LLObject.ObjectFlags.ObjectMove) != 0) - permission = true; - - // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == - user) - permission = true; - - // Estate users should be able to edit anything in the sim - if (IsEstateManager(user)) - permission = true; - - // Admin objects should not be editable by the above - if (IsAdministrator(taskOwner)) - permission = false; - - // Admin should be able to edit anything in the sim (including admin objects) - if (IsAdministrator(user)) - permission = true; - - return permission; - - } + public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) { if (!m_scene.Entities.ContainsKey(objID)) @@ -260,6 +161,9 @@ namespace OpenSim.Region.Environment // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. LLUUID objectOwner = task.OwnerID; + + //return task.RootPart.ObjectFlags;task.RootPart.ObjectFlags | + uint OwnerMask = task.RootPart.ObjectFlags | task.RootPart.OwnerMask; uint GroupMask = task.RootPart.ObjectFlags | task.RootPart.GroupMask; uint EveryoneMask = task.RootPart.ObjectFlags | task.RootPart.EveryoneMask; @@ -288,7 +192,20 @@ namespace OpenSim.Region.Environment if (IsAdministrator(user)) return OwnerMask; - return 0; + if (((EveryoneMask & PERM_MOVE) != 0) || ((EveryoneMask & PERM_COPY) != 0)) + { + if ((EveryoneMask & PERM_MOVE) != 0) + OwnerMask &= ~PERM_MOVE; + + if ((EveryoneMask & PERM_COPY) != 0) + OwnerMask &= ~PERM_COPY; + + OwnerMask &= ~PERM_MODIFY; + OwnerMask &= ~PERM_TRANS; + + return OwnerMask; + } + return EveryoneMask; } protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) @@ -353,15 +270,61 @@ namespace OpenSim.Region.Environment return GenericObjectPermission(user, obj); } - public virtual bool CanReturnObject(LLUUID user, LLUUID obj) + public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj) { - return GenericObjectPermission(user, obj); + bool permission = GenericObjectPermission(user,obj); + if (!permission) + { + if (!m_scene.Entities.ContainsKey(obj)) + { + return false; + } + + // If it's not an object, we cant edit it. + if (!(m_scene.Entities[obj] is SceneObjectGroup)) + { + return false; + } + + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + LLUUID taskOwner = null; + // Added this because at this point in time it wouldn't be wise for + // the administrator object permissions to take effect. + LLUUID objectOwner = task.OwnerID; + if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0) + permission = true; + } + return permission; } - public virtual bool CanCopyObject(LLUUID user, LLUUID obj) { - return true; - // return GenericObjectPermission(user, obj); + bool permission = GenericObjectPermission(user, obj); + if (!permission) + { + if (!m_scene.Entities.ContainsKey(obj)) + { + return false; + } + + // If it's not an object, we cant edit it. + if (!(m_scene.Entities[obj] is SceneObjectGroup)) + { + return false; + } + + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + LLUUID taskOwner = null; + // Added this because at this point in time it wouldn't be wise for + // the administrator object permissions to take effect. + LLUUID objectOwner = task.OwnerID; + if ((task.RootPart.EveryoneMask & PERM_COPY) != 0) + permission = true; + } + return permission; + } + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); } #endregion diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 04bdf5a..501f519 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -443,7 +443,12 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.Resize(scale, localID); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.Resize(scale, localID); + } + } } /// @@ -473,7 +478,12 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateSingleRotation(rot, localID); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateSingleRotation(rot, localID); + } + } } /// @@ -486,7 +496,12 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateGroupRotation(rot); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateGroupRotation(rot); + } + } } /// @@ -500,14 +515,24 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateGroupRotation(pos, rot); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateGroupRotation(pos, rot); + } + } } public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateSinglePosition(pos, localID); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateSinglePosition(pos, localID); + } + } } /// @@ -520,7 +545,12 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateGroupPosition(pos); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateGroupPosition(pos); + } + } } /// @@ -533,7 +563,12 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdateTextureEntry(localID, texture); + { + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateTextureEntry(localID, texture); + } + } } /// @@ -546,17 +581,24 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) - group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); - //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); + { + if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + { + group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); + } + } + } public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID) || PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, objectID)) + SceneObjectGroup group = GetGroupByPrim(objectID); + if (group != null) { - SceneObjectGroup group = GetGroupByPrim(objectID); - if (group != null) + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { group.GrabMovement(offset, pos, remoteClient); + } } } @@ -565,11 +607,16 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void PrimName(uint primLocalID, string name) + public void PrimName(IClientAPI remoteClient, uint primLocalID, string name) { SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) - group.SetPartName(name, primLocalID); + { + if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + { + group.SetPartName(name, primLocalID); + } + } } /// @@ -577,21 +624,30 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void PrimDescription(uint primLocalID, string description) + public void PrimDescription(IClientAPI remoteClient, uint primLocalID, string description) { SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) - group.SetPartDescription(description, primLocalID); + { + if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) + { + group.SetPartDescription(description, primLocalID); + } + } } public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (this.m_parentScene.PermissionsMngr.CanEditObject(agentID, group.GetPartsFullID(primLocalID))) + + if (group != null) { - if (group != null) + if (PermissionsMngr.CanEditObject(agentID, group.UUID)) + { group.UpdateExtraParam(primLocalID, type, inUse, data); + } } + } /// @@ -602,10 +658,13 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePrimShape(LLUUID agentID, uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (this.m_parentScene.PermissionsMngr.CanEditObject(agentID, group.GetPartsFullID(primLocalID))) + if (group != null) { - if (group != null) + if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) + { + group.UpdateShape(shapeBlock, primLocalID); + } } } @@ -724,7 +783,7 @@ namespace OpenSim.Region.Environment.Scenes if (originPrim != null) { - if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID) || PermissionsMngr.AnyoneCanCopyPermission(AgentID, originPrim.UUID)) + if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID)) { SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID); copy.AbsolutePosition = copy.AbsolutePosition + offset; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index dbcd332..6c8b3bf 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -448,6 +448,9 @@ namespace OpenSim.Region.Environment.Scenes item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; item.inventoryCurrentPermissions = 2147483647; item.inventoryNextPermissions = 2147483647; + item.inventoryEveryOnePermissions = ((SceneObjectGroup)selectedEnt).RootPart.EveryoneMask; + item.inventoryBasePermissions = ((SceneObjectGroup)selectedEnt).RootPart.BaseMask; + item.inventoryCurrentPermissions = ((SceneObjectGroup)selectedEnt).RootPart.OwnerMask; userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 238e78a..bf02e8d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -851,7 +851,7 @@ namespace OpenSim.Region.Environment.Scenes m_flags |= flag; } - uint currflag = (uint)m_flags; + //uint currflag = (uint)m_flags; //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); //ScheduleFullUpdate(); } @@ -1295,7 +1295,8 @@ namespace OpenSim.Region.Environment.Scenes //EveryoneMask |= (uint)57344; } - ScheduleFullUpdate(); + //ScheduleFullUpdate(); + SendFullUpdateToAllClients(); } //Field 16 = NextownerMask if (field == (byte)16) @@ -1308,7 +1309,7 @@ namespace OpenSim.Region.Environment.Scenes { NextOwnerMask |= mask; } - ScheduleFullUpdate(); + SendFullUpdateToAllClients(); } } -- cgit v1.1