diff options
author | UbitUmarov | 2017-05-04 11:37:13 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-04 11:37:13 +0100 |
commit | 3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855 (patch) | |
tree | 746ee2b8b01f1164dc815293b63086d959c05eb4 | |
parent | fix right to change permissions of group owned objects (diff) | |
download | opensim-SC-3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855.zip opensim-SC-3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855.tar.gz opensim-SC-3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855.tar.bz2 opensim-SC-3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855.tar.xz |
move deep effective permissions aggregation to first time use and not on changes. There flag it is need with InvalidateDeepEffectivePerms(). Add config options PropagateGroupShareOutwards and PropagateAnyOneOutwards
Diffstat (limited to '')
9 files changed, 48 insertions, 84 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index f1885da..3f3245c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -1182,7 +1182,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | rootPart.TrimPermissions(); | 1184 | rootPart.TrimPermissions(); |
1185 | so.AggregateDeepPerms(); | 1185 | so.InvalidateDeepEffectivePerms(); |
1186 | 1186 | ||
1187 | if (isAttachment) | 1187 | if (isAttachment) |
1188 | so.FromItemID = item.ID; | 1188 | so.FromItemID = item.ID; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 715ae5c..205a321 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -239,6 +239,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
239 | public bool LegacySitOffsets = true; | 239 | public bool LegacySitOffsets = true; |
240 | 240 | ||
241 | /// <summary> | 241 | /// <summary> |
242 | /// set false to not propagare group rights outwards as legacy did | ||
243 | /// </summary> | ||
244 | public bool PropagateGroupShareOutwards = true; | ||
245 | |||
246 | /// <summary> | ||
247 | /// set false to not propagare Everyone rights outwards as legacy did | ||
248 | /// </summary> | ||
249 | public bool PropagateAnyOneOutwards = true; | ||
250 | |||
251 | /// <summary> | ||
242 | /// Can avatars cross from and to this region? | 252 | /// Can avatars cross from and to this region? |
243 | /// </summary> | 253 | /// </summary> |
244 | public bool AllowAvatarCrossing { get; set; } | 254 | public bool AllowAvatarCrossing { get; set; } |
@@ -978,7 +988,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
978 | m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); | 988 | m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); |
979 | m_maxRegionViewDistance = startupConfig.GetFloat("MaxRegionsViewDistance", m_maxRegionViewDistance); | 989 | m_maxRegionViewDistance = startupConfig.GetFloat("MaxRegionsViewDistance", m_maxRegionViewDistance); |
980 | 990 | ||
991 | // old versions compatibility | ||
981 | LegacySitOffsets = startupConfig.GetBoolean("LegacySitOffsets", LegacySitOffsets); | 992 | LegacySitOffsets = startupConfig.GetBoolean("LegacySitOffsets", LegacySitOffsets); |
993 | PropagateGroupShareOutwards = startupConfig.GetBoolean("PropagateGroupShareOutwards", PropagateGroupShareOutwards); | ||
994 | PropagateAnyOneOutwards = startupConfig.GetBoolean("PropagateAnyOneOutwards", PropagateAnyOneOutwards); | ||
982 | 995 | ||
983 | if (m_defaultDrawDistance > m_maxDrawDistance) | 996 | if (m_defaultDrawDistance > m_maxDrawDistance) |
984 | m_defaultDrawDistance = m_maxDrawDistance; | 997 | m_defaultDrawDistance = m_maxDrawDistance; |
@@ -2390,8 +2403,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2390 | EventManager.TriggerOnSceneObjectLoaded(group); | 2403 | EventManager.TriggerOnSceneObjectLoaded(group); |
2391 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 2404 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
2392 | rootPart.Flags &= ~PrimFlags.Scripted; | 2405 | rootPart.Flags &= ~PrimFlags.Scripted; |
2393 | group.AggregateDeepPerms(); | 2406 | |
2394 | rootPart.TrimPermissions(); | 2407 | rootPart.TrimPermissions(); |
2408 | group.InvalidateDeepEffectivePerms(); | ||
2395 | 2409 | ||
2396 | // Don't do this here - it will get done later on when sculpt data is loaded. | 2410 | // Don't do this here - it will get done later on when sculpt data is loaded. |
2397 | // group.CheckSculptAndLoad(); | 2411 | // group.CheckSculptAndLoad(); |
@@ -2662,7 +2676,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2662 | if (UserManagementModule != null) | 2676 | if (UserManagementModule != null) |
2663 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); | 2677 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); |
2664 | 2678 | ||
2665 | sceneObject.AggregateDeepPerms(); | 2679 | sceneObject.InvalidateDeepEffectivePerms();; |
2666 | sceneObject.ScheduleGroupForFullUpdate(); | 2680 | sceneObject.ScheduleGroupForFullUpdate(); |
2667 | 2681 | ||
2668 | return sceneObject; | 2682 | return sceneObject; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a005068..91d2879 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -343,7 +343,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
343 | sceneObject.ForceInventoryPersistence(); | 343 | sceneObject.ForceInventoryPersistence(); |
344 | sceneObject.HasGroupChanged = true; | 344 | sceneObject.HasGroupChanged = true; |
345 | } | 345 | } |
346 | sceneObject.AggregateDeepPerms(); | 346 | sceneObject.InvalidateDeepEffectivePerms(); |
347 | return ret; | 347 | return ret; |
348 | } | 348 | } |
349 | 349 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 36844a9..95a5887 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -254,13 +254,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | // new test code, to place in better place later | 254 | // new test code, to place in better place later |
255 | private object m_PermissionsLock = new object(); | 255 | private object m_PermissionsLock = new object(); |
256 | private bool m_EffectivePermsInvalid = true; | 256 | private bool m_EffectivePermsInvalid = true; |
257 | private bool m_DeepEffectivePermsInvalid = true; | ||
257 | 258 | ||
259 | // should called when parts chanced by their contents did not, so we know their cacche is valid | ||
260 | // in case of doubt call InvalidateDeepEffectivePerms(), it only costs a bit more cpu time | ||
258 | public void InvalidateEffectivePerms() | 261 | public void InvalidateEffectivePerms() |
259 | { | 262 | { |
260 | lock(m_PermissionsLock) | 263 | lock(m_PermissionsLock) |
261 | m_EffectivePermsInvalid = true; | 264 | m_EffectivePermsInvalid = true; |
262 | } | 265 | } |
263 | 266 | ||
267 | // should called when parts chanced and their contents where accounted for | ||
268 | public void InvalidateDeepEffectivePerms() | ||
269 | { | ||
270 | lock(m_PermissionsLock) | ||
271 | { | ||
272 | m_DeepEffectivePermsInvalid = true; | ||
273 | m_EffectivePermsInvalid = true; | ||
274 | } | ||
275 | } | ||
276 | |||
264 | private uint m_EffectiveEveryOnePerms; | 277 | private uint m_EffectiveEveryOnePerms; |
265 | public uint EffectiveEveryOnePerms | 278 | public uint EffectiveEveryOnePerms |
266 | { | 279 | { |
@@ -317,79 +330,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
317 | } | 330 | } |
318 | } | 331 | } |
319 | 332 | ||
320 | // aggregates perms scanning parts and their contents | ||
321 | // AggregatePerms does same using cached parts content perms | ||
322 | public void AggregateDeepPerms() | ||
323 | { | ||
324 | lock(m_PermissionsLock) | ||
325 | { | ||
326 | // aux | ||
327 | const uint allmask = (uint)PermissionMask.AllEffective; | ||
328 | const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
329 | const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer); | ||
330 | |||
331 | uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; | ||
332 | bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; | ||
333 | |||
334 | uint rootOwnerPerms = RootPart.OwnerMask; | ||
335 | uint owner = rootOwnerPerms; | ||
336 | uint rootGroupPerms = RootPart.GroupMask; | ||
337 | uint group = rootGroupPerms; | ||
338 | uint rootEveryonePerms = RootPart.EveryoneMask; | ||
339 | uint everyone = rootEveryonePerms; | ||
340 | |||
341 | // date is time of writing april 30th 2017 | ||
342 | bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); | ||
343 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
344 | for (int i = 0; i < parts.Length; i++) | ||
345 | { | ||
346 | SceneObjectPart part = parts[i]; | ||
347 | part.AggregateInnerPerms(); | ||
348 | owner &= part.AggregatedInnerOwnerPerms; | ||
349 | group &= part.AggregatedInnerGroupPerms; | ||
350 | if(newObject) | ||
351 | everyone &= part.AggregatedInnerEveryonePerms; | ||
352 | } | ||
353 | // recover modify and move | ||
354 | rootOwnerPerms &= movemodmask; | ||
355 | owner |= rootOwnerPerms; | ||
356 | if((owner & copytransfermask) == 0) | ||
357 | owner |= (uint)PermissionMask.Transfer; | ||
358 | |||
359 | owner &= basePerms; | ||
360 | m_EffectiveOwnerPerms = owner; | ||
361 | uint ownertransfermask = owner & (uint)PermissionMask.Transfer; | ||
362 | |||
363 | // recover modify and move | ||
364 | rootGroupPerms &= movemodmask; | ||
365 | group |= rootGroupPerms; | ||
366 | if(noBaseTransfer) | ||
367 | group &=~(uint)PermissionMask.Copy; | ||
368 | else | ||
369 | group |= ownertransfermask; | ||
370 | |||
371 | uint groupOrEveryone = group; | ||
372 | m_EffectiveGroupPerms = group & owner; | ||
373 | |||
374 | // recover move | ||
375 | rootEveryonePerms &= (uint)PermissionMask.Move; | ||
376 | everyone |= rootEveryonePerms; | ||
377 | everyone &= ~(uint)PermissionMask.Modify; | ||
378 | if(noBaseTransfer) | ||
379 | everyone &=~(uint)PermissionMask.Copy; | ||
380 | else | ||
381 | everyone |= ownertransfermask; | ||
382 | |||
383 | groupOrEveryone |= everyone; | ||
384 | |||
385 | m_EffectiveEveryOnePerms = everyone & owner; | ||
386 | m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; | ||
387 | m_EffectivePermsInvalid = false; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | // aggregates perms scanning parts, assuming their contents was already aggregated and cached | ||
392 | // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop | ||
393 | public void AggregatePerms() | 333 | public void AggregatePerms() |
394 | { | 334 | { |
395 | lock(m_PermissionsLock) | 335 | lock(m_PermissionsLock) |
@@ -410,15 +350,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | uint everyone = rootEveryonePerms; | 350 | uint everyone = rootEveryonePerms; |
411 | 351 | ||
412 | bool needUpdate = false; | 352 | bool needUpdate = false; |
353 | bool propGroupOut = Scene.PropagateGroupShareOutwards; | ||
413 | // date is time of writing april 30th 2017 | 354 | // date is time of writing april 30th 2017 |
414 | bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); | 355 | bool propAnyOut = Scene.PropagateAnyOneOutwards & (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); |
415 | SceneObjectPart[] parts = m_parts.GetArray(); | 356 | SceneObjectPart[] parts = m_parts.GetArray(); |
416 | for (int i = 0; i < parts.Length; i++) | 357 | for (int i = 0; i < parts.Length; i++) |
417 | { | 358 | { |
418 | SceneObjectPart part = parts[i]; | 359 | SceneObjectPart part = parts[i]; |
360 | |||
361 | if(m_DeepEffectivePermsInvalid) | ||
362 | part.AggregateInnerPerms(); | ||
363 | |||
419 | owner &= part.AggregatedInnerOwnerPerms; | 364 | owner &= part.AggregatedInnerOwnerPerms; |
420 | group &= part.AggregatedInnerGroupPerms; | 365 | group &= part.AggregatedInnerGroupPerms; |
421 | if(newObject) | 366 | if(propGroupOut) |
367 | group &= part.AggregatedInnerGroupPerms; | ||
368 | if(propAnyOut) | ||
422 | everyone &= part.AggregatedInnerEveryonePerms; | 369 | everyone &= part.AggregatedInnerEveryonePerms; |
423 | } | 370 | } |
424 | // recover modify and move | 371 | // recover modify and move |
@@ -477,6 +424,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
477 | m_EffectiveGroupOrEveryOnePerms = tmpPerms; | 424 | m_EffectiveGroupOrEveryOnePerms = tmpPerms; |
478 | } | 425 | } |
479 | 426 | ||
427 | m_DeepEffectivePermsInvalid = false; | ||
480 | m_EffectivePermsInvalid = false; | 428 | m_EffectivePermsInvalid = false; |
481 | 429 | ||
482 | if(needUpdate) | 430 | if(needUpdate) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e73795e..512656b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2677,7 +2677,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2677 | if (dupe.m_rootPart.PhysActor != null) | 2677 | if (dupe.m_rootPart.PhysActor != null) |
2678 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | 2678 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building |
2679 | 2679 | ||
2680 | dupe.AggregateDeepPerms(); | 2680 | dupe.InvalidateDeepEffectivePerms(); |
2681 | 2681 | ||
2682 | dupe.HasGroupChanged = true; | 2682 | dupe.HasGroupChanged = true; |
2683 | dupe.AttachToBackup(); | 2683 | dupe.AttachToBackup(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4df1f27..21bc19e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -979,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | } | 979 | } |
980 | // old code end | 980 | // old code end |
981 | rootPart.TrimPermissions(); | 981 | rootPart.TrimPermissions(); |
982 | group.AggregateDeepPerms(); | 982 | group.InvalidateDeepEffectivePerms(); |
983 | } | 983 | } |
984 | 984 | ||
985 | return true; | 985 | return true; |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 87d1ace..892403b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
114 | // Script state may, or may not, exist. Not having any, is NOT | 114 | // Script state may, or may not, exist. Not having any, is NOT |
115 | // ever a problem. | 115 | // ever a problem. |
116 | sceneObject.LoadScriptState(reader); | 116 | sceneObject.LoadScriptState(reader); |
117 | sceneObject.AggregateDeepPerms(); | 117 | sceneObject.InvalidateDeepEffectivePerms(); |
118 | return sceneObject; | 118 | return sceneObject; |
119 | } | 119 | } |
120 | 120 | ||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
278 | // Script state may, or may not, exist. Not having any, is NOT | 278 | // Script state may, or may not, exist. Not having any, is NOT |
279 | // ever a problem. | 279 | // ever a problem. |
280 | sceneObject.LoadScriptState(doc); | 280 | sceneObject.LoadScriptState(doc); |
281 | sceneObject.AggregatePerms(); | 281 | // sceneObject.AggregatePerms(); |
282 | return sceneObject; | 282 | return sceneObject; |
283 | } | 283 | } |
284 | catch (Exception e) | 284 | catch (Exception e) |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index 0f022dd..34fdb6d 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
70 | //obj.RegenerateFullIDs(); | 70 | //obj.RegenerateFullIDs(); |
71 | 71 | ||
72 | scene.AddNewSceneObject(obj, true); | 72 | scene.AddNewSceneObject(obj, true); |
73 | obj.AggregateDeepPerms(); | 73 | obj.InvalidateDeepEffectivePerms(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | else | 76 | else |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index fbd7e90..7902fb1 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -626,6 +626,7 @@ namespace OpenSim.Tests.Common | |||
626 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; | 626 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; |
627 | 627 | ||
628 | scene.AddNewSceneObject(so, true); | 628 | scene.AddNewSceneObject(so, true); |
629 | so.InvalidateDeepEffectivePerms(); | ||
629 | 630 | ||
630 | return so; | 631 | return so; |
631 | } | 632 | } |
@@ -652,6 +653,7 @@ namespace OpenSim.Tests.Common | |||
652 | SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail); | 653 | SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail); |
653 | 654 | ||
654 | scene.AddNewSceneObject(so, false); | 655 | scene.AddNewSceneObject(so, false); |
656 | so.InvalidateDeepEffectivePerms(); | ||
655 | 657 | ||
656 | return so; | 658 | return so; |
657 | } | 659 | } |