diff options
author | UbitUmarov | 2017-01-15 16:15:40 +0000 |
---|---|---|
committer | UbitUmarov | 2017-01-15 16:15:40 +0000 |
commit | b9e2606c2ff820369659940e4aafbcb55390794a (patch) | |
tree | 3b2b92a6b7e20a5959ac93b4b5004e1c986b8fdd /OpenSim/Region/Framework/Scenes | |
parent | use of PermissionMask Bit3 for slam was a recent mistake, so make it only bit... (diff) | |
download | opensim-SC_OLD-b9e2606c2ff820369659940e4aafbcb55390794a.zip opensim-SC_OLD-b9e2606c2ff820369659940e4aafbcb55390794a.tar.gz opensim-SC_OLD-b9e2606c2ff820369659940e4aafbcb55390794a.tar.bz2 opensim-SC_OLD-b9e2606c2ff820369659940e4aafbcb55390794a.tar.xz |
add code for fixing effective permitions. This is a test, and currently too slow for prodution. just finding our way home
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 177 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 46 |
2 files changed, 221 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9f98554..f44604b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -248,6 +248,183 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | return -1; | 248 | return -1; |
249 | } | 249 | } |
250 | 250 | ||
251 | // new test code, to place in better place later | ||
252 | private object PermissionsLock = new object(); | ||
253 | |||
254 | private uint m_EffectiveEveryOnePerms; | ||
255 | public uint EffectiveEveryOnePerms | ||
256 | { | ||
257 | get | ||
258 | { | ||
259 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
260 | // bc this is on heavy duty code paths | ||
261 | // but for now we need to test the concept | ||
262 | AggregateEveryOnePerms(); | ||
263 | return m_EffectiveEveryOnePerms; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | public void AggregateEveryOnePerms() | ||
268 | { | ||
269 | lock(PermissionsLock) | ||
270 | { | ||
271 | // get object everyone permissions | ||
272 | uint baseperms = RootPart.EveryoneMask & (uint)PermissionMask.All; | ||
273 | |||
274 | if(baseperms == 0) | ||
275 | { | ||
276 | m_EffectiveEveryOnePerms = 0; | ||
277 | return; | ||
278 | } | ||
279 | |||
280 | uint current = baseperms; | ||
281 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
282 | for (int i = 0; i < parts.Length; i++) | ||
283 | { | ||
284 | SceneObjectPart part = parts[i]; | ||
285 | part.Inventory.AggregateEveryOnePerms(ref current); | ||
286 | if( current == 0) | ||
287 | break; | ||
288 | } | ||
289 | // recover move | ||
290 | baseperms &= (uint)PermissionMask.Move; | ||
291 | current |= baseperms; | ||
292 | current &= (uint)PermissionMask.All; | ||
293 | m_EffectiveEveryOnePerms = current; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | private uint m_EffectiveGroupPerms; | ||
298 | public uint EffectiveGroupPerms | ||
299 | { | ||
300 | get | ||
301 | { | ||
302 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
303 | // bc this is on heavy duty code paths | ||
304 | // but for now we need to test the concept | ||
305 | AggregateGroupPerms(); | ||
306 | return m_EffectiveGroupPerms; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | public void AggregateGroupPerms() | ||
311 | { | ||
312 | lock(PermissionsLock) | ||
313 | { | ||
314 | // get object everyone permissions | ||
315 | uint baseperms = RootPart.GroupMask & (uint)PermissionMask.All; | ||
316 | |||
317 | if(baseperms == 0) | ||
318 | { | ||
319 | m_EffectiveGroupPerms = 0; | ||
320 | return; | ||
321 | } | ||
322 | |||
323 | uint current = baseperms; | ||
324 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
325 | for (int i = 0; i < parts.Length; i++) | ||
326 | { | ||
327 | SceneObjectPart part = parts[i]; | ||
328 | part.Inventory.AggregateGroupPerms(ref current); | ||
329 | if( current == 0) | ||
330 | break; | ||
331 | } | ||
332 | // recover modify and move | ||
333 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | ||
334 | current |= baseperms; | ||
335 | current &= (uint)PermissionMask.All; | ||
336 | m_EffectiveGroupPerms = current; | ||
337 | } | ||
338 | } | ||
339 | |||
340 | private uint m_EffectiveGroupOrEveryOnePerms; | ||
341 | public uint EffectiveGroupOrEveryOnePerms | ||
342 | { | ||
343 | get | ||
344 | { | ||
345 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
346 | // bc this is on heavy duty code paths | ||
347 | // but for now we need to test the concept | ||
348 | AggregateGroupOrEveryOnePerms(); | ||
349 | return m_EffectiveGroupOrEveryOnePerms; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | public void AggregateGroupOrEveryOnePerms() | ||
354 | { | ||
355 | lock(PermissionsLock) | ||
356 | { | ||
357 | // get object everyone permissions | ||
358 | uint baseperms = (RootPart.EveryoneMask | RootPart.GroupMask) & (uint)PermissionMask.All; | ||
359 | |||
360 | if(baseperms == 0) | ||
361 | { | ||
362 | m_EffectiveGroupOrEveryOnePerms = 0; | ||
363 | return; | ||
364 | } | ||
365 | |||
366 | uint current = baseperms; | ||
367 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
368 | for (int i = 0; i < parts.Length; i++) | ||
369 | { | ||
370 | SceneObjectPart part = parts[i]; | ||
371 | part.Inventory.AggregateGroupOrEveryonePerms(ref current); | ||
372 | if( current == 0) | ||
373 | break; | ||
374 | } | ||
375 | // recover modify and move | ||
376 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | ||
377 | current |= baseperms; | ||
378 | current &= (uint)PermissionMask.All; | ||
379 | m_EffectiveGroupOrEveryOnePerms = current; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | private uint m_EffectiveOwnerPerms; | ||
384 | public uint EffectiveOwnerPerms | ||
385 | { | ||
386 | get | ||
387 | { | ||
388 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
389 | // bc this is on heavy duty code paths | ||
390 | // but for now we need to test the concept | ||
391 | AggregateOwnerPerms(); | ||
392 | return m_EffectiveOwnerPerms; | ||
393 | } | ||
394 | } | ||
395 | |||
396 | public void AggregateOwnerPerms() | ||
397 | { | ||
398 | lock(PermissionsLock) | ||
399 | { | ||
400 | // get object everyone permissions | ||
401 | uint baseperms = RootPart.OwnerMask & (uint)PermissionMask.All; | ||
402 | |||
403 | if(baseperms == 0) | ||
404 | { | ||
405 | m_EffectiveOwnerPerms = 0; | ||
406 | return; | ||
407 | } | ||
408 | |||
409 | uint current = baseperms; | ||
410 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
411 | for (int i = 0; i < parts.Length; i++) | ||
412 | { | ||
413 | SceneObjectPart part = parts[i]; | ||
414 | part.Inventory.AggregateOwnerPerms(ref current); | ||
415 | if( current == 0) | ||
416 | break; | ||
417 | } | ||
418 | // recover modify and move | ||
419 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | ||
420 | current |= baseperms; | ||
421 | current &= (uint)PermissionMask.All; | ||
422 | if((current & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0) | ||
423 | current |= (uint)PermissionMask.Transfer; | ||
424 | m_EffectiveOwnerPerms = current; | ||
425 | } | ||
426 | } | ||
427 | |||
251 | public uint GetEffectivePermissions() | 428 | public uint GetEffectivePermissions() |
252 | { | 429 | { |
253 | return GetEffectivePermissions(false); | 430 | return GetEffectivePermissions(false); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 02b94ce..48ae39e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -944,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
944 | group.SetGroup(m_part.GroupID, null); | 944 | group.SetGroup(m_part.GroupID, null); |
945 | 945 | ||
946 | // TODO: Remove magic number badness | 946 | // TODO: Remove magic number badness |
947 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | 947 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number |
948 | { | 948 | { |
949 | if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) | 949 | if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) |
950 | { | 950 | { |
@@ -965,7 +965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
965 | foreach (SceneObjectPart part in partList) | 965 | foreach (SceneObjectPart part in partList) |
966 | { | 966 | { |
967 | // TODO: Remove magic number badness | 967 | // TODO: Remove magic number badness |
968 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | 968 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number |
969 | { | 969 | { |
970 | part.LastOwnerID = part.OwnerID; | 970 | part.LastOwnerID = part.OwnerID; |
971 | part.OwnerID = item.OwnerID; | 971 | part.OwnerID = item.OwnerID; |
@@ -1319,6 +1319,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
1319 | } | 1319 | } |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | // reduce to minimal set | ||
1323 | public void AggregateEveryOnePerms(ref uint current) | ||
1324 | { | ||
1325 | foreach (TaskInventoryItem item in m_items.Values) | ||
1326 | { | ||
1327 | current &= item.EveryonePermissions; | ||
1328 | if(current == 0) | ||
1329 | break; | ||
1330 | } | ||
1331 | } | ||
1332 | |||
1333 | public void AggregateGroupPerms(ref uint current) | ||
1334 | { | ||
1335 | foreach (TaskInventoryItem item in m_items.Values) | ||
1336 | { | ||
1337 | current &= item.GroupPermissions; | ||
1338 | if(current == 0) | ||
1339 | break; | ||
1340 | } | ||
1341 | } | ||
1342 | |||
1343 | public void AggregateGroupOrEveryonePerms(ref uint current) | ||
1344 | { | ||
1345 | foreach (TaskInventoryItem item in m_items.Values) | ||
1346 | { | ||
1347 | current &= (item.GroupPermissions | item.EveryonePermissions); | ||
1348 | if(current == 0) | ||
1349 | break; | ||
1350 | } | ||
1351 | } | ||
1352 | |||
1353 | public void AggregateOwnerPerms(ref uint current) | ||
1354 | { | ||
1355 | foreach (TaskInventoryItem item in m_items.Values) | ||
1356 | { | ||
1357 | current &= item.CurrentPermissions; | ||
1358 | if(current == 0) | ||
1359 | break; | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1363 | |||
1322 | public uint MaskEffectivePermissions() | 1364 | public uint MaskEffectivePermissions() |
1323 | { | 1365 | { |
1324 | uint mask=0x7fffffff; | 1366 | uint mask=0x7fffffff; |