diff options
author | Melanie Thielker | 2009-04-15 19:50:14 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-04-15 19:50:14 +0000 |
commit | 03baa077fbc79bfdec41bc4c846273412e8d5c04 (patch) | |
tree | 1d0a8003bbf3ab8e27de8d8e638b5e311e6bba92 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |
parent | minor: Remove some mono compiler warnings. Uncomment code when it's actually... (diff) | |
download | opensim-SC-03baa077fbc79bfdec41bc4c846273412e8d5c04.zip opensim-SC-03baa077fbc79bfdec41bc4c846273412e8d5c04.tar.gz opensim-SC-03baa077fbc79bfdec41bc4c846273412e8d5c04.tar.bz2 opensim-SC-03baa077fbc79bfdec41bc4c846273412e8d5c04.tar.xz |
Add a console command facility to the RemoteAdmin plugin.
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 329a489..1a6deca 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -36,7 +36,9 @@ using log4net; | |||
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using Nwc.XmlRpc; | 37 | using Nwc.XmlRpc; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenSim; | ||
39 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
41 | using OpenSim.Region.CoreModules.World.Terrain; | 43 | using OpenSim.Region.CoreModules.World.Terrain; |
42 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
@@ -116,6 +118,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
116 | // Either enable full remote functionality or just selected features | 118 | // Either enable full remote functionality or just selected features |
117 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 119 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
118 | 120 | ||
121 | // To get this, you must explicitly specify "all" or | ||
122 | // mention it in a whitelist. It won't be available | ||
123 | // If you just leave the option out! | ||
124 | // | ||
125 | if (!String.IsNullOrEmpty(enabledMethods)) | ||
126 | availableMethods["admin_console_command"] = XmlRpcConsoleCommandMethod; | ||
127 | |||
119 | // The assumption here is that simply enabling Remote Admin as before will produce the same | 128 | // The assumption here is that simply enabling Remote Admin as before will produce the same |
120 | // behavior - enable all methods unless the whitelist is in place for backward-compatibility. | 129 | // behavior - enable all methods unless the whitelist is in place for backward-compatibility. |
121 | if (enabledMethods.ToLower() == "all" || String.IsNullOrEmpty(enabledMethods)) | 130 | if (enabledMethods.ToLower() == "all" || String.IsNullOrEmpty(enabledMethods)) |
@@ -1441,6 +1450,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1441 | return response; | 1450 | return response; |
1442 | } | 1451 | } |
1443 | 1452 | ||
1453 | public XmlRpcResponse XmlRpcConsoleCommandMethod(XmlRpcRequest request) | ||
1454 | { | ||
1455 | m_log.Info("[RADMIN]: Received Command XML Administrator Request"); | ||
1456 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1457 | Hashtable responseData = new Hashtable(); | ||
1458 | |||
1459 | try | ||
1460 | { | ||
1461 | responseData["success"] = "true"; | ||
1462 | |||
1463 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1464 | |||
1465 | // check completeness | ||
1466 | if (!requestData.Contains("password")) | ||
1467 | throw new Exception(String.Format("missing required parameter")); | ||
1468 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
1469 | (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
1470 | |||
1471 | if (!requestData.Contains("command")) | ||
1472 | throw new Exception(String.Format("missing required parameter")); | ||
1473 | MainConsole.Instance.RunCommand(requestData["command"].ToString()); | ||
1474 | |||
1475 | response.Value = responseData; | ||
1476 | } | ||
1477 | catch (Exception e) | ||
1478 | { | ||
1479 | m_log.InfoFormat("[RADMIN] ConsoleCommand: {0}", e.Message); | ||
1480 | |||
1481 | responseData["success"] = "false"; | ||
1482 | responseData["error"] = e.Message; | ||
1483 | |||
1484 | response.Value = responseData; | ||
1485 | } | ||
1486 | |||
1487 | m_log.Info("[RADMIN]: Command XML Administrator Request complete"); | ||
1488 | return response; | ||
1489 | } | ||
1490 | |||
1444 | public void Dispose() | 1491 | public void Dispose() |
1445 | { | 1492 | { |
1446 | } | 1493 | } |