From d62aed7f468d50a3b1f9ee678be9ba66d77a9218 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 3 May 2017 21:12:16 +0100 Subject: [PATCH] fix right to change permissions of group owned objects --- .../World/Permissions/PermissionsModule.cs | 33 ++++++++++++++++++- .../Framework/Scenes/Scene.Permissions.cs | 20 +++++++++++ .../Framework/Scenes/SceneObjectPart.cs | 7 ++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 4c4a8a53d5..45c1c561e7 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -293,6 +293,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions scenePermissions.OnDeleteObject += CanDeleteObject; scenePermissions.OnEditObjectByIDs += CanEditObjectByIDs; scenePermissions.OnEditObject += CanEditObject; + scenePermissions.OnEditObjectPerms += CanEditObjectPerms; scenePermissions.OnInventoryTransfer += CanInventoryTransfer; scenePermissions.OnMoveObject += CanMoveObject; scenePermissions.OnTakeObject += CanTakeObject; @@ -391,6 +392,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions scenePermissions.OnDeleteObject -= CanDeleteObject; scenePermissions.OnEditObjectByIDs -= CanEditObjectByIDs; scenePermissions.OnEditObject -= CanEditObject; + scenePermissions.OnEditObjectPerms -= CanEditObjectPerms; scenePermissions.OnInventoryTransfer -= CanInventoryTransfer; scenePermissions.OnMoveObject -= CanMoveObject; scenePermissions.OnTakeObject -= CanTakeObject; @@ -1387,6 +1389,35 @@ namespace OpenSim.Region.CoreModules.World.Permissions return true; } + private bool CanEditObjectPerms(SceneObjectGroup sog, UUID userID) + { + DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); + if (m_bypassPermissions) return m_bypassPermissionsValue; + + if (sog == null) + return false; + + if(sog.OwnerID == userID || IsAdministrator(userID)) + return true; + + UUID sogGroupID = sog.GroupID; + if(sogGroupID == UUID.Zero || sogGroupID != sog.OwnerID) + return false; + + uint perms = sog.EffectiveOwnerPerms; + if((perms & (uint)PermissionMask.Modify) == 0) + return false; + + ulong powers = 0; + if(GroupMemberPowers(sogGroupID, userID, ref powers)) + { + if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) + return true; + } + + return false; + } + private bool CanEditObjectInventory(UUID objectID, UUID userID) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); @@ -2306,7 +2337,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions ulong powers = 0; if(GroupMemberPowers(sogGroupID, userID, ref powers)) { - if(powers == (ulong)GroupPowers.ObjectManipulate) + if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) return true; if((ti.EveryonePermissions & (uint)PermissionMask.Copy) != 0) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index c55a7a6412..a75671e6fd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID); public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp); + public delegate bool EditObjectPermsHandler(SceneObjectGroup sog, UUID editorID); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID); public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool ObjectEntryHandler(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint); @@ -133,6 +134,7 @@ namespace OpenSim.Region.Framework.Scenes public event DuplicateObjectHandler OnDuplicateObject; public event EditObjectByIDsHandler OnEditObjectByIDs; public event EditObjectHandler OnEditObject; + public event EditObjectPermsHandler OnEditObjectPerms; public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; @@ -511,6 +513,24 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public bool CanEditObjectPermissions(SceneObjectGroup sog, UUID editorID) + { + EditObjectPermsHandler handler = OnEditObjectPerms; + if (handler != null) + { + if(sog == null) + return false; + Delegate[] list = handler.GetInvocationList(); + foreach (EditObjectPermsHandler h in list) + { + if (h(sog, editorID) == false) + return false; + } + } + return true; + } + + public bool CanEditObjectInventory(UUID objectID, UUID editorID) { EditObjectInventoryHandler handler = OnEditObjectInventory; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f948336feb..d980fe517e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4460,8 +4460,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter if (god) baseMask = 0x7ffffff0; - // Are we the owner? - if ((AgentID == OwnerID) || god) + bool canChange = (AgentID == OwnerID) || god; + if(!canChange) + canChange = ParentGroup.Scene.Permissions.CanEditObjectPermissions(ParentGroup, AgentID); + + if (canChange) { switch (field) {