aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authormingchen2008-07-25 02:30:07 +0000
committermingchen2008-07-25 02:30:07 +0000
commitf2742fb6043c6b7332afd026d77a29b25369934c (patch)
tree895f906ba9db30b27117e6f0d7af40e063204e8e /OpenSim
parentllApplyImpulse now accepts any non-zero integer as not FALSE (diff)
downloadopensim-SC-f2742fb6043c6b7332afd026d77a29b25369934c.zip
opensim-SC-f2742fb6043c6b7332afd026d77a29b25369934c.tar.gz
opensim-SC-f2742fb6043c6b7332afd026d77a29b25369934c.tar.bz2
opensim-SC-f2742fb6043c6b7332afd026d77a29b25369934c.tar.xz
*Added CommandIntentions that is used to describe a console commands hazard. HAZARDOUS if it modifies the simulator, NON_HAZARDOUS if it does a command that doesn't modify the simulator but does a background command such as a forced backup, and STATISTICAL if it returns debug or more information.
*This is useful for implementing a protection system from unwanted script execution or for application modules needing to know what a command does.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Interfaces/ICommand.cs9
-rw-r--r--OpenSim/Region/Environment/Interfaces/ICommander.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs24
7 files changed, 36 insertions, 18 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ICommand.cs b/OpenSim/Region/Environment/Interfaces/ICommand.cs
index 4eeb16c..c1da2c3 100644
--- a/OpenSim/Region/Environment/Interfaces/ICommand.cs
+++ b/OpenSim/Region/Environment/Interfaces/ICommand.cs
@@ -29,12 +29,21 @@ using System.Collections.Generic;
29 29
30namespace OpenSim.Region.Environment.Interfaces 30namespace OpenSim.Region.Environment.Interfaces
31{ 31{
32 public enum CommandIntentions
33 {
34 COMMAND_STATISTICAL,
35 COMMAND_NON_HAZARDOUS,
36 COMMAND_HAZARDOUS
37 };
38
32 public interface ICommand 39 public interface ICommand
33 { 40 {
34 void AddArgument(string name, string helptext, string type); 41 void AddArgument(string name, string helptext, string type);
35 Dictionary<string, string> Arguments { get; } 42 Dictionary<string, string> Arguments { get; }
36 string Help { get; } 43 string Help { get; }
37 string Name { get; } 44 string Name { get; }
45 CommandIntentions Intentions { get; }
46
38 void Run(object[] args); 47 void Run(object[] args);
39 void ShowConsoleHelp(); 48 void ShowConsoleHelp();
40 } 49 }
diff --git a/OpenSim/Region/Environment/Interfaces/ICommander.cs b/OpenSim/Region/Environment/Interfaces/ICommander.cs
index c4102af..f2260c3 100644
--- a/OpenSim/Region/Environment/Interfaces/ICommander.cs
+++ b/OpenSim/Region/Environment/Interfaces/ICommander.cs
@@ -27,6 +27,8 @@
27 27
28namespace OpenSim.Region.Environment.Interfaces 28namespace OpenSim.Region.Environment.Interfaces
29{ 29{
30
31
30 public interface ICommander 32 public interface ICommander
31 { 33 {
32 void ProcessConsoleCommand(string function, string[] args); 34 void ProcessConsoleCommand(string function, string[] args);
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
index 84487e8..82f18a1 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
@@ -47,12 +47,14 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
47 private Action<object[]> m_command; 47 private Action<object[]> m_command;
48 private string m_help; 48 private string m_help;
49 private string m_name; 49 private string m_name;
50 private CommandIntentions m_intentions; //A permission type system could implement this and know what a command intends on doing.
50 51
51 public Command(string name, Action<Object[]> command, string help) 52 public Command(string name, CommandIntentions intention, Action<Object[]> command, string help)
52 { 53 {
53 m_name = name; 54 m_name = name;
54 m_command = command; 55 m_command = command;
55 m_help = help; 56 m_help = help;
57 m_intentions = intention;
56 } 58 }
57 59
58 #region ICommand Members 60 #region ICommand Members
@@ -67,6 +69,11 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
67 get { return m_name; } 69 get { return m_name; }
68 } 70 }
69 71
72 public CommandIntentions Intentions
73 {
74 get { return m_intentions; }
75 }
76
70 public string Help 77 public string Help
71 { 78 {
72 get { return m_help; } 79 get { return m_help; }
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
index 8d1371c..c569240 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
56 56
57 public void PostInitialise() 57 public void PostInitialise()
58 { 58 {
59 Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); 59 Command testCommand = new Command("hello", CommandIntentions.COMMAND_STATISTICAL, InterfaceHelloWorld, "Says a simple debugging test string");
60 testCommand.AddArgument("world", "Write world here", "string"); 60 testCommand.AddArgument("world", "Write world here", "string");
61 61
62 m_commander.RegisterCommand("hello", testCommand); 62 m_commander.RegisterCommand("hello", testCommand);
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index 23db484..f9a0bdb 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -182,13 +182,13 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
182 182
183 183
184 //Register Debug Commands 184 //Register Debug Commands
185 Command bypassCommand = new Command("bypass", InterfaceBypassPermissions, "Force the permissions a specific way to test permissions"); 185 Command bypassCommand = new Command("bypass", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBypassPermissions, "Force the permissions a specific way to test permissions");
186 bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean"); 186 bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean");
187 bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean"); 187 bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean");
188 188
189 m_commander.RegisterCommand("bypass", bypassCommand); 189 m_commander.RegisterCommand("bypass", bypassCommand);
190 190
191 Command debugCommand = new Command("debug", InterfaceDebugPermissions, "Force the permissions a specific way to test permissions"); 191 Command debugCommand = new Command("debug", CommandIntentions.COMMAND_STATISTICAL, InterfaceDebugPermissions, "Force the permissions a specific way to test permissions");
192 debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean"); 192 debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
193 193
194 m_commander.RegisterCommand("debug", debugCommand); 194 m_commander.RegisterCommand("debug", debugCommand);
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index cefd15f..ce59ecc 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -199,10 +199,10 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
199 199
200 private void LoadCommanderCommands() 200 private void LoadCommanderCommands()
201 { 201 {
202 Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); 202 Command serialiseSceneCommand = new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveRegion, "Saves the named region into the exports directory.");
203 serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); 203 serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String");
204 204
205 Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); 205 Command serialiseAllScenesCommand = new Command("save-all",CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveAllRegions, "Saves all regions into the exports directory.");
206 206
207 m_commander.RegisterCommand("save", serialiseSceneCommand); 207 m_commander.RegisterCommand("save", serialiseSceneCommand);
208 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); 208 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index 9892794..8fbc62e 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -804,19 +804,19 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
804 supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; 804 supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")";
805 805
806 Command loadFromFileCommand = 806 Command loadFromFileCommand =
807 new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); 807 new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file.");
808 loadFromFileCommand.AddArgument("filename", 808 loadFromFileCommand.AddArgument("filename",
809 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + 809 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
810 supportedFileExtensions, "String"); 810 supportedFileExtensions, "String");
811 811
812 Command saveToFileCommand = 812 Command saveToFileCommand =
813 new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); 813 new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveFile, "Saves the current heightmap to a specified file.");
814 saveToFileCommand.AddArgument("filename", 814 saveToFileCommand.AddArgument("filename",
815 "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + 815 "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " +
816 supportedFileExtensions, "String"); 816 supportedFileExtensions, "String");
817 817
818 Command loadFromTileCommand = 818 Command loadFromTileCommand =
819 new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); 819 new Command("load-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
820 loadFromTileCommand.AddArgument("filename", 820 loadFromTileCommand.AddArgument("filename",
821 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + 821 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
822 supportedFileExtensions, "String"); 822 supportedFileExtensions, "String");
@@ -829,40 +829,40 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
829 829
830 // Terrain adjustments 830 // Terrain adjustments
831 Command fillRegionCommand = 831 Command fillRegionCommand =
832 new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); 832 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
833 fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", 833 fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.",
834 "Double"); 834 "Double");
835 835
836 Command elevateCommand = 836 Command elevateCommand =
837 new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); 837 new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount.");
838 elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); 838 elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double");
839 839
840 Command lowerCommand = 840 Command lowerCommand =
841 new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); 841 new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount.");
842 lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); 842 lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double");
843 843
844 Command multiplyCommand = 844 Command multiplyCommand =
845 new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); 845 new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified.");
846 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); 846 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
847 847
848 Command bakeRegionCommand = 848 Command bakeRegionCommand =
849 new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); 849 new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions revert map.");
850 Command revertRegionCommand = 850 Command revertRegionCommand =
851 new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); 851 new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap.");
852 852
853 // Debug 853 // Debug
854 Command showDebugStatsCommand = 854 Command showDebugStatsCommand =
855 new Command("stats", InterfaceShowDebugStats, 855 new Command("stats", CommandIntentions.COMMAND_STATISTICAL, InterfaceShowDebugStats,
856 "Shows some information about the regions heightmap for debugging purposes."); 856 "Shows some information about the regions heightmap for debugging purposes.");
857 857
858 Command experimentalBrushesCommand = 858 Command experimentalBrushesCommand =
859 new Command("newbrushes", InterfaceEnableExperimentalBrushes, 859 new Command("newbrushes", CommandIntentions.COMMAND_HAZARDOUS, InterfaceEnableExperimentalBrushes,
860 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); 860 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
861 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); 861 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
862 862
863 //Plugins 863 //Plugins
864 Command pluginRunCommand = 864 Command pluginRunCommand =
865 new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); 865 new Command("effect", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRunPluginEffect, "Runs a specified plugin effect");
866 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); 866 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
867 867
868 m_commander.RegisterCommand("load", loadFromFileCommand); 868 m_commander.RegisterCommand("load", loadFromFileCommand);