diff options
author | Justin Clark-Casey (justincc) | 2013-01-15 00:24:51 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-15 00:24:51 +0000 |
commit | c846cefda97bd59b7707147d7ae1a520c9121127 (patch) | |
tree | ee23e4b451087874a8149348e010a905817121f7 /OpenSim/Region/ScriptEngine | |
parent | refactor: Simplify ScriptInstance by retaining reference to SceneObjectPart i... (diff) | |
parent | BulletSim: fix not moving physical objects below terrain to over terrain. (diff) | |
download | opensim-SC_OLD-c846cefda97bd59b7707147d7ae1a520c9121127.zip opensim-SC_OLD-c846cefda97bd59b7707147d7ae1a520c9121127.tar.gz opensim-SC_OLD-c846cefda97bd59b7707147d7ae1a520c9121127.tar.bz2 opensim-SC_OLD-c846cefda97bd59b7707147d7ae1a520c9121127.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
3 files changed, 54 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 33c02ef..958a448 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -245,11 +245,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
245 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 245 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
246 | } | 246 | } |
247 | 247 | ||
248 | // Returns of the function is allowed. Throws a script exception if not allowed. | ||
248 | public void CheckThreatLevel(ThreatLevel level, string function) | 249 | public void CheckThreatLevel(ThreatLevel level, string function) |
249 | { | 250 | { |
250 | if (!m_OSFunctionsEnabled) | 251 | if (!m_OSFunctionsEnabled) |
251 | OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws | 252 | OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws |
252 | 253 | ||
254 | string reasonWhyNot = CheckThreatLevelTest(level, function); | ||
255 | if (!String.IsNullOrEmpty(reasonWhyNot)) | ||
256 | { | ||
257 | OSSLError(reasonWhyNot); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | // Check to see if function is allowed. Returns an empty string if function permitted | ||
262 | // or a string explaining why this function can't be used. | ||
263 | private string CheckThreatLevelTest(ThreatLevel level, string function) | ||
264 | { | ||
253 | if (!m_FunctionPerms.ContainsKey(function)) | 265 | if (!m_FunctionPerms.ContainsKey(function)) |
254 | { | 266 | { |
255 | FunctionPerms perms = new FunctionPerms(); | 267 | FunctionPerms perms = new FunctionPerms(); |
@@ -329,10 +341,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | { | 341 | { |
330 | // Allow / disallow by threat level | 342 | // Allow / disallow by threat level |
331 | if (level > m_MaxThreatLevel) | 343 | if (level > m_MaxThreatLevel) |
332 | OSSLError( | 344 | return |
333 | String.Format( | 345 | String.Format( |
334 | "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.", | 346 | "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.", |
335 | function, m_MaxThreatLevel, level)); | 347 | function, m_MaxThreatLevel, level); |
336 | } | 348 | } |
337 | else | 349 | else |
338 | { | 350 | { |
@@ -342,7 +354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
342 | if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID)) | 354 | if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID)) |
343 | { | 355 | { |
344 | // prim owner is in the list of allowed owners | 356 | // prim owner is in the list of allowed owners |
345 | return; | 357 | return String.Empty; |
346 | } | 358 | } |
347 | 359 | ||
348 | UUID ownerID = m_item.OwnerID; | 360 | UUID ownerID = m_item.OwnerID; |
@@ -354,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
354 | 366 | ||
355 | if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) | 367 | if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) |
356 | { | 368 | { |
357 | return; | 369 | return String.Empty; |
358 | } | 370 | } |
359 | } | 371 | } |
360 | 372 | ||
@@ -365,7 +377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
365 | 377 | ||
366 | if (land.LandData.OwnerID == ownerID) | 378 | if (land.LandData.OwnerID == ownerID) |
367 | { | 379 | { |
368 | return; | 380 | return String.Empty; |
369 | } | 381 | } |
370 | } | 382 | } |
371 | 383 | ||
@@ -375,7 +387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
375 | //Only Estate Managers may use the function | 387 | //Only Estate Managers may use the function |
376 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 388 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
377 | { | 389 | { |
378 | return; | 390 | return String.Empty; |
379 | } | 391 | } |
380 | } | 392 | } |
381 | 393 | ||
@@ -384,25 +396,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | { | 396 | { |
385 | if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) | 397 | if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) |
386 | { | 398 | { |
387 | return; | 399 | return String.Empty; |
388 | } | 400 | } |
389 | } | 401 | } |
390 | 402 | ||
391 | if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) | 403 | if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) |
392 | OSSLError( | 404 | return( |
393 | String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", | 405 | String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", |
394 | function)); | 406 | function)); |
395 | 407 | ||
396 | if (m_item.CreatorID != ownerID) | 408 | if (m_item.CreatorID != ownerID) |
397 | { | 409 | { |
398 | if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) | 410 | if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) |
399 | OSSLError( | 411 | return String.Format("{0} permission denied. Script permissions error.", function); |
400 | String.Format("{0} permission denied. Script permissions error.", | ||
401 | function)); | ||
402 | 412 | ||
403 | } | 413 | } |
404 | } | 414 | } |
405 | } | 415 | } |
416 | return String.Empty; | ||
406 | } | 417 | } |
407 | 418 | ||
408 | internal void OSSLDeprecated(string function, string replacement) | 419 | internal void OSSLDeprecated(string function, string replacement) |
@@ -1558,6 +1569,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1558 | } | 1569 | } |
1559 | } | 1570 | } |
1560 | 1571 | ||
1572 | public string osGetPhysicsEngineType() | ||
1573 | { | ||
1574 | // High because it can be used to target attacks to known weaknesses | ||
1575 | // This would allow a new class of griefer scripts that don't even | ||
1576 | // require their user to know what they are doing (see script | ||
1577 | // kiddie) | ||
1578 | // Because it would be nice if scripts didn't blow up if the information | ||
1579 | // about the physics engine, this function returns an empty string if | ||
1580 | // the user does not have permission to see it. This as opposed to | ||
1581 | // throwing an exception. | ||
1582 | m_host.AddScriptLPS(1); | ||
1583 | string ret = String.Empty; | ||
1584 | if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) | ||
1585 | { | ||
1586 | if (m_ScriptEngine.World.PhysicsScene != null) | ||
1587 | { | ||
1588 | ret = m_ScriptEngine.World.PhysicsScene.EngineType; | ||
1589 | // An old physics engine might have an uninitialized engine type | ||
1590 | if (ret == null) | ||
1591 | ret = "unknown"; | ||
1592 | } | ||
1593 | } | ||
1594 | |||
1595 | return ret; | ||
1596 | } | ||
1597 | |||
1561 | public string osGetSimulatorVersion() | 1598 | public string osGetSimulatorVersion() |
1562 | { | 1599 | { |
1563 | // High because it can be used to target attacks to known weaknesses | 1600 | // High because it can be used to target attacks to known weaknesses |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index cdd9ea8..51d0581 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -259,6 +259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
259 | 259 | ||
260 | string osGetScriptEngineName(); | 260 | string osGetScriptEngineName(); |
261 | string osGetSimulatorVersion(); | 261 | string osGetSimulatorVersion(); |
262 | string osGetPhysicsEngineType(); | ||
262 | Object osParseJSONNew(string JSON); | 263 | Object osParseJSONNew(string JSON); |
263 | Hashtable osParseJSON(string JSON); | 264 | Hashtable osParseJSON(string JSON); |
264 | 265 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index afa9ae0..c9902e4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -420,6 +420,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
420 | return m_OSSL_Functions.osGetScriptEngineName(); | 420 | return m_OSSL_Functions.osGetScriptEngineName(); |
421 | } | 421 | } |
422 | 422 | ||
423 | public string osGetPhysicsEngineType() | ||
424 | { | ||
425 | return m_OSSL_Functions.osGetPhysicsEngineType(); | ||
426 | } | ||
427 | |||
423 | public string osGetSimulatorVersion() | 428 | public string osGetSimulatorVersion() |
424 | { | 429 | { |
425 | return m_OSSL_Functions.osGetSimulatorVersion(); | 430 | return m_OSSL_Functions.osGetSimulatorVersion(); |