diff options
author | Justin Clark-Casey (justincc) | 2012-08-20 21:58:18 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-20 22:01:02 +0100 |
commit | 812c498ef4da06d8c842e53e16e22c45e2fecbc2 (patch) | |
tree | e111719cf5dabeb0a30f63205861010deec76387 /OpenSim/Region | |
parent | Tighten up OpenSim.Framework.Cache locking to avoid race conditions. (diff) | |
download | opensim-SC-812c498ef4da06d8c842e53e16e22c45e2fecbc2.zip opensim-SC-812c498ef4da06d8c842e53e16e22c45e2fecbc2.tar.gz opensim-SC-812c498ef4da06d8c842e53e16e22c45e2fecbc2.tar.bz2 opensim-SC-812c498ef4da06d8c842e53e16e22c45e2fecbc2.tar.xz |
When loading an OAR, validate any group UUIDs and properly reconstruct parcel access lists.
If a group UUID is present that is not on this simulator then the object or parcel is no longer group owned.
This is a change from previous behaviour where such invalid UUIDs were kept.
This is an adaptation of patch 0002 from http://opensimulator.org/mantis/view.php?id=6105 by Oren Hurvitz of Kitely.
My adaptations are formatting only, apart from the notices about parcel owner IDs not being saved since this has now been fixed.
Thanks Oren.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 2b61800..433166d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -97,6 +97,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | ||
101 | /// Used to cache lookups for valid groups. | ||
102 | /// </summary> | ||
103 | private IDictionary<UUID, bool> m_validGroupUuids = new Dictionary<UUID, bool>(); | ||
104 | |||
105 | private IGroupsModule m_groupsModule; | ||
106 | |||
100 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) | 107 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) |
101 | { | 108 | { |
102 | m_scene = scene; | 109 | m_scene = scene; |
@@ -120,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
120 | 127 | ||
121 | // Zero can never be a valid user id | 128 | // Zero can never be a valid user id |
122 | m_validUserUuids[UUID.Zero] = false; | 129 | m_validUserUuids[UUID.Zero] = false; |
130 | |||
131 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
123 | } | 132 | } |
124 | 133 | ||
125 | public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) | 134 | public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) |
@@ -132,6 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
132 | 141 | ||
133 | // Zero can never be a valid user id | 142 | // Zero can never be a valid user id |
134 | m_validUserUuids[UUID.Zero] = false; | 143 | m_validUserUuids[UUID.Zero] = false; |
144 | |||
145 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
135 | } | 146 | } |
136 | 147 | ||
137 | /// <summary> | 148 | /// <summary> |
@@ -302,6 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
302 | if (!ResolveUserUuid(part.LastOwnerID)) | 313 | if (!ResolveUserUuid(part.LastOwnerID)) |
303 | part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 314 | part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
304 | 315 | ||
316 | if (!ResolveGroupUuid(part.GroupID)) | ||
317 | part.GroupID = UUID.Zero; | ||
318 | |||
305 | // And zap any troublesome sit target information | 319 | // And zap any troublesome sit target information |
306 | // part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); | 320 | // part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); |
307 | // part.SitTargetPosition = new Vector3(0, 0, 0); | 321 | // part.SitTargetPosition = new Vector3(0, 0, 0); |
@@ -318,13 +332,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
318 | { | 332 | { |
319 | kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 333 | kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
320 | } | 334 | } |
335 | |||
321 | if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) | 336 | if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) |
322 | { | 337 | { |
323 | if (!ResolveUserUuid(kvp.Value.CreatorID)) | 338 | if (!ResolveUserUuid(kvp.Value.CreatorID)) |
324 | kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 339 | kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
325 | } | 340 | } |
341 | |||
326 | if (UserManager != null) | 342 | if (UserManager != null) |
327 | UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); | 343 | UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); |
344 | |||
345 | if (!ResolveGroupUuid(kvp.Value.GroupID)) | ||
346 | kvp.Value.GroupID = UUID.Zero; | ||
328 | } | 347 | } |
329 | } | 348 | } |
330 | } | 349 | } |
@@ -364,9 +383,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
364 | foreach (string serialisedParcel in serialisedParcels) | 383 | foreach (string serialisedParcel in serialisedParcels) |
365 | { | 384 | { |
366 | LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); | 385 | LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); |
386 | |||
387 | // Validate User and Group UUID's | ||
388 | |||
367 | if (!ResolveUserUuid(parcel.OwnerID)) | 389 | if (!ResolveUserUuid(parcel.OwnerID)) |
368 | parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 390 | parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
369 | 391 | ||
392 | if (!ResolveGroupUuid(parcel.GroupID)) | ||
393 | { | ||
394 | parcel.GroupID = UUID.Zero; | ||
395 | parcel.IsGroupOwned = false; | ||
396 | } | ||
397 | |||
398 | List<LandAccessEntry> accessList = new List<LandAccessEntry>(); | ||
399 | foreach (LandAccessEntry entry in parcel.ParcelAccessList) | ||
400 | { | ||
401 | if (ResolveUserUuid(entry.AgentID)) | ||
402 | accessList.Add(entry); | ||
403 | // else, drop this access rule | ||
404 | } | ||
405 | parcel.ParcelAccessList = accessList; | ||
406 | |||
370 | // m_log.DebugFormat( | 407 | // m_log.DebugFormat( |
371 | // "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", | 408 | // "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", |
372 | // parcel.Name, parcel.LocalID, parcel.Area); | 409 | // parcel.Name, parcel.LocalID, parcel.Area); |
@@ -401,6 +438,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
401 | } | 438 | } |
402 | 439 | ||
403 | /// <summary> | 440 | /// <summary> |
441 | /// Look up the given group id to check whether it's one that is valid for this grid. | ||
442 | /// </summary> | ||
443 | /// <param name="uuid"></param> | ||
444 | /// <returns></returns> | ||
445 | private bool ResolveGroupUuid(UUID uuid) | ||
446 | { | ||
447 | if (uuid == UUID.Zero) | ||
448 | return true; // this means the object has no group | ||
449 | |||
450 | if (!m_validGroupUuids.ContainsKey(uuid)) | ||
451 | { | ||
452 | bool exists; | ||
453 | |||
454 | if (m_groupsModule == null) | ||
455 | exists = false; | ||
456 | else | ||
457 | exists = (m_groupsModule.GetGroupRecord(uuid) != null); | ||
458 | |||
459 | m_validGroupUuids.Add(uuid, exists); | ||
460 | } | ||
461 | |||
462 | return m_validGroupUuids[uuid]; | ||
463 | } | ||
464 | |||
404 | /// Load an asset | 465 | /// Load an asset |
405 | /// </summary> | 466 | /// </summary> |
406 | /// <param name="assetFilename"></param> | 467 | /// <param name="assetFilename"></param> |