diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs | 148 |
1 files changed, 81 insertions, 67 deletions
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; | |||
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using log4net; | 34 | using log4net; |
35 | using OpenSim; | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Region.Environment.Modules.Framework; | 39 | using OpenSim.Region.Environment.Modules.Framework; |
39 | using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; | ||
40 | using OpenSim.Framework.Communications.Cache; | 40 | using OpenSim.Framework.Communications.Cache; |
41 | 41 | ||
42 | namespace OpenSim.Region.Environment.Modules.World.Permissions | 42 | namespace 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() |