aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-30 04:54:15 +0000
committerTeravus Ovares2007-11-30 04:54:15 +0000
commit31cec30aa0a589f622635c689b08c2e026898556 (patch)
tree1f6763396fdd0eed5dff737a878b57f262cc06bc /OpenSim/Region/Environment
parent* This extends my first hack to clear out the useragent table for that specif... (diff)
downloadopensim-SC-31cec30aa0a589f622635c689b08c2e026898556.zip
opensim-SC-31cec30aa0a589f622635c689b08c2e026898556.tar.gz
opensim-SC-31cec30aa0a589f622635c689b08c2e026898556.tar.bz2
opensim-SC-31cec30aa0a589f622635c689b08c2e026898556.tar.xz
* Extended our semi-stupid implementation of in world object permissions to show a user's client that it can't edit a prim if it doesn't have permission.
* Permissions is due for a big revamp. The current way it's done is a hack at best.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs108
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs19
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs83
3 files changed, 201 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index bcaa1bf..9911792 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -135,6 +135,114 @@ namespace OpenSim.Region.Environment
135 135
136 #region Object Permissions 136 #region Object Permissions
137 137
138
139 public virtual bool AnyoneCanCopyPermission(LLUUID user, LLUUID objId)
140 {
141
142 // Default: deny
143 bool permission = false;
144
145 if (!m_scene.Entities.ContainsKey(objId))
146 {
147 return false;
148 }
149
150 // If it's not an object, we cant edit it.
151 if (!(m_scene.Entities[objId] is SceneObjectGroup))
152 {
153 return false;
154 }
155
156 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId];
157 LLUUID taskOwner = null;
158 // Added this because at this point in time it wouldn't be wise for
159 // the administrator object permissions to take effect.
160 LLUUID objectOwner = task.OwnerID;
161 uint objectflags = task.RootPart.EveryoneMask;
162
163 // Object owners should be able to edit their own content
164 if (user == objectOwner)
165 permission = true;
166
167 // If the 'anybody can move' flag is set then allow anyone to move it
168 if ((objectflags & (uint)LLObject.ObjectFlags.ObjectCopy ) != 0)
169 permission = true;
170
171 // Users should be able to edit what is over their land.
172 if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
173 user)
174 permission = true;
175
176 // Estate users should be able to edit anything in the sim
177 if (IsEstateManager(user))
178 permission = true;
179
180 // Admin objects should not be editable by the above
181 if (IsAdministrator(taskOwner))
182 permission = false;
183
184 // Admin should be able to edit anything in the sim (including admin objects)
185 if (IsAdministrator(user))
186 permission = true;
187
188 return permission;
189
190 }
191
192
193 public virtual bool AnyoneCanMovePermission(LLUUID user, LLUUID objId)
194 {
195
196 // Default: deny
197 bool permission = false;
198
199 if (!m_scene.Entities.ContainsKey(objId))
200 {
201 return false;
202 }
203
204 // If it's not an object, we cant edit it.
205 if (!(m_scene.Entities[objId] is SceneObjectGroup))
206 {
207 return false;
208 }
209
210 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId];
211 LLUUID taskOwner = null;
212 // Added this because at this point in time it wouldn't be wise for
213 // the administrator object permissions to take effect.
214 LLUUID objectOwner = task.OwnerID;
215 uint objectflags = task.RootPart.ObjectFlags;
216
217 // Object owners should be able to edit their own content
218 if (user == objectOwner)
219 permission = true;
220
221 // If the 'anybody can move' flag is set then allow anyone to move it
222 if ((objectflags & (uint)LLObject.ObjectFlags.ObjectMove) != 0)
223 permission = true;
224
225 // Users should be able to edit what is over their land.
226 if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
227 user)
228 permission = true;
229
230 // Estate users should be able to edit anything in the sim
231 if (IsEstateManager(user))
232 permission = true;
233
234 // Admin objects should not be editable by the above
235 if (IsAdministrator(taskOwner))
236 permission = false;
237
238 // Admin should be able to edit anything in the sim (including admin objects)
239 if (IsAdministrator(user))
240 permission = true;
241
242 return permission;
243
244 }
245
138 protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) 246 protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId)
139 { 247 {
140 // Default: deny 248 // Default: deny
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 2d74913..cc0f3e1 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -733,7 +733,7 @@ namespace OpenSim.Region.Environment.Scenes
733 /// <summary> 733 /// <summary>
734 /// Loads the World's objects 734 /// Loads the World's objects
735 /// </summary> 735 /// </summary>
736 public virtual void LoadPrimsFromStorage() 736 public virtual void LoadPrimsFromStorage(bool m_permissions)
737 { 737 {
738 MainLog.Instance.Verbose("Loading objects from datastore"); 738 MainLog.Instance.Verbose("Loading objects from datastore");
739 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID); 739 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID);
@@ -741,6 +741,20 @@ namespace OpenSim.Region.Environment.Scenes
741 { 741 {
742 AddEntityFromStorage(prim); 742 AddEntityFromStorage(prim);
743 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 743 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
744 if (m_permissions)
745 {
746 rootPart.EveryoneMask = rootPart.ObjectFlags;
747 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
748 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
749 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
750 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
751 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
752 rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
753 }
754 else
755 {
756 rootPart.EveryoneMask = rootPart.ObjectFlags;
757 }
744 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 758 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
745 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 759 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
746 rootPart.PhysActor = PhysicsScene.AddPrimShape( 760 rootPart.PhysActor = PhysicsScene.AddPrimShape(
@@ -839,7 +853,8 @@ namespace OpenSim.Region.Environment.Scenes
839 // if grass or tree, make phantom 853 // if grass or tree, make phantom
840 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) 854 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
841 { 855 {
842 rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 856 rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
857 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
843 } 858 }
844 // if not phantom, add to physics 859 // if not phantom, add to physics
845 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 860 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index c94bfd9..d8e2143 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -466,6 +466,18 @@ namespace OpenSim.Region.Environment.Scenes
466 LLObject.ObjectFlags.CreateSelected | 466 LLObject.ObjectFlags.CreateSelected |
467 LLObject.ObjectFlags.ObjectOwnerModify; 467 LLObject.ObjectFlags.ObjectOwnerModify;
468 468
469 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
470 {
471 EveryoneMask = (uint)m_flags;
472 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
473 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
474 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
475 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
476 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
477 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
478 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
479 }
480
469 ScheduleFullUpdate(); 481 ScheduleFullUpdate();
470 } 482 }
471 483
@@ -503,6 +515,23 @@ namespace OpenSim.Region.Environment.Scenes
503 OffsetPosition = position; 515 OffsetPosition = position;
504 RotationOffset = rotation; 516 RotationOffset = rotation;
505 ObjectFlags = flags; 517 ObjectFlags = flags;
518
519 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
520 {
521 EveryoneMask = (uint)m_flags;
522 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
523 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
524 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
525 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
526 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
527 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
528 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
529 }
530 else
531 {
532 EveryoneMask = ObjectFlags;
533 }
534
506 bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 535 bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
507 doPhysicsPropertyUpdate(UsePhysics, true); 536 doPhysicsPropertyUpdate(UsePhysics, true);
508 ScheduleFullUpdate(); 537 ScheduleFullUpdate();
@@ -519,6 +548,23 @@ namespace OpenSim.Region.Environment.Scenes
519 { 548 {
520 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); 549 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
521 SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); 550 SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader);
551
552 if (!newobject.ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
553 {
554 newobject.EveryoneMask = newobject.ObjectFlags;
555 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
556 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
557 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
558 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
559 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
560 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
561 newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
562 }
563 else
564 {
565 newobject.EveryoneMask = newobject.ObjectFlags;
566 }
567
522 bool UsePhysics = ((newobject.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 568 bool UsePhysics = ((newobject.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
523 newobject.doPhysicsPropertyUpdate(UsePhysics, true); 569 newobject.doPhysicsPropertyUpdate(UsePhysics, true);
524 570
@@ -711,6 +757,9 @@ namespace OpenSim.Region.Environment.Scenes
711 { 757 {
712 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); 758 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
713 m_flags |= flag; 759 m_flags |= flag;
760 BaseMask |= (uint)flag;
761 GroupMask |= (uint)flag;
762 EveryoneMask |= (uint)flag;
714 } 763 }
715 uint currflag = (uint) m_flags; 764 uint currflag = (uint) m_flags;
716 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 765 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
@@ -724,6 +773,9 @@ namespace OpenSim.Region.Environment.Scenes
724 { 773 {
725 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); 774 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
726 m_flags &= ~flag; 775 m_flags &= ~flag;
776 BaseMask &= ~(uint)flag;
777 GroupMask &= ~(uint)flag;
778 EveryoneMask &= ~(uint)flag;
727 } 779 }
728 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 780 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
729 //ScheduleFullUpdate(); 781 //ScheduleFullUpdate();
@@ -1201,19 +1253,36 @@ namespace OpenSim.Region.Environment.Scenes
1201 } 1253 }
1202 break; 1254 break;
1203 } 1255 }
1256 }
1257 // If you can't edit it, send the base permissions minus the flag to edit
1258 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
1259 {
1260 if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID))
1261 {
1262 //clientFlags = ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
1263 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
1264 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1265 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1266 // Send EveryoneMask
1267 clientFlags = ObjectFlags;
1268
1269 }
1204 else 1270 else
1205 { 1271 {
1206 // If you can't edit it, send the base permissions minus the flag to edit 1272 clientFlags = ObjectFlags;
1207 if (!ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID)) 1273 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID))
1208 { 1274 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
1209 clientFlags = ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; 1275 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID))
1210 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; 1276 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
1211 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 1277
1212 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; 1278 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
1213 } 1279 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1280 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1281 clientFlags = EveryoneMask;
1214 } 1282 }
1215 } 1283 }
1216 1284
1285
1217 byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A }; 1286 byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A };
1218 remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid, 1287 remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid,
1219 OwnerID, 1288 OwnerID,