aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
authorMelanie Thielker2009-04-15 19:50:14 +0000
committerMelanie Thielker2009-04-15 19:50:14 +0000
commit03baa077fbc79bfdec41bc4c846273412e8d5c04 (patch)
tree1d0a8003bbf3ab8e27de8d8e638b5e311e6bba92 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
parentminor: Remove some mono compiler warnings. Uncomment code when it's actually... (diff)
downloadopensim-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.cs47
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;
36using Nini.Config; 36using Nini.Config;
37using Nwc.XmlRpc; 37using Nwc.XmlRpc;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenSim;
39using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
41using OpenSim.Region.CoreModules.World.Terrain; 43using OpenSim.Region.CoreModules.World.Terrain;
42using OpenSim.Region.Framework.Interfaces; 44using 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 }