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.
integration
Justin Clark-Casey (justincc) 2012-08-20 21:58:18 +01:00
parent 970727e57e
commit 812c498ef4
1 changed files with 62 additions and 1 deletions

View File

@ -97,6 +97,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
} }
/// <summary>
/// Used to cache lookups for valid groups.
/// </summary>
private IDictionary<UUID, bool> m_validGroupUuids = new Dictionary<UUID, bool>();
private IGroupsModule m_groupsModule;
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
{ {
m_scene = scene; m_scene = scene;
@ -120,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Zero can never be a valid user id // Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false; m_validUserUuids[UUID.Zero] = false;
m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
} }
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) 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 // Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false; m_validUserUuids[UUID.Zero] = false;
m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
} }
/// <summary> /// <summary>
@ -302,6 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (!ResolveUserUuid(part.LastOwnerID)) if (!ResolveUserUuid(part.LastOwnerID))
part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveGroupUuid(part.GroupID))
part.GroupID = UUID.Zero;
// And zap any troublesome sit target information // And zap any troublesome sit target information
// part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); // part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
// part.SitTargetPosition = new Vector3(0, 0, 0); // 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; kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
} }
if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
{ {
if (!ResolveUserUuid(kvp.Value.CreatorID)) if (!ResolveUserUuid(kvp.Value.CreatorID))
kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
} }
if (UserManager != null) if (UserManager != null)
UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); 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) foreach (string serialisedParcel in serialisedParcels)
{ {
LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
// Validate User and Group UUID's
if (!ResolveUserUuid(parcel.OwnerID)) if (!ResolveUserUuid(parcel.OwnerID))
parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveGroupUuid(parcel.GroupID))
{
parcel.GroupID = UUID.Zero;
parcel.IsGroupOwned = false;
}
List<LandAccessEntry> accessList = new List<LandAccessEntry>();
foreach (LandAccessEntry entry in parcel.ParcelAccessList)
{
if (ResolveUserUuid(entry.AgentID))
accessList.Add(entry);
// else, drop this access rule
}
parcel.ParcelAccessList = accessList;
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", // "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}",
// parcel.Name, parcel.LocalID, parcel.Area); // parcel.Name, parcel.LocalID, parcel.Area);
@ -401,6 +438,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
/// <summary> /// <summary>
/// Look up the given group id to check whether it's one that is valid for this grid.
/// </summary>
/// <param name="uuid"></param>
/// <returns></returns>
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 /// Load an asset
/// </summary> /// </summary>
/// <param name="assetFilename"></param> /// <param name="assetFilename"></param>