aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2017-01-17 23:22:02 +0000
committerUbitUmarov2017-01-17 23:22:02 +0000
commit6d784f63060940bd82a2be776385abd40901f57c (patch)
treec4d98d5348737d6282408b8d88fc9c66ea082ca0 /OpenSim/Region
parentPermissions module: add GetObjectPermissions() that should replace GenericObj... (diff)
downloadopensim-SC-6d784f63060940bd82a2be776385abd40901f57c.zip
opensim-SC-6d784f63060940bd82a2be776385abd40901f57c.tar.gz
opensim-SC-6d784f63060940bd82a2be776385abd40901f57c.tar.bz2
opensim-SC-6d784f63060940bd82a2be776385abd40901f57c.tar.xz
Permissions module: GenerateClientFlags() no need to keep looking for the same part several times; fix locked mask in GetObjectPermissions()
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs110
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs12
4 files changed, 70 insertions, 77 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 8ba1ba3..7455dea 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5731,28 +5731,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5731 } 5731 }
5732 5732
5733// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) 5733// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
5734 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, ScenePresence sp) 5734 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart part, ScenePresence sp)
5735 { 5735 {
5736 byte[] objectData = new byte[60]; 5736 byte[] objectData = new byte[60];
5737 data.RelativePosition.ToBytes(objectData, 0); 5737 part.RelativePosition.ToBytes(objectData, 0);
5738 data.Velocity.ToBytes(objectData, 12); 5738 part.Velocity.ToBytes(objectData, 12);
5739 data.Acceleration.ToBytes(objectData, 24); 5739 part.Acceleration.ToBytes(objectData, 24);
5740 5740
5741 Quaternion rotation = data.RotationOffset; 5741 Quaternion rotation = part.RotationOffset;
5742 rotation.Normalize(); 5742 rotation.Normalize();
5743 rotation.ToBytes(objectData, 36); 5743 rotation.ToBytes(objectData, 36);
5744 data.AngularVelocity.ToBytes(objectData, 48); 5744 part.AngularVelocity.ToBytes(objectData, 48);
5745 5745
5746 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); 5746 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5747 update.ClickAction = (byte)data.ClickAction; 5747 update.ClickAction = (byte)part.ClickAction;
5748 update.CRC = 0; 5748 update.CRC = 0;
5749 update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes; 5749 update.ExtraParams = part.Shape.ExtraParams ?? Utils.EmptyBytes;
5750 update.FullID = data.UUID; 5750 update.FullID = part.UUID;
5751 update.ID = data.LocalId; 5751 update.ID = part.LocalId;
5752 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated 5752 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
5753 //update.JointPivot = Vector3.Zero; 5753 //update.JointPivot = Vector3.Zero;
5754 //update.JointType = 0; 5754 //update.JointType = 0;
5755 update.Material = data.Material; 5755 update.Material = part.Material;
5756 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim 5756 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
5757/* 5757/*
5758 if (data.ParentGroup.IsAttachment) 5758 if (data.ParentGroup.IsAttachment)
@@ -5781,68 +5781,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5781 } 5781 }
5782*/ 5782*/
5783 5783
5784 if (data.ParentGroup.IsAttachment) 5784 if (part.ParentGroup.IsAttachment)
5785 { 5785 {
5786 if (data.IsRoot) 5786 if (part.IsRoot)
5787 { 5787 {
5788 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); 5788 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID);
5789 } 5789 }
5790 else 5790 else
5791 update.NameValue = Utils.EmptyBytes; 5791 update.NameValue = Utils.EmptyBytes;
5792 5792
5793 int st = (int)data.ParentGroup.AttachmentPoint; 5793 int st = (int)part.ParentGroup.AttachmentPoint;
5794 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; 5794 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
5795 } 5795 }
5796 else 5796 else
5797 { 5797 {
5798 update.NameValue = Utils.EmptyBytes; 5798 update.NameValue = Utils.EmptyBytes;
5799 update.State = data.Shape.State; // not sure about this 5799 update.State = part.Shape.State; // not sure about this
5800 } 5800 }
5801 5801
5802 5802
5803 update.ObjectData = objectData; 5803 update.ObjectData = objectData;
5804 update.ParentID = data.ParentID; 5804 update.ParentID = part.ParentID;
5805 update.PathBegin = data.Shape.PathBegin; 5805 update.PathBegin = part.Shape.PathBegin;
5806 update.PathCurve = data.Shape.PathCurve; 5806 update.PathCurve = part.Shape.PathCurve;
5807 update.PathEnd = data.Shape.PathEnd; 5807 update.PathEnd = part.Shape.PathEnd;
5808 update.PathRadiusOffset = data.Shape.PathRadiusOffset; 5808 update.PathRadiusOffset = part.Shape.PathRadiusOffset;
5809 update.PathRevolutions = data.Shape.PathRevolutions; 5809 update.PathRevolutions = part.Shape.PathRevolutions;
5810 update.PathScaleX = data.Shape.PathScaleX; 5810 update.PathScaleX = part.Shape.PathScaleX;
5811 update.PathScaleY = data.Shape.PathScaleY; 5811 update.PathScaleY = part.Shape.PathScaleY;
5812 update.PathShearX = data.Shape.PathShearX; 5812 update.PathShearX = part.Shape.PathShearX;
5813 update.PathShearY = data.Shape.PathShearY; 5813 update.PathShearY = part.Shape.PathShearY;
5814 update.PathSkew = data.Shape.PathSkew; 5814 update.PathSkew = part.Shape.PathSkew;
5815 update.PathTaperX = data.Shape.PathTaperX; 5815 update.PathTaperX = part.Shape.PathTaperX;
5816 update.PathTaperY = data.Shape.PathTaperY; 5816 update.PathTaperY = part.Shape.PathTaperY;
5817 update.PathTwist = data.Shape.PathTwist; 5817 update.PathTwist = part.Shape.PathTwist;
5818 update.PathTwistBegin = data.Shape.PathTwistBegin; 5818 update.PathTwistBegin = part.Shape.PathTwistBegin;
5819 update.PCode = data.Shape.PCode; 5819 update.PCode = part.Shape.PCode;
5820 update.ProfileBegin = data.Shape.ProfileBegin; 5820 update.ProfileBegin = part.Shape.ProfileBegin;
5821 update.ProfileCurve = data.Shape.ProfileCurve; 5821 update.ProfileCurve = part.Shape.ProfileCurve;
5822 update.ProfileEnd = data.Shape.ProfileEnd; 5822 update.ProfileEnd = part.Shape.ProfileEnd;
5823 update.ProfileHollow = data.Shape.ProfileHollow; 5823 update.ProfileHollow = part.Shape.ProfileHollow;
5824 update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes; 5824 update.PSBlock = part.ParticleSystem ?? Utils.EmptyBytes;
5825 update.TextColor = data.GetTextColor().GetBytes(false); 5825 update.TextColor = part.GetTextColor().GetBytes(false);
5826 update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes; 5826 update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
5827 update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes; 5827 update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
5828 update.Scale = data.Shape.Scale; 5828 update.Scale = part.Shape.Scale;
5829 update.Text = Util.StringToBytes256(data.Text); 5829 update.Text = Util.StringToBytes256(part.Text);
5830 update.MediaURL = Util.StringToBytes256(data.MediaUrl); 5830 update.MediaURL = Util.StringToBytes256(part.MediaUrl);
5831 5831
5832 #region PrimFlags 5832 #region PrimFlags
5833 5833
5834 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(sp, data.UUID); 5834 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp);
5835 5835
5836 // Don't send the CreateSelected flag to everyone 5836 // Don't send the CreateSelected flag to everyone
5837 flags &= ~PrimFlags.CreateSelected; 5837 flags &= ~PrimFlags.CreateSelected;
5838 5838
5839 if (sp.UUID == data.OwnerID) 5839 if (sp.UUID == part.OwnerID)
5840 { 5840 {
5841 if (data.CreateSelected) 5841 if (part.CreateSelected)
5842 { 5842 {
5843 // Only send this flag once, then unset it 5843 // Only send this flag once, then unset it
5844 flags |= PrimFlags.CreateSelected; 5844 flags |= PrimFlags.CreateSelected;
5845 data.CreateSelected = false; 5845 part.CreateSelected = false;
5846 } 5846 }
5847 } 5847 }
5848 5848
@@ -5854,21 +5854,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5854 5854
5855 #endregion PrimFlags 5855 #endregion PrimFlags
5856 5856
5857 if (data.Sound != UUID.Zero) 5857 if (part.Sound != UUID.Zero)
5858 { 5858 {
5859 update.Sound = data.Sound; 5859 update.Sound = part.Sound;
5860 update.OwnerID = data.OwnerID; 5860 update.OwnerID = part.OwnerID;
5861 update.Gain = (float)data.SoundGain; 5861 update.Gain = (float)part.SoundGain;
5862 update.Radius = (float)data.SoundRadius; 5862 update.Radius = (float)part.SoundRadius;
5863 update.Flags = data.SoundFlags; 5863 update.Flags = part.SoundFlags;
5864 } 5864 }
5865 5865
5866 switch ((PCode)data.Shape.PCode) 5866 switch ((PCode)part.Shape.PCode)
5867 { 5867 {
5868 case PCode.Grass: 5868 case PCode.Grass:
5869 case PCode.Tree: 5869 case PCode.Tree:
5870 case PCode.NewTree: 5870 case PCode.NewTree:
5871 update.Data = new byte[] { data.Shape.State }; 5871 update.Data = new byte[] { part.Shape.State };
5872 break; 5872 break;
5873 default: 5873 default:
5874 update.Data = Utils.EmptyBytes; 5874 update.Data = Utils.EmptyBytes;
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 57288dc..6f16ae6 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -693,17 +693,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions
693 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object 693 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
694 ); 694 );
695 695
696 public uint GenerateClientFlags(ScenePresence sp, uint curEffectivePerms, UUID objID) 696 public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
697 { 697 {
698 if(sp == null || curEffectivePerms == 0) 698 if(sp == null || task == null || curEffectivePerms == 0)
699 return (uint)0; 699 return 0;
700
701 SceneObjectPart task = m_scene.GetSceneObjectPart(objID);
702 700
703 // this shouldn't ever happen.. return no permissions/objectflags.
704 if (task == null)
705 return (uint)0;
706
707 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 701 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
708 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ; 702 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
709 703
@@ -719,6 +713,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
719 } 713 }
720 714
721 SceneObjectGroup grp = task.ParentGroup; 715 SceneObjectGroup grp = task.ParentGroup;
716 if(grp == null)
717 return 0;
718
722 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0; 719 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
723 720
724 //bypass option == owner rights 721 //bypass option == owner rights
@@ -887,7 +884,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
887 if (part == null) 884 if (part == null)
888 return 0; 885 return 0;
889 886
890 // Admin should be able to edit anything in the sim (including admin objects)
891 if (IsAdministrator(currentUser)) 887 if (IsAdministrator(currentUser))
892 return (uint)PermissionMask.AllEffective; 888 return (uint)PermissionMask.AllEffective;
893 889
@@ -901,15 +897,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
901 897
902 uint lockmask = (uint)PermissionMask.AllEffective; 898 uint lockmask = (uint)PermissionMask.AllEffective;
903 if(locked) 899 if(locked)
904 lockmask = (uint)PermissionMask.Move; 900 lockmask &= ~(uint)PermissionMask.Modify;
905 901
906 if (currentUser == objectOwner) 902 if (currentUser == objectOwner)
907 return group.EffectiveOwnerPerms & lockmask; 903 return group.EffectiveOwnerPerms & lockmask;
908 904
909 if (group.IsAttachment) 905 if (group.IsAttachment)
910 return 0; 906 return 0;
911 907
912 // Friends with benefits should be able to edit the objects too
913 if (IsFriendWithPerms(currentUser, objectOwner)) 908 if (IsFriendWithPerms(currentUser, objectOwner))
914 return group.EffectiveOwnerPerms & lockmask; 909 return group.EffectiveOwnerPerms & lockmask;
915 910
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index e611897..f2d853d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
183 part.SendFullUpdate(remoteClient); 183 part.SendFullUpdate(remoteClient);
184 184
185 // A prim is only tainted if it's allowed to be edited by the person clicking it. 185 // A prim is only tainted if it's allowed to be edited by the person clicking it.
186 if (Permissions.CanChangeSelectedState(sog.UUID, (ScenePresence)remoteClient.SceneAgent)) 186 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
187 { 187 {
188 part.IsSelected = true; 188 part.IsSelected = true;
189 EventManager.TriggerParcelPrimCountTainted(); 189 EventManager.TriggerParcelPrimCountTainted();
@@ -249,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes
249 // handled by group, but by prim. Legacy cruft. 249 // handled by group, but by prim. Legacy cruft.
250 // TODO: Make selection flagging per prim! 250 // TODO: Make selection flagging per prim!
251 // 251 //
252 if (Permissions.CanChangeSelectedState(part.ParentGroup.UUID, (ScenePresence)remoteClient.SceneAgent)) 252 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
253 { 253 {
254 part.IsSelected = false; 254 part.IsSelected = false;
255 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) 255 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 8f32b03..e42d4c2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 #region Delegates 39 #region Delegates
40 public delegate uint GenerateClientFlagsHandler(ScenePresence sp, uint curEffectivePerms, UUID objectID); 40 public delegate uint GenerateClientFlagsHandler(SceneObjectPart part, ScenePresence sp, uint curEffectivePerms);
41 public delegate void SetBypassPermissionsHandler(bool value); 41 public delegate void SetBypassPermissionsHandler(bool value);
42 public delegate bool BypassPermissionsHandler(); 42 public delegate bool BypassPermissionsHandler();
43 public delegate bool PropagatePermissionsHandler(); 43 public delegate bool PropagatePermissionsHandler();
@@ -167,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
167 167
168 #region Object Permission Checks 168 #region Object Permission Checks
169 169
170 public uint GenerateClientFlags(ScenePresence sp, UUID objectID) 170 public uint GenerateClientFlags( SceneObjectPart part, ScenePresence sp)
171 { 171 {
172 // libomv will moan about PrimFlags.ObjectYouOfficer being 172 // libomv will moan about PrimFlags.ObjectYouOfficer being
173 // obsolete... 173 // obsolete...
@@ -182,8 +182,6 @@ namespace OpenSim.Region.Framework.Scenes
182 PrimFlags.ObjectOwnerModify; 182 PrimFlags.ObjectOwnerModify;
183#pragma warning restore 0612 183#pragma warning restore 0612
184 184
185 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
186
187 if (part == null) 185 if (part == null)
188 return 0; 186 return 0;
189 187
@@ -195,7 +193,7 @@ namespace OpenSim.Region.Framework.Scenes
195 Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); 193 Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
196 foreach (GenerateClientFlagsHandler check in list) 194 foreach (GenerateClientFlagsHandler check in list)
197 { 195 {
198 perms &= check(sp, perms, objectID); 196 perms &= check(part, sp, perms);
199 } 197 }
200 } 198 }
201 return perms; 199 return perms;
@@ -411,9 +409,9 @@ namespace OpenSim.Region.Framework.Scenes
411 PrimFlags.ObjectOwnerModify 409 PrimFlags.ObjectOwnerModify
412 ); 410 );
413 411
414 public bool CanChangeSelectedState(UUID objectID, ScenePresence sp) 412 public bool CanChangeSelectedState(SceneObjectPart part, ScenePresence sp)
415 { 413 {
416 uint perms = GenerateClientFlags(sp , objectID); 414 uint perms = GenerateClientFlags(part, sp);
417 return (perms & CANSELECTMASK) != 0; 415 return (perms & CANSELECTMASK) != 0;
418 } 416 }
419 417