aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs314
-rw-r--r--bin/OpenSim.ini.example4
2 files changed, 256 insertions, 62 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 5293a26..c834cc8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -40,6 +40,61 @@ using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
40 40
41namespace OpenSim.Region.ScriptEngine.Shared.Api 41namespace OpenSim.Region.ScriptEngine.Shared.Api
42{ 42{
43 //////////////////////////////////////////////////////////////
44 //
45 // Level description
46 //
47 // None - Function is no threat at all. It doesn't constitute
48 // an threat to either users or the system and has no
49 // known side effects
50 //
51 // Nuisance - Abuse of this command can cause a nuisance to the
52 // region operator, such as log message spew
53 //
54 // VeryLow - Extreme levels ob abuse of this function can cause
55 // impaired functioning of the region, or very gullible
56 // users can be tricked into experiencing harmless effects
57 //
58 // Low - Intentional abuse can cause crashes or malfunction
59 // under certain circumstances, which can easily be rectified,
60 // or certain users can be tricked into certain situations
61 // in an avoidable manner.
62 //
63 // Moderate - Intentional abuse can cause denial of service and crashes
64 // with potential of data or state loss, or trusting users
65 // can be tricked into embarrassing or uncomfortable
66 // situationsa.
67 //
68 // High - Casual abuse can cause impaired functionality or temporary
69 // denial of service conditions. Intentional abuse can easily
70 // cause crashes with potential data loss, or can be used to
71 // trick experienced and cautious users into unwanted situations,
72 // or changes global data permanently and without undo ability
73 //
74 // VeryHigh - Even normal use may, depending on the number of instances,
75 // or frequency of use, result in severe service impairment
76 // or crash with loss of data, or can be used to cause
77 // unwanted or harmful effects on users without giving the
78 // user a means to avoid it.
79 //
80 // Severe - Even casual use is a danger to region stability, or function
81 // allows console or OS command execution, or function allows
82 // taking money without consent, or allows deletion or
83 // modification of user data, or allows the compromise of
84 // sensitive data by design.
85
86 public enum ThreatLevel
87 {
88 None = 0,
89 Nuisance = 1,
90 VeryLow = 2,
91 Low = 3,
92 Moderate = 4,
93 High = 5,
94 VeryHigh = 6,
95 Severe = 7
96 };
97
43 [Serializable] 98 [Serializable]
44 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi 99 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
45 { 100 {
@@ -47,7 +102,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
47 internal SceneObjectPart m_host; 102 internal SceneObjectPart m_host;
48 internal uint m_localID; 103 internal uint m_localID;
49 internal UUID m_itemID; 104 internal UUID m_itemID;
50 internal AsyncCommandManager AsyncCommands = null; 105 internal bool m_OSFunctionsEnabled = false;
106 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
51 internal float m_ScriptDelayFactor = 1.0f; 107 internal float m_ScriptDelayFactor = 1.0f;
52 internal float m_ScriptDistanceFactor = 1.0f; 108 internal float m_ScriptDistanceFactor = 1.0f;
53 109
@@ -58,16 +114,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
58 m_localID = localID; 114 m_localID = localID;
59 m_itemID = itemID; 115 m_itemID = itemID;
60 116
61 IConfigSource config = new IniConfigSource(Application.iniFilePath); 117 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
62 if (config.Configs["XEngine"] == null) 118 m_OSFunctionsEnabled = true;
63 config.AddConfig("XEngine"); 119
64 120 m_ScriptDelayFactor =
65 m_ScriptDelayFactor = config.Configs["XEngine"]. 121 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
66 GetFloat("ScriptDelayFactor", 1.0f); 122 m_ScriptDistanceFactor =
67 m_ScriptDistanceFactor = config.Configs["XEngine"]. 123 m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);
68 GetFloat("ScriptDistanceLimitFactor", 1.0f); 124
69 125 string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
70 AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; 126 switch (risk)
127 {
128 case "None":
129 m_MaxThreatLevel = ThreatLevel.None;
130 break;
131 case "VeryLow":
132 m_MaxThreatLevel = ThreatLevel.VeryLow;
133 break;
134 case "Low":
135 m_MaxThreatLevel = ThreatLevel.Low;
136 break;
137 case "Moderate":
138 m_MaxThreatLevel = ThreatLevel.Moderate;
139 break;
140 case "High":
141 m_MaxThreatLevel = ThreatLevel.High;
142 break;
143 case "VeryHigh":
144 m_MaxThreatLevel = ThreatLevel.VeryHigh;
145 break;
146 case "Severe":
147 m_MaxThreatLevel = ThreatLevel.Severe;
148 break;
149 default:
150 break;
151 }
71 } 152 }
72 153
73 // 154 //
@@ -84,6 +165,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
84 return lease; 165 return lease;
85 } 166 }
86 167
168 public Scene World
169 {
170 get { return m_ScriptEngine.World; }
171 }
172
173 internal void OSSLError(string msg)
174 {
175 throw new Exception("OSSL Runtime Error: " + msg);
176 }
177
178 protected void CheckThreatLevel(ThreatLevel level, string function)
179 {
180 if (level > m_MaxThreatLevel)
181 throw new Exception("Threat level too high - "+function);
182 }
183
87 protected void ScriptSleep(int delay) 184 protected void ScriptSleep(int delay)
88 { 185 {
89 delay = (int)((float)delay * m_ScriptDelayFactor); 186 delay = (int)((float)delay * m_ScriptDelayFactor);
@@ -98,11 +195,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
98 195
99 public int osTerrainSetHeight(int x, int y, double val) 196 public int osTerrainSetHeight(int x, int y, double val)
100 { 197 {
101 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 198 if (!m_OSFunctionsEnabled)
102 { 199 {
103 OSSLError("osTerrainSetHeight: permission denied"); 200 OSSLError("osTerrainSetHeight: permission denied");
104 return 0; 201 return 0;
105 } 202 }
203 CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
106 204
107 m_host.AddScriptLPS(1); 205 m_host.AddScriptLPS(1);
108 if (x > 255 || x < 0 || y > 255 || y < 0) 206 if (x > 255 || x < 0 || y > 255 || y < 0)
@@ -121,11 +219,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
121 219
122 public double osTerrainGetHeight(int x, int y) 220 public double osTerrainGetHeight(int x, int y)
123 { 221 {
124 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 222 if (!m_OSFunctionsEnabled)
125 { 223 {
126 OSSLError("osTerrainGetHeight: permission denied"); 224 OSSLError("osTerrainGetHeight: permission denied");
127 return 0.0; 225 return 0.0;
128 } 226 }
227 CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
129 228
130 m_host.AddScriptLPS(1); 229 m_host.AddScriptLPS(1);
131 if (x > 255 || x < 0 || y > 255 || y < 0) 230 if (x > 255 || x < 0 || y > 255 || y < 0)
@@ -136,11 +235,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
136 235
137 public int osRegionRestart(double seconds) 236 public int osRegionRestart(double seconds)
138 { 237 {
139 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 238 if (!m_OSFunctionsEnabled)
140 { 239 {
141 OSSLError("osRegionRestart: permission denied"); 240 OSSLError("osRegionRestart: permission denied");
142 return 0; 241 return 0;
143 } 242 }
243 // This is High here because region restart is not reliable
244 // it may result in the region staying down or becoming
245 // unstable. This should be changed to Low or VeryLow once
246 // The underlying functionality is fixed, since the security
247 // as such is sound
248 //
249 CheckThreatLevel(ThreatLevel.High, "osRegionRestart");
144 250
145 m_host.AddScriptLPS(1); 251 m_host.AddScriptLPS(1);
146 if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID, false)) 252 if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID, false))
@@ -156,24 +262,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
156 262
157 public void osRegionNotice(string msg) 263 public void osRegionNotice(string msg)
158 { 264 {
159 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 265 if (!m_OSFunctionsEnabled)
160 { 266 {
161 OSSLError("osRegionNotice: permission denied"); 267 OSSLError("osRegionNotice: permission denied");
162 return; 268 return;
163 } 269 }
164 270
271 // This implementation provides absolutely no security
272 // It's high griefing potential makes this classification
273 // necessary
274 //
275 CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice");
276
165 m_host.AddScriptLPS(1); 277 m_host.AddScriptLPS(1);
166 World.SendGeneralAlert(msg); 278 World.SendGeneralAlert(msg);
167 } 279 }
168 280
169 public void osSetRot(UUID target, Quaternion rotation) 281 public void osSetRot(UUID target, Quaternion rotation)
170 { 282 {
171 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 283 if (!m_OSFunctionsEnabled)
172 { 284 {
173 OSSLError("osSetRot: permission denied"); 285 OSSLError("osSetRot: permission denied");
174 return; 286 return;
175 } 287 }
176 288
289 // This function has no security. It can be used to destroy
290 // arbitrary builds the user would normally have no rights to
291 //
292 CheckThreatLevel(ThreatLevel.VeryHigh, "osSetRot");
293
177 m_host.AddScriptLPS(1); 294 m_host.AddScriptLPS(1);
178 if (World.Entities.ContainsKey(target)) 295 if (World.Entities.ContainsKey(target))
179 { 296 {
@@ -188,12 +305,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
188 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, 305 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
189 int timer) 306 int timer)
190 { 307 {
191 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 308 if (!m_OSFunctionsEnabled)
192 { 309 {
193 OSSLError("osSetDynamicTextureURL: permission denied"); 310 OSSLError("osSetDynamicTextureURL: permission denied");
194 return String.Empty; 311 return String.Empty;
195 } 312 }
196 313
314 // This may be upgraded depending on the griefing or DOS
315 // potential, or guarded with a delay
316 //
317 CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL");
318
197 m_host.AddScriptLPS(1); 319 m_host.AddScriptLPS(1);
198 if (dynamicID == String.Empty) 320 if (dynamicID == String.Empty)
199 { 321 {
@@ -214,12 +336,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
214 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, 336 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
215 int timer, int alpha) 337 int timer, int alpha)
216 { 338 {
217 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 339 if (!m_OSFunctionsEnabled)
218 { 340 {
219 OSSLError("osSetDynamicTextureURLBlend: permission denied"); 341 OSSLError("osSetDynamicTextureURLBlend: permission denied");
220 return String.Empty; 342 return String.Empty;
221 } 343 }
222 344
345 CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend");
346
223 m_host.AddScriptLPS(1); 347 m_host.AddScriptLPS(1);
224 if (dynamicID == String.Empty) 348 if (dynamicID == String.Empty)
225 { 349 {
@@ -240,12 +364,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
240 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, 364 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
241 int timer) 365 int timer)
242 { 366 {
243 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 367 if (!m_OSFunctionsEnabled)
244 { 368 {
245 OSSLError("osSetDynamicTextureData: permission denied"); 369 OSSLError("osSetDynamicTextureData: permission denied");
246 return String.Empty; 370 return String.Empty;
247 } 371 }
248 372
373 CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData");
374
249 m_host.AddScriptLPS(1); 375 m_host.AddScriptLPS(1);
250 if (dynamicID == String.Empty) 376 if (dynamicID == String.Empty)
251 { 377 {
@@ -273,12 +399,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
273 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, 399 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
274 int timer, int alpha) 400 int timer, int alpha)
275 { 401 {
276 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 402 if (!m_OSFunctionsEnabled)
277 { 403 {
278 OSSLError("osSetDynamicTextureDataBlend: permission denied"); 404 OSSLError("osSetDynamicTextureDataBlend: permission denied");
279 return String.Empty; 405 return String.Empty;
280 } 406 }
281 407
408 CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend");
409
282 m_host.AddScriptLPS(1); 410 m_host.AddScriptLPS(1);
283 if (dynamicID == String.Empty) 411 if (dynamicID == String.Empty)
284 { 412 {
@@ -306,25 +434,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
306 public bool osConsoleCommand(string command) 434 public bool osConsoleCommand(string command)
307 { 435 {
308 m_host.AddScriptLPS(1); 436 m_host.AddScriptLPS(1);
309 if (m_ScriptEngine.Config.GetBoolean("AllowosConsoleCommand", false)) 437 if (!m_OSFunctionsEnabled)
310 { 438 {
311 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) 439 OSSLError("osConsoleCommand: permission denied");
312 {
313 MainConsole.Instance.RunCommand(command);
314 return true;
315 }
316 return false; 440 return false;
317 } 441 }
442
443 CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand");
444
445 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
446 {
447 MainConsole.Instance.RunCommand(command);
448 return true;
449 }
318 return false; 450 return false;
319 } 451 }
452
320 public void osSetPrimFloatOnWater(int floatYN) 453 public void osSetPrimFloatOnWater(int floatYN)
321 { 454 {
322 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 455 if (!m_OSFunctionsEnabled)
323 { 456 {
324 OSSLError("osSetPrimFloatOnWater: permission denied"); 457 OSSLError("osSetPrimFloatOnWater: permission denied");
325 return; 458 return;
326 } 459 }
327 460
461 CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater");
462
328 m_host.AddScriptLPS(1); 463 m_host.AddScriptLPS(1);
329 if (m_host.ParentGroup != null) 464 if (m_host.ParentGroup != null)
330 { 465 {
@@ -338,6 +473,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
338 // Teleport functions 473 // Teleport functions
339 public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 474 public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
340 { 475 {
476 if (!m_OSFunctionsEnabled)
477 {
478 OSSLError("osTeleportAgent: permission denied");
479 return;
480 }
481
482 // High because there is no security check. High griefer potential
483 //
484 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
485
341 m_host.AddScriptLPS(1); 486 m_host.AddScriptLPS(1);
342 UUID agentId = new UUID(); 487 UUID agentId = new UUID();
343 if (UUID.TryParse(agent, out agentId)) 488 if (UUID.TryParse(agent, out agentId))
@@ -351,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
351 World.RequestTeleportLocation(presence.ControllingClient, regionName, 496 World.RequestTeleportLocation(presence.ControllingClient, regionName,
352 new Vector3((float)position.x, (float)position.y, (float)position.z), 497 new Vector3((float)position.x, (float)position.y, (float)position.z),
353 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); 498 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
354 // ScriptSleep(5000); 499 ScriptSleep(5000);
355 } 500 }
356 } 501 }
357 } 502 }
@@ -365,12 +510,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
365 // Adam's super super custom animation functions 510 // Adam's super super custom animation functions
366 public void osAvatarPlayAnimation(string avatar, string animation) 511 public void osAvatarPlayAnimation(string avatar, string animation)
367 { 512 {
368 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 513 if (!m_OSFunctionsEnabled)
369 { 514 {
370 OSSLError("osAvatarPlayAnimation: permission denied"); 515 OSSLError("osAvatarPlayAnimation: permission denied");
371 return; 516 return;
372 } 517 }
373 518
519 CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation");
520
374 m_host.AddScriptLPS(1); 521 m_host.AddScriptLPS(1);
375 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence) 522 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
376 { 523 {
@@ -381,12 +528,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
381 528
382 public void osAvatarStopAnimation(string avatar, string animation) 529 public void osAvatarStopAnimation(string avatar, string animation)
383 { 530 {
384 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 531 if (!m_OSFunctionsEnabled)
385 { 532 {
386 OSSLError("osAvatarStopAnimation: permission denied"); 533 OSSLError("osAvatarStopAnimation: permission denied");
387 return; 534 return;
388 } 535 }
389 536
537 CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation");
538
390 m_host.AddScriptLPS(1); 539 m_host.AddScriptLPS(1);
391 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence) 540 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
392 { 541 {
@@ -398,12 +547,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
398 //Texture draw functions 547 //Texture draw functions
399 public string osMovePen(string drawList, int x, int y) 548 public string osMovePen(string drawList, int x, int y)
400 { 549 {
401 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 550 if (!m_OSFunctionsEnabled)
402 { 551 {
403 OSSLError("osMovePen: permission denied"); 552 OSSLError("osMovePen: permission denied");
404 return String.Empty; 553 return String.Empty;
405 } 554 }
406 555
556 CheckThreatLevel(ThreatLevel.None, "osMovePen");
557
407 m_host.AddScriptLPS(1); 558 m_host.AddScriptLPS(1);
408 drawList += "MoveTo " + x + "," + y + ";"; 559 drawList += "MoveTo " + x + "," + y + ";";
409 return drawList; 560 return drawList;
@@ -411,12 +562,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
411 562
412 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) 563 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
413 { 564 {
414 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 565 if (!m_OSFunctionsEnabled)
415 { 566 {
416 OSSLError("osDrawLine: permission denied"); 567 OSSLError("osDrawLine: permission denied");
417 return String.Empty; 568 return String.Empty;
418 } 569 }
419 570
571 CheckThreatLevel(ThreatLevel.None, "osDrawLine");
572
420 m_host.AddScriptLPS(1); 573 m_host.AddScriptLPS(1);
421 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; 574 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
422 return drawList; 575 return drawList;
@@ -424,12 +577,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
424 577
425 public string osDrawLine(string drawList, int endX, int endY) 578 public string osDrawLine(string drawList, int endX, int endY)
426 { 579 {
427 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 580 if (!m_OSFunctionsEnabled)
428 { 581 {
429 OSSLError("osDrawLine: permission denied"); 582 OSSLError("osDrawLine: permission denied");
430 return String.Empty; 583 return String.Empty;
431 } 584 }
432 585
586 CheckThreatLevel(ThreatLevel.None, "osDrawLine");
587
433 m_host.AddScriptLPS(1); 588 m_host.AddScriptLPS(1);
434 drawList += "LineTo " + endX + "," + endY + "; "; 589 drawList += "LineTo " + endX + "," + endY + "; ";
435 return drawList; 590 return drawList;
@@ -437,12 +592,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
437 592
438 public string osDrawText(string drawList, string text) 593 public string osDrawText(string drawList, string text)
439 { 594 {
440 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 595 if (!m_OSFunctionsEnabled)
441 { 596 {
442 OSSLError("osDrawText: permission denied"); 597 OSSLError("osDrawText: permission denied");
443 return String.Empty; 598 return String.Empty;
444 } 599 }
445 600
601 CheckThreatLevel(ThreatLevel.None, "osDrawText");
602
446 m_host.AddScriptLPS(1); 603 m_host.AddScriptLPS(1);
447 drawList += "Text " + text + "; "; 604 drawList += "Text " + text + "; ";
448 return drawList; 605 return drawList;
@@ -450,12 +607,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
450 607
451 public string osDrawEllipse(string drawList, int width, int height) 608 public string osDrawEllipse(string drawList, int width, int height)
452 { 609 {
453 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 610 if (!m_OSFunctionsEnabled)
454 { 611 {
455 OSSLError("osDrawEllipse: permission denied"); 612 OSSLError("osDrawEllipse: permission denied");
456 return String.Empty; 613 return String.Empty;
457 } 614 }
458 615
616 CheckThreatLevel(ThreatLevel.None, "osDrawEllipse");
617
459 m_host.AddScriptLPS(1); 618 m_host.AddScriptLPS(1);
460 drawList += "Ellipse " + width + "," + height + "; "; 619 drawList += "Ellipse " + width + "," + height + "; ";
461 return drawList; 620 return drawList;
@@ -463,12 +622,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
463 622
464 public string osDrawRectangle(string drawList, int width, int height) 623 public string osDrawRectangle(string drawList, int width, int height)
465 { 624 {
466 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 625 if (!m_OSFunctionsEnabled)
467 { 626 {
468 OSSLError("osDrawRectangle: permission denied"); 627 OSSLError("osDrawRectangle: permission denied");
469 return String.Empty; 628 return String.Empty;
470 } 629 }
471 630
631 CheckThreatLevel(ThreatLevel.None, "osDrawRectangle");
632
472 m_host.AddScriptLPS(1); 633 m_host.AddScriptLPS(1);
473 drawList += "Rectangle " + width + "," + height + "; "; 634 drawList += "Rectangle " + width + "," + height + "; ";
474 return drawList; 635 return drawList;
@@ -476,12 +637,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
476 637
477 public string osDrawFilledRectangle(string drawList, int width, int height) 638 public string osDrawFilledRectangle(string drawList, int width, int height)
478 { 639 {
479 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 640 if (!m_OSFunctionsEnabled)
480 { 641 {
481 OSSLError("osDrawFilledRectangle: permission denied"); 642 OSSLError("osDrawFilledRectangle: permission denied");
482 return String.Empty; 643 return String.Empty;
483 } 644 }
484 645
646 CheckThreatLevel(ThreatLevel.None, "osDrawFilledRectangle");
647
485 m_host.AddScriptLPS(1); 648 m_host.AddScriptLPS(1);
486 drawList += "FillRectangle " + width + "," + height + "; "; 649 drawList += "FillRectangle " + width + "," + height + "; ";
487 return drawList; 650 return drawList;
@@ -489,12 +652,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
489 652
490 public string osSetFontSize(string drawList, int fontSize) 653 public string osSetFontSize(string drawList, int fontSize)
491 { 654 {
492 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 655 if (!m_OSFunctionsEnabled)
493 { 656 {
494 OSSLError("osSetFontSize: permission denied"); 657 OSSLError("osSetFontSize: permission denied");
495 return String.Empty; 658 return String.Empty;
496 } 659 }
497 660
661 CheckThreatLevel(ThreatLevel.None, "osSetFontSize");
662
498 m_host.AddScriptLPS(1); 663 m_host.AddScriptLPS(1);
499 drawList += "FontSize "+ fontSize +"; "; 664 drawList += "FontSize "+ fontSize +"; ";
500 return drawList; 665 return drawList;
@@ -502,12 +667,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
502 667
503 public string osSetPenSize(string drawList, int penSize) 668 public string osSetPenSize(string drawList, int penSize)
504 { 669 {
505 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 670 if (!m_OSFunctionsEnabled)
506 { 671 {
507 OSSLError("osSetPenSize: permission denied"); 672 OSSLError("osSetPenSize: permission denied");
508 return String.Empty; 673 return String.Empty;
509 } 674 }
510 675
676 CheckThreatLevel(ThreatLevel.None, "osSetPenSize");
677
511 m_host.AddScriptLPS(1); 678 m_host.AddScriptLPS(1);
512 drawList += "PenSize " + penSize + "; "; 679 drawList += "PenSize " + penSize + "; ";
513 return drawList; 680 return drawList;
@@ -515,12 +682,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
515 682
516 public string osSetPenColour(string drawList, string colour) 683 public string osSetPenColour(string drawList, string colour)
517 { 684 {
518 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 685 if (!m_OSFunctionsEnabled)
519 { 686 {
520 OSSLError("osSetPenColour: permission denied"); 687 OSSLError("osSetPenColour: permission denied");
521 return String.Empty; 688 return String.Empty;
522 } 689 }
523 690
691 CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
692
524 m_host.AddScriptLPS(1); 693 m_host.AddScriptLPS(1);
525 drawList += "PenColour " + colour + "; "; 694 drawList += "PenColour " + colour + "; ";
526 return drawList; 695 return drawList;
@@ -528,36 +697,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
528 697
529 public string osDrawImage(string drawList, int width, int height, string imageUrl) 698 public string osDrawImage(string drawList, int width, int height, string imageUrl)
530 { 699 {
531 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 700 if (!m_OSFunctionsEnabled)
532 { 701 {
533 OSSLError("osDrawImage: permission denied"); 702 OSSLError("osDrawImage: permission denied");
534 return String.Empty; 703 return String.Empty;
535 } 704 }
536 705
537 m_host.AddScriptLPS(1); 706 CheckThreatLevel(ThreatLevel.None, "osDrawImage");
538 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; 707
539 return drawList; 708 m_host.AddScriptLPS(1);
709 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
710 return drawList;
540 } 711 }
541 712
542 public void osSetStateEvents(int events) 713 public void osSetStateEvents(int events)
543 { 714 {
544 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 715 if (!m_OSFunctionsEnabled)
545 { 716 {
546 OSSLError("osSetStateEvents: permission denied"); 717 OSSLError("osSetStateEvents: permission denied");
547 return; 718 return;
548 } 719 }
549 720
721 // This function is a hack. There is no reason for it's existence
722 // anymore, since state events now work properly.
723 // It was probably added as a crutch or debugging aid, and
724 // should be removed
725 //
726 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
727
550 m_host.SetScriptEvents(m_itemID, events); 728 m_host.SetScriptEvents(m_itemID, events);
551 } 729 }
552 730
553 public void osSetRegionWaterHeight(double height) 731 public void osSetRegionWaterHeight(double height)
554 { 732 {
555 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 733 if (!m_OSFunctionsEnabled)
556 { 734 {
557 OSSLError("osSetRegionWaterHeight: permission denied"); 735 OSSLError("osSetRegionWaterHeight: permission denied");
558 return; 736 return;
559 } 737 }
560 738
739 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
740
561 m_host.AddScriptLPS(1); 741 m_host.AddScriptLPS(1);
562 //Check to make sure that the script's owner is the estate manager/master 742 //Check to make sure that the script's owner is the estate manager/master
563 //World.Permissions.GenericEstatePermission( 743 //World.Permissions.GenericEstatePermission(
@@ -569,12 +749,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
569 749
570 public double osList2Double(LSL_Types.list src, int index) 750 public double osList2Double(LSL_Types.list src, int index)
571 { 751 {
572 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 752 if (!m_OSFunctionsEnabled)
573 { 753 {
574 OSSLError("osList2Double: permission denied"); 754 OSSLError("osList2Double: permission denied");
575 return 0.0; 755 return 0.0;
576 } 756 }
577 757
758 // There is really no double type in OSSL. C# and other
759 // have one, but the current implementation of LSL_Types.list
760 // is not allowed to contain any.
761 // This really should be removed.
762 //
763 CheckThreatLevel(ThreatLevel.None, "osList2Double");
764
578 m_host.AddScriptLPS(1); 765 m_host.AddScriptLPS(1);
579 if (index < 0) 766 if (index < 0)
580 { 767 {
@@ -589,12 +776,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
589 776
590 public void osSetParcelMediaURL(string url) 777 public void osSetParcelMediaURL(string url)
591 { 778 {
592 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 779 if (!m_OSFunctionsEnabled)
593 { 780 {
594 OSSLError("osSetParcelMediaURL: permission denied"); 781 OSSLError("osSetParcelMediaURL: permission denied");
595 return; 782 return;
596 } 783 }
597 784
785 // What actually is the difference to the LL function?
786 //
787 CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
788
598 m_host.AddScriptLPS(1); 789 m_host.AddScriptLPS(1);
599 UUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 790 UUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
600 791
@@ -611,24 +802,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
611 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url); 802 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
612 } 803 }
613 804
614 public Scene World
615 {
616 get { return m_ScriptEngine.World; }
617 }
618
619 internal void OSSLError(string msg)
620 {
621 throw new Exception("OSSL Runtime Error: " + msg);
622 }
623
624 public string osGetScriptEngineName() 805 public string osGetScriptEngineName()
625 { 806 {
626 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 807 if (!m_OSFunctionsEnabled)
627 { 808 {
628 OSSLError("osGetScriptEngineName: permission denied"); 809 OSSLError("osGetScriptEngineName: permission denied");
629 return ""; 810 return "";
630 } 811 }
631 812
813 // This gets a "high" because knowing the engine may be used
814 // to exploit engine-specific bugs or induce usage patterns
815 // that trigger engine-specific failures.
816 // Besides, public grid users aren't supposed to know.
817 //
818 CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName");
819
632 m_host.AddScriptLPS(1); 820 m_host.AddScriptLPS(1);
633 821
634 int scriptEngineNameIndex = 0; 822 int scriptEngineNameIndex = 0;
@@ -657,12 +845,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
657 //for testing purposes only 845 //for testing purposes only
658 public void osSetParcelMediaTime(double time) 846 public void osSetParcelMediaTime(double time)
659 { 847 {
660 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 848 if (!m_OSFunctionsEnabled)
661 { 849 {
662 OSSLError("osSetParcelMediaTime: permission denied"); 850 OSSLError("osSetParcelMediaTime: permission denied");
663 return; 851 return;
664 } 852 }
665 853
854 // This gets very high because I have no idea what it does.
855 // If someone knows, please adjust. If it;s no longer needed,
856 // please remove.
857 //
858 CheckThreatLevel(ThreatLevel.VeryHigh, "osSetParcelMediaTime");
859
666 m_host.AddScriptLPS(1); 860 m_host.AddScriptLPS(1);
667 861
668 World.ParcelMediaSetTime((float)time); 862 World.ParcelMediaSetTime((float)time);
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index eda5813..617f10e 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -677,6 +677,8 @@ AllowedCompilers = lsl,vb,js,cs
677CompileWithDebugInformation = true 677CompileWithDebugInformation = true
678; Allow the use of os* functions (some are dangerous) 678; Allow the use of os* functions (some are dangerous)
679AllowOSFunctions = false 679AllowOSFunctions = false
680; Threat level to allow, one of None, VeryLow, Low, Moderate, High, VeryHigh, Severe
681OSFunctionThreatLevel = VeryLow
680; Interval (s) between background save of script states 682; Interval (s) between background save of script states
681SaveInterval = 120 683SaveInterval = 120
682; Interval (s) between maintenance runs (0 = disable) 684; Interval (s) between maintenance runs (0 = disable)
@@ -685,8 +687,6 @@ MaintenanceInterval = 10
685EventLimit = 30 687EventLimit = 30
686; If a script overruns it's event limit, kill the script? 688; If a script overruns it's event limit, kill the script?
687KillTimedOutScripts = false 689KillTimedOutScripts = false
688; Allow OS console command functionality (VERY DANGEROUS!!)
689AllowosConsoleCommand = false
690; Sets the multiplier for the scripting delays 690; Sets the multiplier for the scripting delays
691ScriptDelayFactor = 1.0 691ScriptDelayFactor = 1.0
692; The factor the 10 m distances llimits are multiplied by 692; The factor the 10 m distances llimits are multiplied by