aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorMelanie Thielker2009-02-07 12:25:39 +0000
committerMelanie Thielker2009-02-07 12:25:39 +0000
commit54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a (patch)
treef606cbdbc383ec21fee28f0a1454140a1c714278 /OpenSim/Region/Environment
parentThank you dslake for a patch that: (diff)
downloadopensim-SC_OLD-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.zip
opensim-SC_OLD-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.gz
opensim-SC_OLD-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.bz2
opensim-SC_OLD-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.xz
Replace the console for all OpenSim apps with a new console featuring command
line editing, context sensitive help (press ? at any time), command line history, a new plugin command system and new appender features thet let you type while the console is scrolling. Seamlessly integrates the ICommander interfaces.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs148
2 files changed, 93 insertions, 67 deletions
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs
index 0ad95ae..b6114e8 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs
@@ -88,6 +88,18 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
88 } 88 }
89 } 89 }
90 90
91 public string ShortHelp()
92 {
93 string help = m_name;
94
95 foreach (CommandArgument arg in m_args)
96 {
97 help += " <" + arg.Name + ">";
98 }
99
100 return help;
101 }
102
91 public void ShowConsoleHelp() 103 public void ShowConsoleHelp()
92 { 104 {
93 Console.WriteLine("== " + Name + " =="); 105 Console.WriteLine("== " + Name + " ==");
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index 060a4f4..e48ef13 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -32,21 +32,20 @@ using System.Collections;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using System.Reflection; 33using System.Reflection;
34using log4net; 34using log4net;
35using OpenSim;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.Environment.Modules.Framework; 39using OpenSim.Region.Environment.Modules.Framework;
39using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander;
40using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
41 41
42namespace OpenSim.Region.Environment.Modules.World.Permissions 42namespace OpenSim.Region.Environment.Modules.World.Permissions
43{ 43{
44 public class PermissionsModule : IRegionModule, ICommandableModule 44 public class PermissionsModule : IRegionModule
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 protected Scene m_scene; 48 protected Scene m_scene;
49 private readonly Commander m_commander = new Commander("permissions");
50 49
51 #region Constants 50 #region Constants
52 // These are here for testing. They will be taken out 51 // These are here for testing. They will be taken out
@@ -94,60 +93,6 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
94 93
95 #endregion 94 #endregion
96 95
97 #region ICommandableModule Members
98
99 public ICommander CommandInterface
100 {
101 get { throw new System.NotImplementedException(); }
102 }
103
104 private void InterfaceDebugPermissions(Object[] args)
105 {
106 if ((bool)args[0] == true)
107 {
108 m_debugPermissions = true;
109 m_log.Info("[PERMISSIONS]: Permissions Debugging Enabled.");
110 }
111 else
112 {
113 m_debugPermissions = false;
114 m_log.Info("[PERMISSIONS]: Permissions Debugging Disabled.");
115 }
116 }
117
118 private void InterfaceBypassPermissions(Object[] args)
119 {
120 if ((bool)args[0] == true)
121 {
122 m_log.Info("[PERMISSIONS]: Permissions Bypass Enabled.");
123 m_bypassPermissionsValue = (bool)args[1];
124 }
125 else
126 {
127 m_bypassPermissions = false;
128 m_log.Info("[PERMISSIONS]: Permissions Bypass Disabled. Normal Operation.");
129 }
130 }
131
132 /// <summary>
133 /// Processes commandline input. Do not call directly.
134 /// </summary>
135 /// <param name="args">Commandline arguments</param>
136 private void EventManager_OnPluginConsole(string[] args)
137 {
138 if (args[0] == "permissions")
139 {
140 string[] tmpArgs = new string[args.Length - 2];
141 int i;
142 for (i = 2; i < args.Length; i++)
143 tmpArgs[i - 2] = args[i];
144
145 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
146 }
147 }
148
149 #endregion
150
151 #region IRegionModule Members 96 #region IRegionModule Members
152 97
153 public void Initialise(Scene scene, IConfigSource config) 98 public void Initialise(Scene scene, IConfigSource config)
@@ -226,20 +171,89 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
226 171
227 m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED 172 m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED
228 173
229 //Register Debug Commands 174 m_scene.AddCommand("permissions", "bypass permissions",
230 Command bypassCommand = new Command("bypass", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBypassPermissions, "Force the permissions a specific way to test permissions"); 175 "bypass permissions <true / false>",
231 bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean"); 176 "Bypass permission checks",
232 bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean"); 177 HandleBypassPermissions);
178
179 m_scene.AddCommand("permissions", "force permissions",
180 "force permissions <true / false>",
181 "Force permissions on or off",
182 HandleForcePermissions);
183
184 m_scene.AddCommand("permissions", "debug permissions",
185 "debug permissions <true / false>",
186 "Enable permissions debugging",
187 HandleDebugPermissions);
188 }
189
190 public void HandleBypassPermissions(string module, string[] args)
191 {
192 if (m_scene.ConsoleScene() != null &&
193 m_scene.ConsoleScene() != m_scene)
194 {
195 return;
196 }
197
198 if (args.Length > 2)
199 {
200 bool val;
201
202 if (!bool.TryParse(args[2], out val))
203 return;
204
205 m_bypassPermissions = val;
206
207 m_log.InfoFormat("[PERMISSIONS] Set permissions bypass to {0} for {1}", m_bypassPermissions, m_scene.RegionInfo.RegionName);
208 }
209 }
210
211 public void HandleForcePermissions(string module, string[] args)
212 {
213 if (m_scene.ConsoleScene() != null &&
214 m_scene.ConsoleScene() != m_scene)
215 {
216 return;
217 }
218
219 if (!m_bypassPermissions)
220 {
221 m_log.Error("[PERMISSIONS] Permissions can't be forced unless they are bypassed first");
222 return;
223 }
233 224
234 m_commander.RegisterCommand("bypass", bypassCommand); 225 if (args.Length > 2)
226 {
227 bool val;
235 228
236 Command debugCommand = new Command("debug", CommandIntentions.COMMAND_STATISTICAL, InterfaceDebugPermissions, "Force the permissions a specific way to test permissions"); 229 if (!bool.TryParse(args[2], out val))
237 debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean"); 230 return;
238 231
239 m_commander.RegisterCommand("debug", debugCommand); 232 m_bypassPermissionsValue = val;
240 m_scene.RegisterModuleCommander(m_commander);
241 233
242 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); 234 m_log.InfoFormat("[PERMISSIONS] Forced permissions to {0} in {1}", m_bypassPermissionsValue, m_scene.RegionInfo.RegionName);
235 }
236 }
237
238 public void HandleDebugPermissions(string module, string[] args)
239 {
240 if (m_scene.ConsoleScene() != null &&
241 m_scene.ConsoleScene() != m_scene)
242 {
243 return;
244 }
245
246 if (args.Length > 2)
247 {
248 bool val;
249
250 if (!bool.TryParse(args[2], out val))
251 return;
252
253 m_debugPermissions = val;
254
255 m_log.InfoFormat("[PERMISSIONS] Set permissions debugging to {0} in {1}", m_debugPermissions, m_scene.RegionInfo.RegionName);
256 }
243 } 257 }
244 258
245 public void PostInitialise() 259 public void PostInitialise()