From e0ab0b3b6b8ae45ff74c274d5af89ccc9bdb5566 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 11 Jan 2017 01:02:57 +0000 Subject: [PATCH] change GenerateClientFlags(...) to work with a scenepresence; make use of the new IsGod to check its God rights; remove the non standard estate manager right to move other ppl prims i added on last commits; coment out a test method i added sometime ago --- OpenSim/Framework/IClientAPI.cs | 2 +- .../ClientStack/Linden/UDP/LLClientView.cs | 23 ++++++---- .../World/Permissions/PermissionsModule.cs | 43 ++++++++++++++++--- .../Framework/Scenes/Scene.Permissions.cs | 6 +-- 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1267993d1f..eedba9d2fa 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1112,7 +1112,7 @@ namespace OpenSim.Framework /// void SendKillObject(List localID); - void SendPartFullUpdate(ISceneEntity ent, uint? parentID); +// void SendPartFullUpdate(ISceneEntity ent, uint? parentID); void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index df3466815b..8ba1ba399d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -4126,14 +4126,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Vector3 mycamera = Vector3.Zero; Vector3 mypos = Vector3.Zero; ScenePresence mysp = (ScenePresence)SceneAgent; - if(mysp != null && !mysp.IsDeleted) + + // we should have a presence + if(mysp == null) + return; + + if(doCulling) { cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; // mycamera = mysp.CameraPosition; mypos = mysp.AbsolutePosition; } - else - doCulling = false; while (maxUpdatesBytes > 0) { @@ -4330,7 +4333,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (update.Entity is ScenePresence) ablock = CreateAvatarUpdateBlock((ScenePresence)update.Entity); else - ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId); + ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, mysp); objectUpdateBlocks.Add(ablock); objectUpdates.Value.Add(update); maxUpdatesBytes -= ablock.Length; @@ -4462,6 +4465,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // hack.. dont use +/* public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) { if (ent is SceneObjectPart) @@ -4472,7 +4476,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP packet.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, this.m_agentId); + ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, mysp); if (parentID.HasValue) { blk.ParentID = parentID.Value; @@ -4488,7 +4492,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name); // } - +*/ public void ReprioritizeUpdates() { lock (m_entityUpdates.SyncRoot) @@ -5726,7 +5730,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP return update; } - protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) +// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) + protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, ScenePresence sp) { byte[] objectData = new byte[60]; data.RelativePosition.ToBytes(objectData, 0); @@ -5826,12 +5831,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region PrimFlags - PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID); + PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(sp, data.UUID); // Don't send the CreateSelected flag to everyone flags &= ~PrimFlags.CreateSelected; - if (recipientID == data.OwnerID) + if (sp.UUID == data.OwnerID) { if (data.CreateSelected) { diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 1bb5181ebe..495da8bb75 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -623,7 +623,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions PrimFlags.ObjectOwnerModify ); - public uint GenerateClientFlags(UUID user, UUID objID) + public uint GenerateClientFlags(ScenePresence sp, UUID objID) { // ObjectFlags and Permission flags are two different enumerations // ObjectFlags, tells the client what it will allow the user to do. @@ -641,8 +641,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions objflags &= NOT_DEFAULT_FLAGS; - // get a relevant class for current user on task - PermissionClass permissionClass = GetPermissionClass(user, task); + // get a relevant class for current presence on task + PermissionClass permissionClass = GetPermissionClass(sp, task); // handle acording uint returnMask = 0; @@ -668,10 +668,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions returnMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags); if (task.OwnerID != UUID.Zero) returnMask |= (uint)PrimFlags.ObjectAnyOwner; - - // allow estatemanagers to move prims to help solve disputes - if(!task.ParentGroup.IsAttachment && IsEstateManager(user)) - returnMask |= (uint)PrimFlags.ObjectMove; break; } return returnMask; @@ -705,6 +701,39 @@ namespace OpenSim.Region.CoreModules.World.Permissions return objectFlagsMask; } + private PermissionClass GetPermissionClass(ScenePresence sp, SceneObjectPart obj) + { + if (obj == null || sp == null) + return PermissionClass.Everyone; + + if (m_bypassPermissions) + return PermissionClass.Owner; + + + if (sp.IsGod) + return PermissionClass.Owner; + + UUID user = sp.UUID; + + // Object owners should be able to edit their own content + UUID objectOwner = obj.OwnerID; + if (user == objectOwner) + return PermissionClass.Owner; + + if(!obj.ParentGroup.IsAttachment) + { + if (IsFriendWithPerms(user, objectOwner) ) + return PermissionClass.Owner; + + // Group permissions + if (obj.GroupID != UUID.Zero && IsGroupMember(obj.GroupID, user, 0)) + return PermissionClass.Group; + } + + return PermissionClass.Everyone; + } + + // OARs need this method that handles offline users public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj) { if (obj == null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index e97e4947ad..c4cb6c79a0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes { #region Delegates - public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID); + public delegate uint GenerateClientFlagsHandler(ScenePresence sp, UUID objectID); public delegate void SetBypassPermissionsHandler(bool value); public delegate bool BypassPermissionsHandler(); public delegate bool PropagatePermissionsHandler(); @@ -167,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes #region Object Permission Checks - public uint GenerateClientFlags(UUID userID, UUID objectID) + public uint GenerateClientFlags(ScenePresence sp, UUID objectID) { // libomv will moan about PrimFlags.ObjectYouOfficer being // obsolete... @@ -195,7 +195,7 @@ namespace OpenSim.Region.Framework.Scenes Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); foreach (GenerateClientFlagsHandler check in list) { - perms &= check(userID, objectID); + perms &= check(sp, objectID); } } return perms;