aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
diff options
context:
space:
mode:
authorUbitUmarov2017-05-04 11:37:13 +0100
committerUbitUmarov2017-05-04 11:37:13 +0100
commit3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855 (patch)
tree746ee2b8b01f1164dc815293b63086d959c05eb4 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
parentfix right to change permissions of group owned objects (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs98
1 files changed, 23 insertions, 75 deletions
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)