From af3e477e4b1cc6c1a2176d776e6c39d0c7fc457c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 19 Apr 2010 19:27:45 +0200 Subject: Avoid duplicate script resumes. Move resume calls to more logical places --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 77e73fb..f050dcf 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -239,6 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Fire after attach, so we don't get messy perms dialogs // 3 == AttachedRez objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3); + objatt.ResumeScripts(); // Do this last so that event listeners have access to all the effects of the attachment m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); @@ -250,7 +251,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID, remoteClient.Name, AttachmentPt); } - objatt.ResumeScripts(); return objatt; } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 32a0df9..2352ced 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -601,6 +601,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // Fire on_rez group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0); + rootPart.ParentGroup.ResumeScripts(); rootPart.ScheduleFullUpdate(); } @@ -621,7 +622,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } - rootPart.ParentGroup.ResumeScripts(); return rootPart.ParentGroup; } } -- cgit v1.1 From 855eda844ffa12b01fccfd9aeb831390b02687bf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Apr 2010 20:06:55 +0100 Subject: log problems when an asset request through the UDP TransferRequest channel goes wrong --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 47 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b3f5f09..54c312c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7091,32 +7091,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP taskID = new UUID(transfer.TransferInfo.Params, 48); UUID itemID = new UUID(transfer.TransferInfo.Params, 64); UUID requestID = new UUID(transfer.TransferInfo.Params, 80); + +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Got request for asset {0} from item {1} in prim {2} by {3}", +// requestID, itemID, taskID, Name); + if (!(((Scene)m_scene).Permissions.BypassPermissions())) { if (taskID != UUID.Zero) // Prim { SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); + if (part == null) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist", + Name, requestID, itemID, taskID); return true; + } if (part.OwnerID != AgentId) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}", + Name, requestID, itemID, taskID, part.OwnerID); return true; + } if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set", + Name, requestID, itemID, taskID); return true; + } TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); if (ti == null) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but item does not exist", + Name, requestID, itemID, taskID); return true; + } if (ti.OwnerID != AgentId) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", + Name, requestID, itemID, taskID, ti.OwnerID); return true; + } - if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + if (( + ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", + Name, requestID, itemID, taskID); return true; + } if (ti.AssetID != requestID) + { + m_log.WarnFormat( + "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", + Name, requestID, itemID, taskID, ti.AssetID); return true; + } } else // Agent { @@ -11389,7 +11432,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // } } - //m_log.DebugFormat("[LLCLIENTVIEW]: {0} requesting asset {1}", Name, requestID); +// m_log.DebugFormat("[LLCLIENTVIEW]: {0} requesting asset {1}", Name, requestID); m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); } -- cgit v1.1 From da83ee28be93ff2649e1df214d942b01104247de Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Apr 2010 21:02:36 +0100 Subject: If a transfer request is received for a task inventory item asset, then route the permissions request through the existing CanEditScript() and CanEditNotecard() methods. This implements the 'share with group' flag for notecards and scripts in prim inventory since the PermissionsModule checks group membership and permissions. Other than that, the code in PermissionsModule duplicates the checks in LLClientView so there should be no change other than allowing group members to edit embedded notecards and scripts. For all other asset types, the permission checking code in LLClientView continues to be used, pending refactoring of suitable permissions code This means that 'share with group' will not yet work for prim inventory items other than notecards and scripts --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 108 ++++++++++++--------- .../World/Permissions/PermissionsModule.cs | 17 ++-- 2 files changed, 75 insertions(+), 50 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 54c312c..c4e8e09 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7093,7 +7093,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID requestID = new UUID(transfer.TransferInfo.Params, 80); // m_log.DebugFormat( -// "[LLCLIENTVIEW]: Got request for asset {0} from item {1} in prim {2} by {3}", +// "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}", // requestID, itemID, taskID, Name); if (!(((Scene)m_scene).Permissions.BypassPermissions())) @@ -7105,60 +7105,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (part == null) { m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist", + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist", Name, requestID, itemID, taskID); return true; } - if (part.OwnerID != AgentId) + TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID); + if (tii == null) { m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}", - Name, requestID, itemID, taskID, part.OwnerID); - return true; - } - - if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) - { - m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set", - Name, requestID, itemID, taskID); - return true; - } - - TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); - if (ti == null) - { - m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but item does not exist", + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist", Name, requestID, itemID, taskID); return true; - } - - if (ti.OwnerID != AgentId) + } + + if (tii.Type == (int)AssetType.LSLText) { - m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", - Name, requestID, itemID, taskID, ti.OwnerID); - return true; + if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId)) + return true; } - - if (( - ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) - != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + else if (tii.Type == (int)AssetType.Notecard) { - m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", - Name, requestID, itemID, taskID); - return true; + if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId)) + return true; } - - if (ti.AssetID != requestID) + else { - m_log.WarnFormat( - "[LLCLIENTVIEW]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", - Name, requestID, itemID, taskID, ti.AssetID); - return true; + // TODO: Change this code to allow items other than notecards and scripts to be successfully + // shared with group. In fact, all this permissions checking should move to an IPermissionsModule + if (part.OwnerID != AgentId) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}", + Name, requestID, itemID, taskID, part.OwnerID); + return true; + } + + if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set", + Name, requestID, itemID, taskID); + return true; + } + + if (tii.OwnerID != AgentId) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", + Name, requestID, itemID, taskID, tii.OwnerID); + return true; + } + + if (( + tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", + Name, requestID, itemID, taskID); + return true; + } + + if (tii.AssetID != requestID) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", + Name, requestID, itemID, taskID, tii.AssetID); + return true; + } } } else // Agent @@ -7197,7 +7212,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if (assetRequestItem.AssetID != requestID) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", + Name, requestID, itemID, assetRequestItem.AssetID); return true; + } } } } @@ -11432,7 +11452,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // } } -// m_log.DebugFormat("[LLCLIENTVIEW]: {0} requesting asset {1}", Name, requestID); +// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); } @@ -11800,4 +11820,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(dialog, ThrottleOutPacketType.Task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index d940564..01359f0 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1079,7 +1079,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) return false; - } else { + } + else + { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return false; } @@ -1095,7 +1097,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; if (!IsGroupMember(ti.GroupID, user, 0)) - return false; + return false; } // Require full perms @@ -1593,14 +1595,16 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (part.OwnerID != user) { if (part.GroupID == UUID.Zero) - return false; + return false; if (!IsGroupMember(part.GroupID, user, 0)) return false; if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) return false; - } else { + } + else + { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return false; } @@ -1855,7 +1859,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericObjectPermission(agentID, prim, false); } - private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { + private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) + { //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); switch (scriptType) { case 0: @@ -1889,4 +1894,4 @@ namespace OpenSim.Region.CoreModules.World.Permissions return(false); } } -} +} \ No newline at end of file -- cgit v1.1 From 524a2a9e26794e2ed645d51c089be42633a782df Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Apr 2010 21:25:59 +0100 Subject: Make the "notecard saved" text appear in the saver rather than the notecard owner, if the notecard is saved by a permitted group member This means moving the alert up to a place where the IClientAPI is available. One can also argue that such client messages shouldn't be sent directly from the scene data model --- .../Agent/AssetTransaction/AgentAssetsTransactions.cs | 3 +++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 ++++++- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 10 ---------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 012d581..d30e954 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -181,7 +181,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction Manager.MyScene.AssetService.Store(asset); if (part.Inventory.UpdateInventoryItem(item)) + { + remoteClient.SendAgentAlertMessage("Notecard saved", false); part.GetProperties(remoteClient); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7661068..144de43 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -201,7 +201,9 @@ namespace OpenSim.Region.Framework.Scenes // Update item with new asset item.AssetID = asset.FullID; - group.UpdateInventoryItem(item); + if (group.UpdateInventoryItem(item)) + remoteClient.SendAgentAlertMessage("Notecard saved", false); + part.GetProperties(remoteClient); // Trigger rerunning of script (use TriggerRezScript event, see RezScript) @@ -1224,7 +1226,10 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, part, transactionID, currentItem); } if (part.Inventory.UpdateInventoryItem(itemInfo)) + { + remoteClient.SendAgentAlertMessage("Notecard saved", false); part.GetProperties(remoteClient); + } } } else diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2e13f90..4b9a2ad 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -630,16 +630,6 @@ namespace OpenSim.Region.Framework.Scenes { item.AssetID = m_items[item.ItemID].AssetID; } - else if ((InventoryType)item.Type == InventoryType.Notecard) - { - ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); - - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage( - "Notecard saved", false); - } - } m_items[item.ItemID] = item; m_inventorySerial++; -- cgit v1.1 From 50f327ef5c63959b7dcfbd4e19761f3a8a8038c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Apr 2010 21:34:42 +0100 Subject: minor: change a comment and replace some magic numbers with the AssetType enum --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index c4e8e09..d7120a5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7132,7 +7132,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP else { // TODO: Change this code to allow items other than notecards and scripts to be successfully - // shared with group. In fact, all this permissions checking should move to an IPermissionsModule + // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule if (part.OwnerID != AgentId) { m_log.WarnFormat( @@ -7194,7 +7194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // only to notecards and scripts. All // other asset types are always available // - if (assetRequestItem.AssetType == 10) + if (assetRequestItem.AssetType == (int)AssetType.LSLText) { if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId)) { @@ -7202,7 +7202,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } } - else if (assetRequestItem.AssetType == 7) + else if (assetRequestItem.AssetType == (int)AssetType.Notecard) { if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId)) { -- cgit v1.1 From 459323a931f6d4e23d813ef6414ea8e4d511dd76 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 21 Apr 2010 19:44:19 +0100 Subject: Make the detection cone in attachments face in the direction of the avatar, not the relative rotation of the attachment towards the avatar. --- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 2296379..4d7ead6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -302,6 +302,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins float dz; Quaternion q = SensePoint.RotationOffset; + if (SensePoint.ParentGroup.RootPart.IsAttachment) + { + // In attachments, the sensor cone always orients with the + // avatar rotation. This may include a nonzero elevation if + // in mouselook. + + ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); + q = avatar.Rotation; + } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); -- cgit v1.1