object Take and TakeCopy are for in scene SOPs and SPs and permitions module is NOT a shared module

httptests
UbitUmarov 2017-01-19 11:34:40 +00:00
parent b9ecc962ac
commit fe9a785ecc
5 changed files with 36 additions and 26 deletions

View File

@ -1322,7 +1322,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (part == null)
return;
if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
SceneObjectGroup group = part.ParentGroup;
if (!m_scene.Permissions.CanTakeObject(group, sp))
{
remoteClient.SendAgentAlertMessage(
"You don't have sufficient permissions to attach this object", false);
@ -1334,7 +1336,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
AttachmentPt &= 0x7f;
// Calls attach with a Zero position
SceneObjectGroup group = part.ParentGroup;
if (AttachObject(sp, group , AttachmentPt, false, true, append))
{
if (DebugLevel > 0)

View File

@ -541,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
#region Permissions
private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene)
private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
{
if (m_bypassPermissions) return true;
if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer))
{
SceneObjectGroup sog = null;
if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer)
return true;
if(sp == null || sog == null)
return false;
if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID))
{
if (sog.OwnerID == sp.UUID)
return true;
return false;
}

View File

@ -1671,39 +1671,45 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
}
private bool CanTakeObject(UUID objectID, UUID userID, Scene scene)
private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
if (sog == null)
if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
return false;
// take is not a attachment op
if(sog.IsAttachment)
return false;
// ignore locked, viewers shell ask for confirmation
uint perms = GetObjectPermissions(userID, sog, false);
uint perms = GetObjectPermissions(sp, sog, false);
if((perms & (uint)PermissionMask.Modify) == 0)
return false;
if (sog.OwnerID != userID && ((perms & (uint)PermissionMask.Transfer) == 0))
if (sog.OwnerID != sp.UUID && ((perms & (uint)PermissionMask.Transfer) == 0))
return false;
return true;
}
private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene)
private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
if (sog == null)
if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
return false;
uint perms = GetObjectPermissions(userID, sog, true);
// refuse on attachments
if(sog.IsAttachment && !sp.IsGod)
return false;
uint perms = GetObjectPermissions(sp, sog, true);
if((perms & (uint)PermissionMask.Copy) == 0)
return false;
if(sog.OwnerID != userID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0)
if(sog.OwnerID != sp.UUID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0)
return false;
return true;
}

View File

@ -2126,6 +2126,8 @@ namespace OpenSim.Region.Framework.Scenes
List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
ScenePresence sp = remoteClient.SceneAgent as ScenePresence;
// Start with true for both, then remove the flags if objects
// that we can't derez are part of the selection
bool permissionToTake = true;
@ -2180,14 +2182,14 @@ namespace OpenSim.Region.Framework.Scenes
{
if (action == DeRezAction.TakeCopy)
{
if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
if (!Permissions.CanTakeCopyObject(grp, sp))
permissionToTakeCopy = false;
}
else
{
permissionToTakeCopy = false;
}
if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
if (!Permissions.CanTakeObject(grp, sp))
permissionToTake = false;
if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))

View File

@ -44,9 +44,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene);
public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene);
public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene);
public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene);
public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene);
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 EditObjectHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
@ -300,7 +300,7 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
#region TAKE OBJECT
public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID)
public bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
{
bool result = true;
@ -310,7 +310,7 @@ namespace OpenSim.Region.Framework.Scenes
Delegate[] list = handler.GetInvocationList();
foreach (TakeObjectHandler h in list)
{
if (h(objectID, AvatarTakingUUID, m_scene) == false)
if (h(sog, sp) == false)
{
result = false;
break;
@ -357,7 +357,7 @@ namespace OpenSim.Region.Framework.Scenes
#region TAKE COPY OBJECT
public bool CanTakeCopyObject(UUID objectID, UUID userID)
public bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
{
bool result = true;
@ -367,7 +367,7 @@ namespace OpenSim.Region.Framework.Scenes
Delegate[] list = handler.GetInvocationList();
foreach (TakeCopyObjectHandler h in list)
{
if (h(objectID, userID, m_scene) == false)
if (h(sog, sp) == false)
{
result = false;
break;