Permissions module: GenerateClientFlags() no need to keep looking for the same part several times; fix locked mask in GetObjectPermissions()

httptests
UbitUmarov 2017-01-17 23:22:02 +00:00
parent 06bca0388f
commit 6d784f6306
4 changed files with 70 additions and 77 deletions

View File

@ -5731,28 +5731,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) // protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, ScenePresence sp) protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart part, ScenePresence sp)
{ {
byte[] objectData = new byte[60]; byte[] objectData = new byte[60];
data.RelativePosition.ToBytes(objectData, 0); part.RelativePosition.ToBytes(objectData, 0);
data.Velocity.ToBytes(objectData, 12); part.Velocity.ToBytes(objectData, 12);
data.Acceleration.ToBytes(objectData, 24); part.Acceleration.ToBytes(objectData, 24);
Quaternion rotation = data.RotationOffset; Quaternion rotation = part.RotationOffset;
rotation.Normalize(); rotation.Normalize();
rotation.ToBytes(objectData, 36); rotation.ToBytes(objectData, 36);
data.AngularVelocity.ToBytes(objectData, 48); part.AngularVelocity.ToBytes(objectData, 48);
ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
update.ClickAction = (byte)data.ClickAction; update.ClickAction = (byte)part.ClickAction;
update.CRC = 0; update.CRC = 0;
update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes; update.ExtraParams = part.Shape.ExtraParams ?? Utils.EmptyBytes;
update.FullID = data.UUID; update.FullID = part.UUID;
update.ID = data.LocalId; update.ID = part.LocalId;
//update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
//update.JointPivot = Vector3.Zero; //update.JointPivot = Vector3.Zero;
//update.JointType = 0; //update.JointType = 0;
update.Material = data.Material; update.Material = part.Material;
update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
/* /*
if (data.ParentGroup.IsAttachment) if (data.ParentGroup.IsAttachment)
@ -5781,68 +5781,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
*/ */
if (data.ParentGroup.IsAttachment) if (part.ParentGroup.IsAttachment)
{ {
if (data.IsRoot) if (part.IsRoot)
{ {
update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID);
} }
else else
update.NameValue = Utils.EmptyBytes; update.NameValue = Utils.EmptyBytes;
int st = (int)data.ParentGroup.AttachmentPoint; int st = (int)part.ParentGroup.AttachmentPoint;
update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
} }
else else
{ {
update.NameValue = Utils.EmptyBytes; update.NameValue = Utils.EmptyBytes;
update.State = data.Shape.State; // not sure about this update.State = part.Shape.State; // not sure about this
} }
update.ObjectData = objectData; update.ObjectData = objectData;
update.ParentID = data.ParentID; update.ParentID = part.ParentID;
update.PathBegin = data.Shape.PathBegin; update.PathBegin = part.Shape.PathBegin;
update.PathCurve = data.Shape.PathCurve; update.PathCurve = part.Shape.PathCurve;
update.PathEnd = data.Shape.PathEnd; update.PathEnd = part.Shape.PathEnd;
update.PathRadiusOffset = data.Shape.PathRadiusOffset; update.PathRadiusOffset = part.Shape.PathRadiusOffset;
update.PathRevolutions = data.Shape.PathRevolutions; update.PathRevolutions = part.Shape.PathRevolutions;
update.PathScaleX = data.Shape.PathScaleX; update.PathScaleX = part.Shape.PathScaleX;
update.PathScaleY = data.Shape.PathScaleY; update.PathScaleY = part.Shape.PathScaleY;
update.PathShearX = data.Shape.PathShearX; update.PathShearX = part.Shape.PathShearX;
update.PathShearY = data.Shape.PathShearY; update.PathShearY = part.Shape.PathShearY;
update.PathSkew = data.Shape.PathSkew; update.PathSkew = part.Shape.PathSkew;
update.PathTaperX = data.Shape.PathTaperX; update.PathTaperX = part.Shape.PathTaperX;
update.PathTaperY = data.Shape.PathTaperY; update.PathTaperY = part.Shape.PathTaperY;
update.PathTwist = data.Shape.PathTwist; update.PathTwist = part.Shape.PathTwist;
update.PathTwistBegin = data.Shape.PathTwistBegin; update.PathTwistBegin = part.Shape.PathTwistBegin;
update.PCode = data.Shape.PCode; update.PCode = part.Shape.PCode;
update.ProfileBegin = data.Shape.ProfileBegin; update.ProfileBegin = part.Shape.ProfileBegin;
update.ProfileCurve = data.Shape.ProfileCurve; update.ProfileCurve = part.Shape.ProfileCurve;
update.ProfileEnd = data.Shape.ProfileEnd; update.ProfileEnd = part.Shape.ProfileEnd;
update.ProfileHollow = data.Shape.ProfileHollow; update.ProfileHollow = part.Shape.ProfileHollow;
update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes; update.PSBlock = part.ParticleSystem ?? Utils.EmptyBytes;
update.TextColor = data.GetTextColor().GetBytes(false); update.TextColor = part.GetTextColor().GetBytes(false);
update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes; update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes; update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
update.Scale = data.Shape.Scale; update.Scale = part.Shape.Scale;
update.Text = Util.StringToBytes256(data.Text); update.Text = Util.StringToBytes256(part.Text);
update.MediaURL = Util.StringToBytes256(data.MediaUrl); update.MediaURL = Util.StringToBytes256(part.MediaUrl);
#region PrimFlags #region PrimFlags
PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(sp, data.UUID); PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp);
// Don't send the CreateSelected flag to everyone // Don't send the CreateSelected flag to everyone
flags &= ~PrimFlags.CreateSelected; flags &= ~PrimFlags.CreateSelected;
if (sp.UUID == data.OwnerID) if (sp.UUID == part.OwnerID)
{ {
if (data.CreateSelected) if (part.CreateSelected)
{ {
// Only send this flag once, then unset it // Only send this flag once, then unset it
flags |= PrimFlags.CreateSelected; flags |= PrimFlags.CreateSelected;
data.CreateSelected = false; part.CreateSelected = false;
} }
} }
@ -5854,21 +5854,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion PrimFlags #endregion PrimFlags
if (data.Sound != UUID.Zero) if (part.Sound != UUID.Zero)
{ {
update.Sound = data.Sound; update.Sound = part.Sound;
update.OwnerID = data.OwnerID; update.OwnerID = part.OwnerID;
update.Gain = (float)data.SoundGain; update.Gain = (float)part.SoundGain;
update.Radius = (float)data.SoundRadius; update.Radius = (float)part.SoundRadius;
update.Flags = data.SoundFlags; update.Flags = part.SoundFlags;
} }
switch ((PCode)data.Shape.PCode) switch ((PCode)part.Shape.PCode)
{ {
case PCode.Grass: case PCode.Grass:
case PCode.Tree: case PCode.Tree:
case PCode.NewTree: case PCode.NewTree:
update.Data = new byte[] { data.Shape.State }; update.Data = new byte[] { part.Shape.State };
break; break;
default: default:
update.Data = Utils.EmptyBytes; update.Data = Utils.EmptyBytes;

View File

@ -693,17 +693,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions
PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
); );
public uint GenerateClientFlags(ScenePresence sp, uint curEffectivePerms, UUID objID) public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
{ {
if(sp == null || curEffectivePerms == 0) if(sp == null || task == null || curEffectivePerms == 0)
return (uint)0; return 0;
SceneObjectPart task = m_scene.GetSceneObjectPart(objID);
// this shouldn't ever happen.. return no permissions/objectflags.
if (task == null)
return (uint)0;
// Remove any of the objectFlags that are temporary. These will get added back if appropriate // Remove any of the objectFlags that are temporary. These will get added back if appropriate
uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ; uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
@ -719,6 +713,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
} }
SceneObjectGroup grp = task.ParentGroup; SceneObjectGroup grp = task.ParentGroup;
if(grp == null)
return 0;
bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0; bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
//bypass option == owner rights //bypass option == owner rights
@ -887,7 +884,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (part == null) if (part == null)
return 0; return 0;
// Admin should be able to edit anything in the sim (including admin objects)
if (IsAdministrator(currentUser)) if (IsAdministrator(currentUser))
return (uint)PermissionMask.AllEffective; return (uint)PermissionMask.AllEffective;
@ -901,15 +897,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
uint lockmask = (uint)PermissionMask.AllEffective; uint lockmask = (uint)PermissionMask.AllEffective;
if(locked) if(locked)
lockmask = (uint)PermissionMask.Move; lockmask &= ~(uint)PermissionMask.Modify;
if (currentUser == objectOwner) if (currentUser == objectOwner)
return group.EffectiveOwnerPerms & lockmask; return group.EffectiveOwnerPerms & lockmask;
if (group.IsAttachment) if (group.IsAttachment)
return 0; return 0;
// Friends with benefits should be able to edit the objects too
if (IsFriendWithPerms(currentUser, objectOwner)) if (IsFriendWithPerms(currentUser, objectOwner))
return group.EffectiveOwnerPerms & lockmask; return group.EffectiveOwnerPerms & lockmask;

View File

@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
part.SendFullUpdate(remoteClient); part.SendFullUpdate(remoteClient);
// A prim is only tainted if it's allowed to be edited by the person clicking it. // A prim is only tainted if it's allowed to be edited by the person clicking it.
if (Permissions.CanChangeSelectedState(sog.UUID, (ScenePresence)remoteClient.SceneAgent)) if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
{ {
part.IsSelected = true; part.IsSelected = true;
EventManager.TriggerParcelPrimCountTainted(); EventManager.TriggerParcelPrimCountTainted();
@ -249,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes
// handled by group, but by prim. Legacy cruft. // handled by group, but by prim. Legacy cruft.
// TODO: Make selection flagging per prim! // TODO: Make selection flagging per prim!
// //
if (Permissions.CanChangeSelectedState(part.ParentGroup.UUID, (ScenePresence)remoteClient.SceneAgent)) if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
{ {
part.IsSelected = false; part.IsSelected = false;
if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected)

View File

@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
#region Delegates #region Delegates
public delegate uint GenerateClientFlagsHandler(ScenePresence sp, uint curEffectivePerms, UUID objectID); public delegate uint GenerateClientFlagsHandler(SceneObjectPart part, ScenePresence sp, uint curEffectivePerms);
public delegate void SetBypassPermissionsHandler(bool value); public delegate void SetBypassPermissionsHandler(bool value);
public delegate bool BypassPermissionsHandler(); public delegate bool BypassPermissionsHandler();
public delegate bool PropagatePermissionsHandler(); public delegate bool PropagatePermissionsHandler();
@ -167,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Object Permission Checks #region Object Permission Checks
public uint GenerateClientFlags(ScenePresence sp, UUID objectID) public uint GenerateClientFlags( SceneObjectPart part, ScenePresence sp)
{ {
// libomv will moan about PrimFlags.ObjectYouOfficer being // libomv will moan about PrimFlags.ObjectYouOfficer being
// obsolete... // obsolete...
@ -182,8 +182,6 @@ namespace OpenSim.Region.Framework.Scenes
PrimFlags.ObjectOwnerModify; PrimFlags.ObjectOwnerModify;
#pragma warning restore 0612 #pragma warning restore 0612
SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
if (part == null) if (part == null)
return 0; return 0;
@ -195,7 +193,7 @@ namespace OpenSim.Region.Framework.Scenes
Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
foreach (GenerateClientFlagsHandler check in list) foreach (GenerateClientFlagsHandler check in list)
{ {
perms &= check(sp, perms, objectID); perms &= check(part, sp, perms);
} }
} }
return perms; return perms;
@ -411,9 +409,9 @@ namespace OpenSim.Region.Framework.Scenes
PrimFlags.ObjectOwnerModify PrimFlags.ObjectOwnerModify
); );
public bool CanChangeSelectedState(UUID objectID, ScenePresence sp) public bool CanChangeSelectedState(SceneObjectPart part, ScenePresence sp)
{ {
uint perms = GenerateClientFlags(sp , objectID); uint perms = GenerateClientFlags(part, sp);
return (perms & CANSELECTMASK) != 0; return (perms & CANSELECTMASK) != 0;
} }