change CanDeedObject. WARNING like on other grids, if you do not set next owner rights on object and ALL ITS CONTENTS, you may loose all rights on it

httptests
UbitUmarov 2017-01-19 17:45:54 +00:00
parent b9651652e1
commit d8108ab740
3 changed files with 41 additions and 24 deletions

View File

@ -71,12 +71,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
#region Constants #region Constants
// These are here for testing. They will be taken out // These are here for testing. They will be taken out
//private uint PERM_ALL = (uint)2147483647;
private uint PERM_COPY = (uint)32768;
//private uint PERM_MODIFY = (uint)16384;
private uint PERM_MOVE = (uint)524288;
private uint PERM_TRANS = (uint)8192;
// private uint PERM_LOCKED = (uint)540672;
private uint PERM_LOCKED = (uint)524288; // same as move private uint PERM_LOCKED = (uint)524288; // same as move
/// <value> /// <value>
@ -867,6 +861,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return PermissionClass.Everyone; return PermissionClass.Everyone;
} }
// get effective object permissions using user UUID. User rights will be fixed
protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked) protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked)
{ {
if (group == null) if (group == null)
@ -918,6 +913,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return group.EffectiveEveryOnePerms & lockmask; return group.EffectiveEveryOnePerms & lockmask;
} }
// get effective object permissions using present presence. So some may depend on requested rights (ie God)
protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked) protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked)
{ {
if (sp == null || sp.IsDeleted || group == null || group.IsDeleted) if (sp == null || sp.IsDeleted || group == null || group.IsDeleted)
@ -1178,15 +1174,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false);
} }
private bool CanDeedObject(UUID user, UUID group, Scene scene) private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
ScenePresence sp = scene.GetScenePresence(user); if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted || targetGroupID == UUID.Zero)
IClientAPI client = sp.ControllingClient; return false;
if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) // object has group already?
if(sog.GroupID != targetGroupID)
return false;
// is effectivelly shared?
if(sog.EffectiveGroupPerms == 0)
return false;
if(sp.IsGod)
return true;
// owned by requester?
if(sog.OwnerID != sp.UUID)
return false;
// owner can transfer?
if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
return false;
// group member ?
ulong powers = 0;
if(!GroupMemberPowers(targetGroupID, sp, ref powers))
return false;
// has group rights?
if ((powers & (ulong)GroupPowers.DeedObject) == 0)
return false; return false;
return true; return true;

View File

@ -2717,9 +2717,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (ownerID != UUID.Zero) if (ownerID != UUID.Zero)
return; return;
if (!Permissions.CanDeedObject(remoteClient.AgentId, groupID))
return;
} }
List<SceneObjectGroup> groups = new List<SceneObjectGroup>(); List<SceneObjectGroup> groups = new List<SceneObjectGroup>();
@ -2750,15 +2747,9 @@ namespace OpenSim.Region.Framework.Scenes
child.TriggerScriptChangedEvent(Changed.OWNER); child.TriggerScriptChangedEvent(Changed.OWNER);
} }
} }
else // The object was deeded to the group else // The object deeded to the group
{ {
if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) if (!Permissions.CanDeedObject(remoteClient, sog, groupID))
continue;
if (!Permissions.CanTransferObject(sog.UUID, groupID))
continue;
if (sog.GroupID != groupID)
continue; continue;
sog.SetOwnerId(groupID); sog.SetOwnerId(groupID);

View File

@ -78,7 +78,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene);
public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene);
public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene); public delegate bool DeedObjectHandler(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID);
public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene);
public delegate bool LinkObjectHandler(UUID user, UUID objectID); public delegate bool LinkObjectHandler(UUID user, UUID objectID);
public delegate bool DelinkObjectHandler(UUID user, UUID objectID); public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
@ -934,15 +934,20 @@ namespace OpenSim.Region.Framework.Scenes
return true; return true;
} }
public bool CanDeedObject(UUID user, UUID group) public bool CanDeedObject(IClientAPI client, SceneObjectGroup sog, UUID targetGroupID)
{ {
DeedObjectHandler handler = OnDeedObject; DeedObjectHandler handler = OnDeedObject;
if (handler != null) if (handler != null)
{ {
if(sog == null || client == null || client.SceneAgent == null || targetGroupID == UUID.Zero)
return false;
ScenePresence sp = client.SceneAgent as ScenePresence;
Delegate[] list = handler.GetInvocationList(); Delegate[] list = handler.GetInvocationList();
foreach (DeedObjectHandler h in list) foreach (DeedObjectHandler h in list)
{ {
if (h(user, group, m_scene) == false) if (h(sp, sog, targetGroupID) == false)
return false; return false;
} }
} }