From d24e4a9f2d860db87ca191242861453547f82e65 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 5 Dec 2008 20:30:00 +0000 Subject: [PATCH] Committing the missing bits to enable script crossing. Disabled by default. For a script to successfully cross, both source and destination region must enable the feature. WARNING: Trusting binaries from other sims allows ARBITRARY REMOTE CODE EXECUTION for ANYONE! Please do not use except in ultimate trust scenarios! --- OpenSim/Region/Environment/Scenes/Scene.cs | 81 ++++++++++++++++++- .../Scenes/SceneObjectPartInventory.cs | 1 + 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 7e13671044..79a626e0cc 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2098,9 +2098,16 @@ namespace OpenSim.Region.Environment.Scenes if (newRegionHandle != 0) { + string objectState = grp.GetStateSnapshot(); + successYN = m_sceneGridService.PrimCrossToNeighboringRegion( newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); + if (successYN && (objectState != "") && m_allowScriptCrossings) + { + successYN = m_sceneGridService.PrimCrossToNeighboringRegion( + newRegionHandle, grp.UUID, objectState, 100); + } if (successYN) { @@ -2147,10 +2154,10 @@ namespace OpenSim.Region.Environment.Scenes /// public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod) { - m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); if (XMLMethod == 0) { + m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); // If the user is banned, we won't let any of their objects @@ -2242,6 +2249,78 @@ namespace OpenSim.Region.Environment.Scenes } } } + else if ((XMLMethod == 100) && m_allowScriptCrossings) + { + m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); + XmlDocument doc = new XmlDocument(); + doc.LoadXml(objXMLData); + + XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); + if (rootL.Count == 1) + { + XmlNode rootNode = rootL[0]; + if (rootNode != null) + { + XmlNodeList partL = rootNode.ChildNodes; + + foreach (XmlNode part in partL) + { + XmlNodeList nodeL = part.ChildNodes; + + switch (part.Name) + { + case "Assemblies": + foreach (XmlNode asm in nodeL) + { + string fn = asm.Attributes.GetNamedItem("Filename").Value; + + Byte[] filedata = Convert.FromBase64String(asm.InnerText); + string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); + path = Path.Combine(path, fn); + + if (!File.Exists(path)) + { + FileStream fs = File.Create(path); + fs.Write(filedata, 0, filedata.Length); + fs.Close(); + } + } + break; + case "ScriptStates": + foreach (XmlNode st in nodeL) + { + string id = st.Attributes.GetNamedItem("UUID").Value; + UUID uuid = new UUID(id); + XmlNode state = st.ChildNodes[0]; + + XmlDocument sdoc = new XmlDocument(); + XmlNode sxmlnode = sdoc.CreateNode( + XmlNodeType.XmlDeclaration, + "", ""); + sdoc.AppendChild(sxmlnode); + + XmlNode newnode = sdoc.ImportNode(state, true); + sdoc.AppendChild(newnode); + + string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); + spath = Path.Combine(spath, uuid.ToString()); + FileStream sfs = File.Create(spath + ".state"); + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + Byte[] buf = enc.GetBytes(sdoc.InnerXml); + sfs.Write(buf, 0, buf.Length); + sfs.Close(); + } + break; + } + } + } + } + + SceneObjectPart RootPrim = GetSceneObjectPart(primID); + RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); + + return true; + } return true; } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs index 545d603814..8137a5359d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs @@ -250,6 +250,7 @@ namespace OpenSim.Region.Environment.Scenes m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); + return; } AssetCache cache = m_part.ParentGroup.Scene.AssetCache;