add CanEdit check for SOGs, iclients and SPs that need to be in scene and use it

httptests
UbitUmarov 2017-01-19 13:10:04 +00:00
parent 7651d60d72
commit 984345a202
3 changed files with 61 additions and 22 deletions

View File

@ -283,6 +283,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
m_scene.Permissions.OnIsEstateManager += IsEstateManager; m_scene.Permissions.OnIsEstateManager += IsEstateManager;
m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
m_scene.Permissions.OnDeleteObject += CanDeleteObject; m_scene.Permissions.OnDeleteObject += CanDeleteObject;
m_scene.Permissions.OnEditObjectByIDs += CanEditObjectByIDs;
m_scene.Permissions.OnEditObject += CanEditObject; m_scene.Permissions.OnEditObject += CanEditObject;
m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties;
m_scene.Permissions.OnInstantMessage += CanInstantMessage; m_scene.Permissions.OnInstantMessage += CanInstantMessage;
@ -1235,7 +1236,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return true; return true;
} }
private bool CanEditObject(UUID objectID, UUID userID, Scene scene) private bool CanEditObjectByIDs(UUID objectID, UUID userID, Scene scene)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
@ -1250,6 +1251,20 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return true; return true;
} }
private bool CanEditObject(SceneObjectGroup sog, ScenePresence sp)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
return false;
uint perms = GetObjectPermissions(sp, sog, true);
if((perms & (uint)PermissionMask.Modify) == 0)
return false;
return true;
}
private bool CanEditObjectInventory(UUID objectID, UUID userID, Scene scene) private bool CanEditObjectInventory(UUID objectID, UUID userID, Scene scene)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);

View File

@ -48,7 +48,8 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene); public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene);
public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
@ -118,6 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
public event SellGroupObjectHandler OnSellGroupObject; public event SellGroupObjectHandler OnSellGroupObject;
public event TakeCopyObjectHandler OnTakeCopyObject; public event TakeCopyObjectHandler OnTakeCopyObject;
public event DuplicateObjectHandler OnDuplicateObject; public event DuplicateObjectHandler OnDuplicateObject;
public event EditObjectByIDsHandler OnEditObjectByIDs;
public event EditObjectHandler OnEditObject; public event EditObjectHandler OnEditObject;
public event EditObjectInventoryHandler OnEditObjectInventory; public event EditObjectInventoryHandler OnEditObjectInventory;
public event MoveObjectHandler OnMoveObject; public event MoveObjectHandler OnMoveObject;
@ -307,6 +309,9 @@ namespace OpenSim.Region.Framework.Scenes
TakeObjectHandler handler = OnTakeObject; TakeObjectHandler handler = OnTakeObject;
if (handler != null) if (handler != null)
{ {
if(sog == null || sp == null)
return false;
Delegate[] list = handler.GetInvocationList(); Delegate[] list = handler.GetInvocationList();
foreach (TakeObjectHandler h in list) foreach (TakeObjectHandler h in list)
{ {
@ -364,6 +369,8 @@ namespace OpenSim.Region.Framework.Scenes
TakeCopyObjectHandler handler = OnTakeCopyObject; TakeCopyObjectHandler handler = OnTakeCopyObject;
if (handler != null) if (handler != null)
{ {
if(sog == null || sp == null)
return false;
Delegate[] list = handler.GetInvocationList(); Delegate[] list = handler.GetInvocationList();
foreach (TakeCopyObjectHandler h in list) foreach (TakeCopyObjectHandler h in list)
{ {
@ -419,11 +426,11 @@ namespace OpenSim.Region.Framework.Scenes
#region EDIT OBJECT #region EDIT OBJECT
public bool CanEditObject(UUID objectID, UUID editorID) public bool CanEditObject(UUID objectID, UUID editorID)
{ {
EditObjectHandler handler = OnEditObject; EditObjectByIDsHandler handler = OnEditObjectByIDs;
if (handler != null) if (handler != null)
{ {
Delegate[] list = handler.GetInvocationList(); Delegate[] list = handler.GetInvocationList();
foreach (EditObjectHandler h in list) foreach (EditObjectByIDsHandler h in list)
{ {
if (h(objectID, editorID, m_scene) == false) if (h(objectID, editorID, m_scene) == false)
return false; return false;
@ -432,6 +439,26 @@ namespace OpenSim.Region.Framework.Scenes
return true; return true;
} }
public bool CanEditObject(SceneObjectGroup sog, IClientAPI client)
{
EditObjectHandler handler = OnEditObject;
if (handler != null)
{
if(sog == null || client == null || client.SceneAgent == null)
return false;
ScenePresence sp = client.SceneAgent as ScenePresence;
Delegate[] list = handler.GetInvocationList();
foreach (EditObjectHandler h in list)
{
if (h(sog, sp) == false)
return false;
}
}
return true;
}
public bool CanEditObjectInventory(UUID objectID, UUID editorID) public bool CanEditObjectInventory(UUID objectID, UUID editorID)
{ {
EditObjectInventoryHandler handler = OnEditObjectInventory; EditObjectInventoryHandler handler = OnEditObjectInventory;
@ -452,17 +479,14 @@ namespace OpenSim.Region.Framework.Scenes
#region MOVE OBJECT #region MOVE OBJECT
public bool CanMoveObject(SceneObjectGroup sog, IClientAPI client) public bool CanMoveObject(SceneObjectGroup sog, IClientAPI client)
{ {
if(sog == null || client == null)
return false;
if(client.SceneAgent == null)
return false;
ScenePresence sp = client.SceneAgent as ScenePresence;
MoveObjectHandler handler = OnMoveObject; MoveObjectHandler handler = OnMoveObject;
if (handler != null) if (handler != null)
{ {
if(sog == null || client == null || client.SceneAgent == null)
return false;
ScenePresence sp = client.SceneAgent as ScenePresence;
Delegate[] list = handler.GetInvocationList(); Delegate[] list = handler.GetInvocationList();
foreach (MoveObjectHandler h in list) foreach (MoveObjectHandler h in list)
{ {

View File

@ -1358,7 +1358,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup grp = part.ParentGroup; SceneObjectGroup grp = part.ParentGroup;
if (grp != null) if (grp != null)
{ {
if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(grp, remoteClient))
{ {
// These two are exceptions SL makes in the interpretation // These two are exceptions SL makes in the interpretation
// of the change flags. Must check them here because otherwise // of the change flags. Must check them here because otherwise
@ -1406,7 +1406,7 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null) if (part != null)
{ {
if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(part.ParentGroup, remoteClient))
{ {
bool physbuild = false; bool physbuild = false;
if (part.ParentGroup.RootPart.PhysActor != null) if (part.ParentGroup.RootPart.PhysActor != null)
@ -1428,7 +1428,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
bool physbuild = false; bool physbuild = false;
if (group.RootPart.PhysActor != null) if (group.RootPart.PhysActor != null)
@ -1603,7 +1603,7 @@ namespace OpenSim.Region.Framework.Scenes
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID,remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
group.UpdateTextureEntry(localID, texture); group.UpdateTextureEntry(localID, texture);
} }
@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
// VolumeDetect can't be set via UI and will always be off when a change is made there // VolumeDetect can't be set via UI and will always be off when a change is made there
// now only change volume dtc if phantom off // now only change volume dtc if phantom off
@ -1674,7 +1674,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(primLocalID); SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
group.SetPartName(Util.CleanString(name), primLocalID); group.SetPartName(Util.CleanString(name), primLocalID);
group.HasGroupChanged = true; group.HasGroupChanged = true;
@ -1692,7 +1692,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(primLocalID); SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
group.SetPartDescription(Util.CleanString(description), primLocalID); group.SetPartDescription(Util.CleanString(description), primLocalID);
group.HasGroupChanged = true; group.HasGroupChanged = true;
@ -1714,7 +1714,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(primLocalID); SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
if (part != null) if (part != null)
@ -1731,7 +1731,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(primLocalID); SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null) if (group != null)
{ {
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
if (part != null) if (part != null)
@ -2033,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes
// libomv will complain about PrimFlags.JointWheel being // libomv will complain about PrimFlags.JointWheel being
// deprecated, so we // deprecated, so we
#pragma warning disable 0612 #pragma warning disable 0612
if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(sog, remoteClient))
{ {
sog.RootPart.AddFlag(PrimFlags.JointWheel); sog.RootPart.AddFlag(PrimFlags.JointWheel);
sog.HasGroupChanged = true; sog.HasGroupChanged = true;