From 169e176f47b66b6c5235f7bcaa9cb15b9117fa2b Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 21 Dec 2007 03:34:51 +0000 Subject: *RemoteAdminPlugin can now be password protected. Add the password in the INI under [RemoteAdmin] with the name access_password *Removed a few more unneeded exceptions in land that has been fixed --- .../RemoteController/RemoteAdminPlugin.cs | 171 ++++++++++++--------- OpenSim/Region/Environment/LandManagement/Land.cs | 4 +- 2 files changed, 103 insertions(+), 72 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 8122b8a..9ae1a7b 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -53,7 +53,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions { private OpenSimMain m_app; private BaseHttpServer m_httpd; - + private string requiredPassword = ""; public void Initialise(OpenSimMain openSim) { try @@ -61,6 +61,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions if (openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false)) { MainLog.Instance.Verbose("RADMIN", "Remote Admin Plugin Enabled"); + requiredPassword = openSim.ConfigSource.Configs["RemoteAdmin"].GetString("access_password", ""); m_app = openSim; m_httpd = openSim.HttpServer; @@ -85,19 +86,27 @@ namespace OpenSim.ApplicationPlugins.LoadRegions LLUUID regionID = new LLUUID((string)requestData["regionID"]); Hashtable responseData = new Hashtable(); - responseData["accepted"] = "true"; - response.Value = responseData; - - OpenSim.Region.Environment.Scenes.Scene RebootedScene; - - if (m_app.SceneManager.TryGetScene(regionID, out RebootedScene)) + if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) { - responseData["rebooting"] = "true"; - RebootedScene.Restart(30); + responseData["accepted"] = "false"; + response.Value = responseData; } else { - responseData["rebooting"] = "false"; + responseData["accepted"] = "true"; + response.Value = responseData; + + OpenSim.Region.Environment.Scenes.Scene RebootedScene; + + if (m_app.SceneManager.TryGetScene(regionID, out RebootedScene)) + { + responseData["rebooting"] = "true"; + RebootedScene.Restart(30); + } + else + { + responseData["rebooting"] = "false"; + } } return response; @@ -108,14 +117,23 @@ namespace OpenSim.ApplicationPlugins.LoadRegions XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; - string message = (string)requestData["message"]; - MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message); - Hashtable responseData = new Hashtable(); - responseData["accepted"] = "true"; - response.Value = responseData; + if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + { + responseData["accepted"] = "false"; + response.Value = responseData; + } + else + { + + string message = (string)requestData["message"]; + MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message); + + responseData["accepted"] = "true"; + response.Value = responseData; - m_app.SceneManager.SendGeneralMessage(message); + m_app.SceneManager.SendGeneralMessage(message); + } return response; } @@ -125,42 +143,49 @@ namespace OpenSim.ApplicationPlugins.LoadRegions MainLog.Instance.Verbose("RADMIN", "Received Shutdown Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; - - if ((string)requestData["shutdown"] == "delayed") + Hashtable responseData = new Hashtable(); + if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) { - int timeout = (Int32)requestData["milliseconds"]; - - Hashtable responseData = new Hashtable(); - responseData["accepted"] = "true"; + responseData["accepted"] = "false"; response.Value = responseData; - - m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() + - " second(s). Please save what you are doing and log out."); - - // Perform shutdown - Timer shutdownTimer = new Timer(timeout); // Wait before firing - shutdownTimer.AutoReset = false; - shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); - shutdownTimer.Start(); - - return response; } else { - Hashtable responseData = new Hashtable(); - responseData["accepted"] = "true"; - response.Value = responseData; + if ((string)requestData["shutdown"] == "delayed") + { + int timeout = (Int32)requestData["milliseconds"]; + + responseData["accepted"] = "true"; + response.Value = responseData; + + m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() + + " second(s). Please save what you are doing and log out."); + + // Perform shutdown + Timer shutdownTimer = new Timer(timeout); // Wait before firing + shutdownTimer.AutoReset = false; + shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); + shutdownTimer.Start(); + + return response; + } + else + { + responseData["accepted"] = "true"; + response.Value = responseData; - m_app.SceneManager.SendGeneralMessage("Region is going down now."); + m_app.SceneManager.SendGeneralMessage("Region is going down now."); - // Perform shutdown - Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing - shutdownTimer.AutoReset = false; - shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); - shutdownTimer.Start(); + // Perform shutdown + Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing + shutdownTimer.AutoReset = false; + shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); + shutdownTimer.Start(); - return response; + return response; + } } + return response; } private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -173,40 +198,46 @@ namespace OpenSim.ApplicationPlugins.LoadRegions MainLog.Instance.Verbose("RADMIN", "Received Create Region Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; - - RegionInfo newRegionData = new RegionInfo(); - - try + Hashtable responseData = new Hashtable(); + if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) { - newRegionData.RegionID = (string)requestData["region_id"]; - newRegionData.RegionName = (string)requestData["region_name"]; - newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]); - newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]); + responseData["created"] = "false"; + response.Value = responseData; + } + else + { + RegionInfo newRegionData = new RegionInfo(); - // Security risk - newRegionData.DataStore = (string)requestData["datastore"]; + try + { + newRegionData.RegionID = (string)requestData["region_id"]; + newRegionData.RegionName = (string)requestData["region_name"]; + newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]); + newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]); - newRegionData.InternalEndPoint = new IPEndPoint( - IPAddress.Parse((string)requestData["listen_ip"]), 0); + // Security risk + newRegionData.DataStore = (string)requestData["datastore"]; - newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"]; - newRegionData.ExternalHostName = (string)requestData["external_address"]; + newRegionData.InternalEndPoint = new IPEndPoint( + IPAddress.Parse((string)requestData["listen_ip"]), 0); - newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"]; - newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"]; + newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"]; + newRegionData.ExternalHostName = (string)requestData["external_address"]; - m_app.CreateRegion(newRegionData); + newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"]; + newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"]; - Hashtable responseData = new Hashtable(); - responseData["created"] = "true"; - response.Value = responseData; - } - catch (Exception e) - { - Hashtable responseData = new Hashtable(); - responseData["created"] = "false"; - responseData["error"] = e.ToString(); - response.Value = responseData; + m_app.CreateRegion(newRegionData); + + responseData["created"] = "true"; + response.Value = responseData; + } + catch (Exception e) + { + responseData["created"] = "false"; + responseData["error"] = e.ToString(); + response.Value = responseData; + } } return response; diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 11ff0ee..7977c78 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -472,7 +472,7 @@ namespace OpenSim.Region.Environment.LandManagement if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) { //Throw an exception - The bitmap is not 64x64 - throw new Exception("Error: Invalid Parcel Bitmap"); + //throw new Exception("Error: Invalid Parcel Bitmap"); } else { @@ -584,7 +584,7 @@ namespace OpenSim.Region.Environment.LandManagement if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) { //Throw an exception - The bitmap is not 64x64 - throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); + //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); } int x, y; -- cgit v1.1