From 812c498ef4da06d8c842e53e16e22c45e2fecbc2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 20 Aug 2012 21:58:18 +0100 Subject: [PATCH] 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. --- .../World/Archiver/ArchiveReadRequest.cs | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 2b61800c94..433166d848 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 } } + /// + /// Used to cache lookups for valid groups. + /// + private IDictionary m_validGroupUuids = new Dictionary(); + + private IGroupsModule m_groupsModule; + public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) { m_scene = scene; @@ -120,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Zero can never be a valid user id m_validUserUuids[UUID.Zero] = false; + + m_groupsModule = m_scene.RequestModuleInterface(); } public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) @@ -132,6 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Zero can never be a valid user id m_validUserUuids[UUID.Zero] = false; + + m_groupsModule = m_scene.RequestModuleInterface(); } /// @@ -302,6 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (!ResolveUserUuid(part.LastOwnerID)) part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; + if (!ResolveGroupUuid(part.GroupID)) + part.GroupID = UUID.Zero; + // And zap any troublesome sit target information // part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); // part.SitTargetPosition = new Vector3(0, 0, 0); @@ -318,13 +332,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver { kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } + if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) { if (!ResolveUserUuid(kvp.Value.CreatorID)) kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; } + if (UserManager != null) UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); + + if (!ResolveGroupUuid(kvp.Value.GroupID)) + kvp.Value.GroupID = UUID.Zero; } } } @@ -364,9 +383,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver foreach (string serialisedParcel in serialisedParcels) { LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); + + // Validate User and Group UUID's + if (!ResolveUserUuid(parcel.OwnerID)) parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; - + + if (!ResolveGroupUuid(parcel.GroupID)) + { + parcel.GroupID = UUID.Zero; + parcel.IsGroupOwned = false; + } + + List accessList = new List(); + foreach (LandAccessEntry entry in parcel.ParcelAccessList) + { + if (ResolveUserUuid(entry.AgentID)) + accessList.Add(entry); + // else, drop this access rule + } + parcel.ParcelAccessList = accessList; + // m_log.DebugFormat( // "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", // parcel.Name, parcel.LocalID, parcel.Area); @@ -401,6 +438,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver } /// + /// Look up the given group id to check whether it's one that is valid for this grid. + /// + /// + /// + private bool ResolveGroupUuid(UUID uuid) + { + if (uuid == UUID.Zero) + return true; // this means the object has no group + + if (!m_validGroupUuids.ContainsKey(uuid)) + { + bool exists; + + if (m_groupsModule == null) + exists = false; + else + exists = (m_groupsModule.GetGroupRecord(uuid) != null); + + m_validGroupUuids.Add(uuid, exists); + } + + return m_validGroupUuids[uuid]; + } + /// Load an asset /// ///