From 62d02e079eff3e6108bc4956e34fe5dd8f5cfcad Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 15 Apr 2008 14:18:37 +0000 Subject: [PATCH] From: dirk husemann attached is a patch set that * adds further robustness checks for the CreateUser and CreateRegion XmlRpc * fixes SceneManager.TryGetScene(IPEndPoint, Scene) --- contrary to my expectation IPEndPoint.Address is not sufficient for a comparision, IPEndPoint.Address.Address (the long representation) does work however. * add [RemoteAdmin] section to OpenSim.ini.example * fixes XML doc comments good night, dirk --- .../RemoteController/RemoteAdminPlugin.cs | 61 ++++++++++++------- .../Region/Environment/Scenes/SceneManager.cs | 6 +- bin/OpenSim.ini.example | 4 ++ 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index f1b3ade9ef..6450ec764d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -234,6 +234,29 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_app.Shutdown(); } + + private void checkStringParameters(XmlRpcRequest request, string[] param) + { + Hashtable requestData = (Hashtable) request.Params[0]; + foreach (string p in param) + { + if (!requestData.Contains(p)) + throw new Exception(String.Format("missing string parameter {0}", p)); + if (String.IsNullOrEmpty((string)requestData[p])) + throw new Exception(String.Format("parameter {0} is empty", p)); + } + } + + private void checkIntegerParams(XmlRpcRequest request, string[] param) + { + Hashtable requestData = (Hashtable) request.Params[0]; + foreach (string p in param) + { + if (!requestData.Contains(p)) + throw new Exception(String.Format("missing integer parameter {0}", p)); + } + } + /// /// Create a new region. /// @@ -250,21 +273,24 @@ namespace OpenSim.ApplicationPlugins.LoadRegions /// region_id /// (optional) desired region UUID /// region_x - /// desired region X coordinate + /// desired region X coordinate (integer) /// region_y - /// desired region Y coordinate + /// desired region Y coordinate (integer) /// region_master_first /// firstname of region master /// region_master_last /// lastname of region master /// listen_ip - /// internal IP address + /// internal IP address (dotted quad) /// listen_port - /// internal port + /// internal port (integer) /// external_address /// external IP address /// datastore /// datastore parameter (?) + /// persist + /// if true, persist the region info + /// ('true' or 'false') /// /// /// XmlRpcCreateRegionMethod returns @@ -288,16 +314,12 @@ namespace OpenSim.ApplicationPlugins.LoadRegions Hashtable responseData = new Hashtable(); try { - // check completeness - foreach (string p in new string[] { "password", - "region_name", "region_x", "region_y", - "region_master_first", "region_master_last", - "region_master_password", - "listen_ip", "listen_port", "external_address"}) - { - if (!requestData.Contains(p)) - throw new Exception(String.Format("missing parameter {0}", p)); - } + checkStringParameters(request, new string[] { "password", + "region_name", + "region_master_first", "region_master_last", + "region_master_password", + "listen_ip", "external_address"}); + checkIntegerParams(request, new string[] { "region_x", "region_y", "listen_port"}); // check password if (!String.IsNullOrEmpty(requiredPassword) && @@ -350,6 +372,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); region.InternalEndPoint.Port = (Int32) requestData["listen_port"]; + if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", region.InternalEndPoint.Address, @@ -445,13 +468,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions try { // check completeness - foreach (string p in new string[] { "password", - "user_firstname", "user_lastname", "user_password", - "start_region_x", "start_region_y" }) - { - if (!requestData.Contains(p)) - throw new Exception(String.Format("missing parameter {0}", p)); - } + checkStringParameters(request, new string[] { "password", "user_firstname", + "user_lastname", "user_password" }); + checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); // check password if (!String.IsNullOrEmpty(requiredPassword) && diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index fbaf655055..42a77dd37e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -297,8 +297,10 @@ namespace OpenSim.Region.Environment.Scenes { foreach (Scene mscene in m_localScenes) { - if (mscene.RegionInfo.InternalEndPoint.Address == ipEndPoint.Address && - mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port) + // .NET WEIRDNESS ALERT: need to compare the long + // values of address... + if ((mscene.RegionInfo.InternalEndPoint.Address.Address == ipEndPoint.Address.Address) && + (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) { scene = mscene; return true; diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 1cca2b5db8..6a0494719e 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -141,6 +141,10 @@ whisper_distance = 10 say_distance = 30 shout_distance = 100 +[RemoteAdmin] +enabled = false +access_password = unknown + ; Uncomment the following for IRC bridge ; experimental, so if it breaks... keep both parts... yada yada ; also, not good error detection when it fails