Thank you kindly, StrawberryFride for a patch that:

Enable users to enable only selected methods out of the 
available set of remote methods to restrict remote 
functionality to less harmful methods, such as 
admin_broadcast, or admin_region_query.
0.6.2-post-fixes
Charles Krinke 2009-01-10 04:16:06 +00:00
parent 3bdd4db3fd
commit 5e87e49570
1 changed files with 60 additions and 39 deletions

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Terrain;
using OpenSim.Region.Environment.Scenes;
using System.Collections.Generic;
namespace OpenSim.ApplicationPlugins.RemoteController
{
@ -86,22 +87,42 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_app = openSim;
m_httpd = openSim.HttpServer;
m_httpd.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod, false);
m_httpd.AddXmlRPCHandler("admin_delete_region", XmlRpcDeleteRegionMethod, false);
m_httpd.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod, false);
m_httpd.AddXmlRPCHandler("admin_broadcast", XmlRpcAlertMethod, false);
m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod, false);
m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod, false);
m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod, false);
//This handler creates a user with a email,
m_httpd.AddXmlRPCHandler("admin_create_user_email", XmlRpcCreateUserMethodEmail, false);
m_httpd.AddXmlRPCHandler("admin_exists_user", XmlRpcUserExistsMethod, false);
m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod, false);
m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod, false);
m_httpd.AddXmlRPCHandler("admin_save_xml", XmlRpcSaveXMLMethod, false);
m_httpd.AddXmlRPCHandler("admin_load_oar", XmlRpcLoadOARMethod, false);
m_httpd.AddXmlRPCHandler("admin_save_oar", XmlRpcSaveOARMethod, false);
m_httpd.AddXmlRPCHandler("admin_region_query", XmlRpcRegionQueryMethod, false);
Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>();
availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod;
availableMethods["admin_delete_region"] = XmlRpcDeleteRegionMethod;
availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
availableMethods["admin_restart"] = XmlRpcRestartMethod;
availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
availableMethods["admin_create_user"] = XmlRpcCreateUserMethod;
availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethodEmail;
availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod;
availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod;
availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod;
availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod;
availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod;
availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod;
availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
// Either enable full remote functionality or just selected features
string enabledMethods = m_config.GetString("enabled_methods", "all");
// The assumption here is that simply enabling Remote Admin as before will produce the same
// behavior - enable all methods unless the whitelist is in place for backward-compatibility.
if (enabledMethods.ToLower() == "all" || String.IsNullOrEmpty(enabledMethods))
{
foreach (string method in availableMethods.Keys)
{
m_httpd.AddXmlRPCHandler(method, availableMethods[method]);
}
}
else
{
foreach (string enabledMethod in enabledMethods.Split('|'))
{
m_httpd.AddXmlRPCHandler(enabledMethod, availableMethods[enabledMethod]);
}
}
}
}
catch (NullReferenceException)
@ -1354,10 +1375,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
m_log.InfoFormat("[RADMIN] SaveXml: {0}", e.Message);
m_log.DebugFormat("[RADMIN] SaveXml: {0}", e.ToString());
responseData["loaded"] = "false";
responseData["saved"] = "false";
responseData["switched"] = "false";
responseData["error"] = e.Message;