From 2214b2f5783a4015f9fcfba6b2e7265c6bb01020 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 11 Oct 2008 00:39:43 +0000 Subject: Commit Diva's new patch for the DataSnapshot. Comment the default metaverseink search provider to prevent accidental data exposure. --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 50 +++-- OpenSim/Region/DataSnapshot/LandSnapshot.cs | 248 +++++++++++---------- 2 files changed, 157 insertions(+), 141 deletions(-) (limited to 'OpenSim/Region/DataSnapshot') diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 586b665..6af6574 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.DataSnapshot private List m_disabledModules = new List(); private Dictionary m_gridinfo = new Dictionary(); private string m_snapsDir = "DataSnapshot"; + private string m_exposure_level = "minimum"; //Lists of stuff we need private List m_scenes = new List(); @@ -82,6 +83,15 @@ namespace OpenSim.Region.DataSnapshot #endregion + #region Properties + + public string ExposureLevel + { + get { return m_exposure_level; } + } + + #endregion + #region IRegionModule public void Close() {} @@ -92,23 +102,24 @@ namespace OpenSim.Region.DataSnapshot m_configLoaded = true; m_log.Info("[DATASNAPSHOT]: Loading configuration"); //Read from the config for options - lock (m_syncInit) - { - try - { - m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); - if (config.Configs["Startup"].GetBoolean("gridmode", true)) - { - m_gridinfo.Add("gridserverURL", config.Configs["Network"].GetString("grid_server_url", "harbl")); - m_gridinfo.Add("userserverURL", config.Configs["Network"].GetString("user_server_url", "harbl")); - m_gridinfo.Add("assetserverURL", config.Configs["Network"].GetString("asset_server_url", "harbl")); - } - else - { - //Non gridmode stuff - } + lock (m_syncInit) + { + try + { + m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); + if (config.Configs["Startup"].GetBoolean("gridmode", true)) + { + m_gridinfo.Add("gridserverURL", config.Configs["Network"].GetString("grid_server_url", "harbl")); + m_gridinfo.Add("userserverURL", config.Configs["Network"].GetString("user_server_url", "harbl")); + m_gridinfo.Add("assetserverURL", config.Configs["Network"].GetString("asset_server_url", "harbl")); + } + else + { + //Non gridmode stuff + } m_gridinfo.Add("Name", config.Configs["DataSnapshot"].GetString("gridname", "harbl")); + m_exposure_level = config.Configs["DataSnapshot"].GetString("data_exposure", m_exposure_level); m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); @@ -116,10 +127,13 @@ namespace OpenSim.Region.DataSnapshot m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); - foreach (String bloody_wanker in annoying_string_array) { + foreach (String bloody_wanker in annoying_string_array) + { m_disabledModules.Add(bloody_wanker); } - } catch (Exception) { + } + catch (Exception) + { m_log.Info("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); m_enabled = false; return; @@ -147,7 +161,7 @@ namespace OpenSim.Region.DataSnapshot MakeEverythingStale(); - if (m_dataServices != "noservices") + if (m_dataServices != "" && m_dataServices != "noservices") NotifyDataServices(m_dataServices); } } diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs index 562cd8a..e6b8e82 100644 --- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/LandSnapshot.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.DataSnapshot.Providers public class LandSnapshot : IDataSnapshotProvider { private Scene m_scene = null; - // private DataSnapshotManager m_parent = null; + private DataSnapshotManager m_parent = null; //private Dictionary m_landIndexed = new Dictionary(); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_stale = true; @@ -107,7 +107,7 @@ namespace OpenSim.Region.DataSnapshot.Providers public void Initialize(Scene scene, DataSnapshotManager parent) { m_scene = scene; - // m_parent = parent; + m_parent = parent; //Brought back from the dead for staleness checks. m_scene.EventManager.OnNewClient += OnNewClient; @@ -137,135 +137,137 @@ namespace OpenSim.Region.DataSnapshot.Providers LandObject land = (LandObject)parcel_interface; LandData parcel = land.landData; - // if ((parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory) - // { - - //TODO: make better method of marshalling data from LandData to XmlNode - XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); - - // Attributes of the parcel node - XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); - scripts_attr.Value = GetScriptsPermissions(parcel); - XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); - build_attr.Value = GetBuildPermissions(parcel); - XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); - public_attr.Value = GetPublicPermissions(parcel); - // Check the category of the Parcel - XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); - category_attr.Value = ((int)parcel.Category).ToString(); - // Check if the parcel is for sale - XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); - forsale_attr.Value = CheckForSale(parcel); - XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); - sales_attr.Value = parcel.SalePrice.ToString(); - - XmlAttribute directory_attr = nodeFactory.CreateAttribute("show_directory"); - directory_attr.Value = GetShowInSearch(parcel); - //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); - //entities_attr.Value = land.primsOverMe.Count.ToString(); - xmlparcel.Attributes.Append(directory_attr); - xmlparcel.Attributes.Append(scripts_attr); - xmlparcel.Attributes.Append(build_attr); - xmlparcel.Attributes.Append(public_attr); - xmlparcel.Attributes.Append(category_attr); - xmlparcel.Attributes.Append(forsale_attr); - xmlparcel.Attributes.Append(sales_attr); - //xmlparcel.Attributes.Append(entities_attr); - - - //name, description, area, and UUID - XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); - name.InnerText = parcel.Name; - xmlparcel.AppendChild(name); - - XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); - desc.InnerText = parcel.Description; - xmlparcel.AppendChild(desc); - - XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - uuid.InnerText = parcel.GlobalID.ToString(); - xmlparcel.AppendChild(uuid); - - XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); - area.InnerText = parcel.Area.ToString(); - xmlparcel.AppendChild(area); - - //default location - XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); - Vector3 loc = parcel.UserLocation; - if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default - loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); - tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); - xmlparcel.AppendChild(tpLocation); - - XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); - uint x = (uint)loc.X, y = (uint)loc.Y; - findPointInParcel(land, ref x, ref y); // find a suitable spot - infouuid.InnerText = Util.BuildFakeParcelID( - m_scene.RegionInfo.RegionHandle, x, y).ToString(); - xmlparcel.AppendChild(infouuid); - - XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); - dwell.InnerText = "0"; - xmlparcel.AppendChild(dwell); - - //TODO: figure how to figure out teleport system landData.landingType - - //land texture snapshot uuid - if (parcel.SnapshotID != UUID.Zero) + if (m_parent.ExposureLevel.Equals("all") || + (m_parent.ExposureLevel.Equals("minimum") && + (parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory)) { - XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); - textureuuid.InnerText = parcel.SnapshotID.ToString(); - xmlparcel.AppendChild(textureuuid); - } - - //attached user and group - if (parcel.GroupID != UUID.Zero) - { - XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); - XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - groupuuid.InnerText = parcel.GroupID.ToString(); - groupblock.AppendChild(groupuuid); - - //No name yet, there's no way to get a group name since they don't exist yet. - //TODO: When groups are supported, add the group handling code. - xmlparcel.AppendChild(groupblock); - } - - if (!parcel.IsGroupOwned) - { - XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); + //TODO: make better method of marshalling data from LandData to XmlNode + XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); + + // Attributes of the parcel node + XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); + scripts_attr.Value = GetScriptsPermissions(parcel); + XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); + build_attr.Value = GetBuildPermissions(parcel); + XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); + public_attr.Value = GetPublicPermissions(parcel); + // Check the category of the Parcel + XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); + category_attr.Value = ((int)parcel.Category).ToString(); + // Check if the parcel is for sale + XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); + forsale_attr.Value = CheckForSale(parcel); + XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); + sales_attr.Value = parcel.SalePrice.ToString(); + + XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch"); + directory_attr.Value = GetShowInSearch(parcel); + //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); + //entities_attr.Value = land.primsOverMe.Count.ToString(); + xmlparcel.Attributes.Append(directory_attr); + xmlparcel.Attributes.Append(scripts_attr); + xmlparcel.Attributes.Append(build_attr); + xmlparcel.Attributes.Append(public_attr); + xmlparcel.Attributes.Append(category_attr); + xmlparcel.Attributes.Append(forsale_attr); + xmlparcel.Attributes.Append(sales_attr); + //xmlparcel.Attributes.Append(entities_attr); + + + //name, description, area, and UUID + XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); + name.InnerText = parcel.Name; + xmlparcel.AppendChild(name); + + XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); + desc.InnerText = parcel.Description; + xmlparcel.AppendChild(desc); + + XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + uuid.InnerText = parcel.GlobalID.ToString(); + xmlparcel.AppendChild(uuid); + + XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); + area.InnerText = parcel.Area.ToString(); + xmlparcel.AppendChild(area); + + //default location + XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); + Vector3 loc = parcel.UserLocation; + if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default + loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); + tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); + xmlparcel.AppendChild(tpLocation); + + XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); + uint x = (uint)loc.X, y = (uint)loc.Y; + findPointInParcel(land, ref x, ref y); // find a suitable spot + infouuid.InnerText = Util.BuildFakeParcelID( + m_scene.RegionInfo.RegionHandle, x, y).ToString(); + xmlparcel.AppendChild(infouuid); + + XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); + dwell.InnerText = "0"; + xmlparcel.AppendChild(dwell); + + //TODO: figure how to figure out teleport system landData.landingType + + //land texture snapshot uuid + if (parcel.SnapshotID != UUID.Zero) + { + XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); + textureuuid.InnerText = parcel.SnapshotID.ToString(); + xmlparcel.AppendChild(textureuuid); + } - UUID userOwnerUUID = parcel.OwnerID; + //attached user and group + if (parcel.GroupID != UUID.Zero) + { + XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); + XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + groupuuid.InnerText = parcel.GroupID.ToString(); + groupblock.AppendChild(groupuuid); - XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - useruuid.InnerText = userOwnerUUID.ToString(); - userblock.AppendChild(useruuid); + //No name yet, there's no way to get a group name since they don't exist yet. + //TODO: When groups are supported, add the group handling code. - try - { - XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); - CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userOwnerUUID); - username.InnerText = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; - userblock.AppendChild(username); + xmlparcel.AppendChild(groupblock); } - catch (Exception) + + if (!parcel.IsGroupOwned) { - //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); + XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); + + UUID userOwnerUUID = parcel.OwnerID; + + XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + useruuid.InnerText = userOwnerUUID.ToString(); + userblock.AppendChild(useruuid); + + try + { + XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); + CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userOwnerUUID); + username.InnerText = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; + userblock.AppendChild(username); + } + catch (Exception) + { + //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); + } + + xmlparcel.AppendChild(userblock); } - - xmlparcel.AppendChild(userblock); + //else + //{ + // XmlAttribute type = (XmlAttribute)nodeFactory.CreateNode(XmlNodeType.Attribute, "type", ""); + // type.InnerText = "owner"; + // groupblock.Attributes.Append(type); + //} + + parent.AppendChild(xmlparcel); } - //else - //{ - // XmlAttribute type = (XmlAttribute)nodeFactory.CreateNode(XmlNodeType.Attribute, "type", ""); - // type.InnerText = "owner"; - // groupblock.Attributes.Append(type); - //} - - parent.AppendChild(xmlparcel); - // } } //snap.AppendChild(parent); } @@ -378,7 +380,7 @@ namespace OpenSim.Region.DataSnapshot.Providers // another, smaller rectangular parcel). Both will have the same initial coordinates. private void findPointInParcel(ILandObject land, ref uint refX, ref uint refY) { - m_log.DebugFormat("[LAND] trying {0}, {1}", refX, refY); + m_log.DebugFormat("[DATASNAPSHOT] trying {0}, {1}", refX, refY); // the point we started with already is in the parcel if (land.containsPoint((int)refX, (int)refY)) return; -- cgit v1.1