object CanMove is for in scene SOGs Icleints and SPs and permitions module is NOT a shared module

httptests
UbitUmarov 2017-01-19 12:35:00 +00:00
parent fe9a785ecc
commit 673bd37219
5 changed files with 57 additions and 81 deletions

View File

@ -1420,28 +1420,21 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return GenericEstatePermission(user);
}
private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene)
private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions)
{
SceneObjectPart part = scene.GetSceneObjectPart(objectID);
if(part == null)
if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
return false;
if (part.OwnerID != moverID)
if (m_bypassPermissions)
{
if (part.ParentGroup.IsDeleted || part.ParentGroup.IsAttachment)
if (sog.OwnerID != sp.UUID && sog.IsAttachment)
return false;
}
return m_bypassPermissionsValue;
}
SceneObjectGroup sog = scene.GetGroupByPrim(objectID);
if (sog == null)
return false;
uint perms = GetObjectPermissions(moverID, sog, true);
uint perms = GetObjectPermissions(sp, sog, true);
if((perms & (uint)PermissionMask.Move) == 0)
return false;
return true;

View File

@ -325,7 +325,7 @@ namespace OpenSim.Region.Framework.Scenes
if(group == null || group.IsDeleted)
return;
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
{
group.GrabMovement(objectID, offset, pos, remoteClient);
}
@ -386,7 +386,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
{
group.SpinStart(remoteClient);
}
@ -404,7 +404,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
{
group.SpinMovement(rotation, remoteClient);
}

View File

@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes
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 EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene);
public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
@ -450,15 +450,22 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
#region MOVE OBJECT
public bool CanMoveObject(UUID objectID, UUID moverID)
public bool CanMoveObject(SceneObjectGroup sog, IClientAPI client)
{
if(sog == null || client == null)
return false;
ScenePresence sp = client.SceneAgent as ScenePresence;
if(sp == null)
return false;
MoveObjectHandler handler = OnMoveObject;
if (handler != null)
{
Delegate[] list = handler.GetInvocationList();
foreach (MoveObjectHandler h in list)
{
if (h(objectID, moverID, m_scene) == false)
if (h(sog, sp) == false)
return false;
}
}

View File

@ -1379,7 +1379,7 @@ namespace OpenSim.Region.Framework.Scenes
if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0)
{
// Are we allowed to move it?
if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanMoveObject(grp, remoteClient))
{
// Strip all but move and rotation from request
data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation);
@ -1474,7 +1474,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
{
group.UpdateSingleRotation(rot, localID);
}
@ -1492,7 +1492,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
{
group.UpdateSingleRotation(rot, pos, localID);
}
@ -1510,7 +1510,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
{
group.UpdateGroupRotationR(rot);
}
@ -1529,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
{
group.UpdateGroupRotationPR(pos, rot);
}
@ -1547,7 +1547,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId) || group.IsAttachment)
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient) || group.IsAttachment)
{
group.UpdateSinglePosition(pos, localID);
}
@ -1561,17 +1561,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="pos"></param>
/// <param name="remoteClient"></param>
public void UpdatePrimGroupPosition(uint localId, Vector3 pos, IClientAPI remoteClient)
{
UpdatePrimGroupPosition(localId, pos, remoteClient.AgentId);
}
/// <summary>
/// Update the position of the given group.
/// </summary>
/// <param name="localId"></param>
/// <param name="pos"></param>
/// <param name="updatingAgentId"></param>
public void UpdatePrimGroupPosition(uint localId, Vector3 pos, UUID updatingAgentId)
{
SceneObjectGroup group = GetGroupByPrim(localId);
@ -1589,7 +1578,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, updatingAgentId)
if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)
&& m_parentScene.Permissions.CanObjectEntry(group.UUID, false, pos))
{
group.UpdateGroupPosition(pos);
@ -2025,27 +2014,9 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
{
UUID user = remoteClient.AgentId;
UUID objid = UUID.Zero;
SceneObjectPart obj = null;
EntityBase[] entityList = GetEntities();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
SceneObjectGroup sog = ent as SceneObjectGroup;
foreach (SceneObjectPart part in sog.Parts)
{
if (part.LocalId == localID)
{
objid = part.UUID;
obj = part;
}
}
}
}
SceneObjectGroup sog = GetGroupByPrim(localID);
if(sog == null)
return;
//Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints
//aka ObjectFlags.JointWheel = IncludeInSearch
@ -2062,15 +2033,15 @@ namespace OpenSim.Region.Framework.Scenes
// libomv will complain about PrimFlags.JointWheel being
// deprecated, so we
#pragma warning disable 0612
if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(objid, user))
if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(sog.UUID, remoteClient.AgentId))
{
obj.ParentGroup.RootPart.AddFlag(PrimFlags.JointWheel);
obj.ParentGroup.HasGroupChanged = true;
sog.RootPart.AddFlag(PrimFlags.JointWheel);
sog.HasGroupChanged = true;
}
else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(objid,user))
else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(sog, remoteClient))
{
obj.ParentGroup.RootPart.RemFlag(PrimFlags.JointWheel);
obj.ParentGroup.HasGroupChanged = true;
sog.RootPart.RemFlag(PrimFlags.JointWheel);
sog.HasGroupChanged = true;
}
#pragma warning restore 0612
}

View File

@ -157,14 +157,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Cross
sceneA.SceneGraph.UpdatePrimGroupPosition(
so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId);
so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), sp1SceneA.ControllingClient);
// crossing is async
Thread.Sleep(500);
SceneObjectGroup so1PostCross;
{
ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
@ -179,7 +178,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
Assert.NotNull(so1PostCross);
Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
}
Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
@ -187,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Recross
sceneB.SceneGraph.UpdatePrimGroupPosition(
so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId);
so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), sp1SceneBPostCross.ControllingClient);
// crossing is async
Thread.Sleep(500);
@ -255,13 +254,19 @@ namespace OpenSim.Region.Framework.Scenes.Tests
lmmA.EventManagerOnNoLandDataFromStorage();
lmmB.EventManagerOnNoLandDataFromStorage();
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
UUID so1Id = so1.UUID;
so1.AbsolutePosition = new Vector3(128, 10, 20);
// Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
// because only this will execute permission checks in the source region.
sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);
sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), sp1SceneA.ControllingClient);
// crossing is async
Thread.Sleep(500);