add bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject land) permissions check

httptests
UbitUmarov 2017-04-03 16:10:05 +01:00
parent 44993550a8
commit eb11505d19
3 changed files with 91 additions and 0 deletions

View File

@ -286,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
scenePermissions.OnRezObject += CanRezObject;
scenePermissions.OnObjectEntry += CanObjectEntry;
scenePermissions.OnObjectEnterWithScripts += OnObjectEnterWithScripts;
scenePermissions.OnDuplicateObject += CanDuplicateObject;
scenePermissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs;
@ -381,6 +382,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
scenePermissions.OnRezObject -= CanRezObject;
scenePermissions.OnObjectEntry -= CanObjectEntry;
scenePermissions.OnObjectEnterWithScripts -= OnObjectEnterWithScripts;
scenePermissions.OnReturnObjects -= CanReturnObjects;
scenePermissions.OnDuplicateObject -= CanDuplicateObject;
@ -1627,6 +1630,55 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return false;
}
private bool OnObjectEnterWithScripts(SceneObjectGroup sog, ILandObject parcel)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if(sog == null || sog.IsDeleted)
return false;
if (m_bypassPermissions)
return m_bypassPermissionsValue;
if (parcel == null)
return true;
int checkflags = ((int)ParcelFlags.AllowAPrimitiveEntry);
bool scripts = (sog.ScriptCount() > 0);
if(scripts)
checkflags |= ((int)ParcelFlags.AllowOtherScripts);
if ((parcel.LandData.Flags & checkflags) == checkflags)
return true;
UUID userID = sog.OwnerID;
LandData landdata = parcel.LandData;
if (landdata.OwnerID == userID)
return true;
if (IsAdministrator(userID))
return true;
UUID landGroupID = landdata.GroupID;
if (landGroupID != UUID.Zero)
{
checkflags = (int)ParcelFlags.AllowGroupObjectEntry;
if(scripts)
checkflags |= ((int)ParcelFlags.AllowGroupScripts);
if ((parcel.LandData.Flags & checkflags) == checkflags)
return IsGroupMember(landGroupID, userID, 0);
if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
return true;
}
//Otherwise, false!
return false;
}
private bool CanReturnObjects(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);

View File

@ -56,6 +56,7 @@ namespace OpenSim.Region.Framework.Scenes
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);
public delegate bool ObjectEnterWithScriptsHandler(SceneObjectGroup sog, ILandObject land);
public delegate bool ReturnObjectsHandler(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects);
public delegate bool InstantMessageHandler(UUID user, UUID target);
public delegate bool InventoryTransferHandler(UUID user, UUID target);
@ -135,6 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
public event EditObjectInventoryHandler OnEditObjectInventory;
public event MoveObjectHandler OnMoveObject;
public event ObjectEntryHandler OnObjectEntry;
public event ObjectEnterWithScriptsHandler OnObjectEnterWithScripts;
public event ReturnObjectsHandler OnReturnObjects;
public event InstantMessageHandler OnInstantMessage;
public event InventoryTransferHandler OnInventoryTransfer;
@ -565,6 +567,21 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
public bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject land)
{
ObjectEnterWithScriptsHandler handler = OnObjectEnterWithScripts;
if (handler != null)
{
Delegate[] list = handler.GetInvocationList();
foreach (ObjectEnterWithScriptsHandler h in list)
{
if (h(sog, land) == false)
return false;
}
}
return true;
}
#endregion
#region RETURN OBJECT

View File

@ -83,6 +83,7 @@ namespace OpenSim.Region.OptionalModules
m_scene = scene;
scene.Permissions.OnRezObject += CanRezObject;
scene.Permissions.OnObjectEntry += CanObjectEnter;
scene.Permissions.OnObjectEnterWithScripts += CanObjectEnterWithScripts;
scene.Permissions.OnDuplicateObject += CanDuplicateObject;
m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
@ -95,6 +96,7 @@ namespace OpenSim.Region.OptionalModules
m_scene.Permissions.OnRezObject -= CanRezObject;
m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
scene.Permissions.OnObjectEnterWithScripts -= CanObjectEnterWithScripts;
m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
}
@ -173,6 +175,26 @@ namespace OpenSim.Region.OptionalModules
return true;
}
private bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject newParcel)
{
if (sog == null)
return false;
if (newParcel == null)
return true;
int objectCount = sog.PrimCount;
// TODO: Add Special Case here for temporary prims
string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
if (response != null)
return false;
return true;
}
private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
{
string response = null;