diff options
author | SignpostMarv | 2012-08-01 10:28:58 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-02 22:14:46 +0100 |
commit | ce7694c108e8abf2e52a0b0167eab3d550f364ab (patch) | |
tree | 9233f757a1b8631b3dea35ae0124df4886a21659 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | fixing copypasta (diff) | |
download | opensim-SC_OLD-ce7694c108e8abf2e52a0b0167eab3d550f364ab.zip opensim-SC_OLD-ce7694c108e8abf2e52a0b0167eab3d550f364ab.tar.gz opensim-SC_OLD-ce7694c108e8abf2e52a0b0167eab3d550f364ab.tar.bz2 opensim-SC_OLD-ce7694c108e8abf2e52a0b0167eab3d550f364ab.tar.xz |
added perms checking, duplicated functionality to methods that do not require perms and have higher threat level
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 02b97e8..d0db15f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3538,7 +3538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3538 | 3538 | ||
3539 | return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); | 3539 | return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); |
3540 | } | 3540 | } |
3541 | 3541 | ||
3542 | /// <summary> | 3542 | /// <summary> |
3543 | /// Sets the response type for an HTTP request/response | 3543 | /// Sets the response type for an HTTP request/response |
3544 | /// </summary> | 3544 | /// </summary> |
@@ -3549,11 +3549,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3549 | if (m_UrlModule != null) | 3549 | if (m_UrlModule != null) |
3550 | m_UrlModule.HttpContentType(new UUID(id),type); | 3550 | m_UrlModule.HttpContentType(new UUID(id),type); |
3551 | } | 3551 | } |
3552 | 3552 | /// Shout an error if the object owner did not grant the script the specified permissions. | |
3553 | public void osDropAttachment() | 3553 | /// </summary> |
3554 | /// <param name="perms"></param> | ||
3555 | /// <returns>boolean indicating whether an error was shouted.</returns> | ||
3556 | protected bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix) | ||
3554 | { | 3557 | { |
3555 | CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment"); | 3558 | CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment"); |
3556 | m_host.AddScriptLPS(1); | 3559 | m_host.AddScriptLPS(1); |
3560 | bool fail = false; | ||
3561 | if (m_item.PermsGranter != m_host.OwnerID) | ||
3562 | { | ||
3563 | fail = true; | ||
3564 | OSSLShoutError(string.Format("{0}. Permissions not granted to owner.", errorPrefix)); | ||
3565 | } | ||
3566 | else if ((m_item.PermsMask & perms) == 0) | ||
3567 | { | ||
3568 | fail = true; | ||
3569 | OSSLShoutError(string.Format("{0}. Permissions not granted.", errorPrefix)); | ||
3570 | } | ||
3571 | |||
3572 | return fail; | ||
3573 | } | ||
3574 | |||
3575 | protected void DropAttachment(bool checkPerms) | ||
3576 | { | ||
3577 | if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment")) | ||
3578 | { | ||
3579 | return; | ||
3580 | } | ||
3557 | 3581 | ||
3558 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3582 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3559 | ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID); | 3583 | ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID); |
@@ -3564,10 +3588,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3564 | } | 3588 | } |
3565 | } | 3589 | } |
3566 | 3590 | ||
3567 | public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) | 3591 | protected void DropAttachemntAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot) |
3568 | { | 3592 | { |
3569 | CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt"); | 3593 | if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment")) |
3570 | m_host.AddScriptLPS(1); | 3594 | { |
3595 | return; | ||
3596 | } | ||
3571 | 3597 | ||
3572 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3598 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3573 | ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID); | 3599 | ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID); |
@@ -3579,5 +3605,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3579 | attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, omvPos, omvRot); | 3605 | attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, omvPos, omvRot); |
3580 | } | 3606 | } |
3581 | } | 3607 | } |
3608 | |||
3609 | public void osDropAttachment() | ||
3610 | { | ||
3611 | CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment"); | ||
3612 | m_host.AddScriptLPS(1); | ||
3613 | |||
3614 | DropAttachment(true); | ||
3615 | } | ||
3616 | |||
3617 | public void osForceDropAttachment() | ||
3618 | { | ||
3619 | CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment"); | ||
3620 | m_host.AddScriptLPS(1); | ||
3621 | |||
3622 | DropAttachment(false); | ||
3623 | } | ||
3624 | |||
3625 | public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) | ||
3626 | { | ||
3627 | CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt"); | ||
3628 | m_host.AddScriptLPS(1); | ||
3629 | |||
3630 | DropAttachemntAt(true, pos, rot); | ||
3631 | } | ||
3632 | |||
3633 | public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) | ||
3634 | { | ||
3635 | CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt"); | ||
3636 | m_host.AddScriptLPS(1); | ||
3637 | |||
3638 | DropAttachemntAt(false, pos, rot); | ||
3639 | } | ||
3582 | } | 3640 | } |
3583 | } \ No newline at end of file | 3641 | } \ No newline at end of file |