From c91753c065ec67491b94386b06d742a328ccffd4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Mar 2013 00:56:53 +0000 Subject: minor: Log number of region modules loaded from each plugin --- .../RegionModulesControllerPlugin.cs | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 633d005..510be37 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -85,16 +85,26 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController if (modulesConfig == null) modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); + Dictionary> loadedModules = new Dictionary>(); + // Scan modules and load all that aren't disabled foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) { + IList loadedModuleData; + + if (!loadedModules.ContainsKey(node.Addin)) + loadedModules.Add(node.Addin, new List { 0, 0, 0 }); + + loadedModuleData = loadedModules[node.Addin]; + if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) { if (CheckModuleEnabled(node, modulesConfig)) { m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); m_sharedModules.Add(node); + loadedModuleData[0]++; } } else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) @@ -103,14 +113,26 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); m_nonSharedModules.Add(node); + loadedModuleData[1]++; } } else { - m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); + m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); + loadedModuleData[2]++; } } + foreach (KeyValuePair> loadedModuleData in loadedModules) + { + m_log.InfoFormat( + "[REGIONMODULES]: From plugin {0}, (version {1}), loaded {2} modules, {3} shared, {4} non-shared {5} unknown", + loadedModuleData.Key.Id, + loadedModuleData.Key.Version, + loadedModuleData.Value[0] + loadedModuleData.Value[1] + loadedModuleData.Value[2], + loadedModuleData.Value[0], loadedModuleData.Value[1], loadedModuleData.Value[2]); + } + // Load and init the module. We try a constructor with a port // if a port was given, fall back to one without if there is // no port or the more specific constructor fails. -- cgit v1.1 From 1a98ce5f6480c65ae30db933941f1a0184b5bc84 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Mar 2013 01:06:08 +0000 Subject: minor: Quieten down the parts of the WebSocketEcho module logging for now where it tells us it is added/loaded/removed from regions --- .../Example/WebSocketEchoTest/WebSocketEchoModule.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs index 112ba4e..5bf0ed4 100644 --- a/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs +++ b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.OptionalModules.WebSocketEchoModule public class WebSocketEchoModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool enabled; public string Name { get { return "WebSocketEchoModule"; } } @@ -55,9 +56,9 @@ namespace OpenSim.Region.OptionalModules.WebSocketEchoModule public void Initialise(IConfigSource pConfig) { - enabled =(pConfig.Configs["WebSocketEcho"] != null); - if (enabled) - m_log.DebugFormat("[WebSocketEchoModule]: INITIALIZED MODULE"); + enabled = (pConfig.Configs["WebSocketEcho"] != null); +// if (enabled) +// m_log.DebugFormat("[WebSocketEchoModule]: INITIALIZED MODULE"); } /// @@ -158,17 +159,17 @@ namespace OpenSim.Region.OptionalModules.WebSocketEchoModule public void AddRegion(Scene scene) { - m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); +// m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) { - m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); +// m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) { - m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} LOADED", scene.RegionInfo.RegionName); +// m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} LOADED", scene.RegionInfo.RegionName); } } } \ No newline at end of file -- cgit v1.1 From 4999d7920a63af99c6bba53134d4c0e891b99573 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Mar 2013 01:23:01 +0000 Subject: Revert "Removed more vars from [Startup]. I think these were already moved elsewhere, because I can't find any reference to them in the code." This reverts commit efa722786509bd8e02e23f11da974b4282dbd185. --- bin/OpenSim.ini.example | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 0eb43a2..16e314b 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -256,6 +256,26 @@ ;; default is false ; TelehubAllowLandmark = false + ;# {AllowedClients} {} {Bar (|) separated list of allowed clients} {} + ;; Bar (|) separated list of viewers which may gain access to the regions. + ;; One can use a substring of the viewer name to enable only certain + ;; versions + ;; Example: Agent uses the viewer "Imprudence 1.3.2.0" + ;; - "Imprudence" has access + ;; - "Imprudence 1.3" has access + ;; - "Imprudence 1.3.1" has no access + ; AllowedViewerList = + + ;# {BannedClients} {} {Bar (|) separated list of banned clients} {} + ;# Bar (|) separated list of viewers which may not gain access to the regions. + ;; One can use a Substring of the viewer name to disable only certain + ;; versions + ;; Example: Agent uses the viewer "Imprudence 1.3.2.0" + ;; - "Imprudence" has no access + ;; - "Imprudence 1.3" has no access + ;; - "Imprudence 1.3.1" has access + ; BannedViewerList = + [Map] ;# {GenerateMaptiles} {} {Generate map tiles?} {true false} true ;; Map tile options. -- cgit v1.1 From 1bc8692a999f4e80b90b9a1eb7c7428b2e74214e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Mar 2013 01:43:54 +0000 Subject: Move AllowedClients and BannedClients section to new [AccessControl] section in OpenSim.ini from [Startup] This change also corrects the setting names - they were actually wrong (though the text in {} was correct). If there are settings in [Startup] they will continue to be used and anything there will override settings in [AccessControl] --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++++++-- bin/OpenSim.ini.example | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5b61538..14dac7a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -932,7 +932,12 @@ namespace OpenSim.Region.Framework.Scenes } } - string grant = startupConfig.GetString("AllowedClients", String.Empty); + string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "Startup" }; + + string grant + = Util.GetConfigVarFromSections( + config, "AllowedClients", possibleAccessControlConfigSections, ""); + if (grant.Length > 0) { foreach (string viewer in grant.Split('|')) @@ -941,7 +946,10 @@ namespace OpenSim.Region.Framework.Scenes } } - grant = startupConfig.GetString("BannedClients", String.Empty); + grant + = Util.GetConfigVarFromSections( + config, "BannedClients", possibleAccessControlConfigSections, ""); + if (grant.Length > 0) { foreach (string viewer in grant.Split('|')) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 16e314b..eab1fce 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -256,6 +256,8 @@ ;; default is false ; TelehubAllowLandmark = false + +[AccessControl] ;# {AllowedClients} {} {Bar (|) separated list of allowed clients} {} ;; Bar (|) separated list of viewers which may gain access to the regions. ;; One can use a substring of the viewer name to enable only certain @@ -264,7 +266,7 @@ ;; - "Imprudence" has access ;; - "Imprudence 1.3" has access ;; - "Imprudence 1.3.1" has no access - ; AllowedViewerList = + ; AllowedClients = ;# {BannedClients} {} {Bar (|) separated list of banned clients} {} ;# Bar (|) separated list of viewers which may not gain access to the regions. @@ -274,7 +276,8 @@ ;; - "Imprudence" has no access ;; - "Imprudence 1.3" has no access ;; - "Imprudence 1.3.1" has access - ; BannedViewerList = + ; BannedClients = + [Map] ;# {GenerateMaptiles} {} {Generate map tiles?} {true false} true @@ -310,6 +313,7 @@ ;; got a large number of objects, so you can turn it off here if you'd like. ; DrawPrimOnMapTile = true + [Permissions] ;# {permissionmodules} {} {Permission modules to use (may specify multiple modules, separated by comma} {} DefaultPermissionsModule ;; Permission modules to use, separated by comma. -- cgit v1.1 From b47ffb5dc40418705bb16669e47130aeddeaec6c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 2 Mar 2013 13:02:02 -0800 Subject: Added existance and default value for [XEngine]MinTimerInterval to OpenSimDefaults.ini --- bin/OpenSimDefaults.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 091107f..417150a 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1400,6 +1400,10 @@ ; up the system to malicious scripters ; NotecardLineReadCharsMax = 255 + ; Minimum settable timer interval. Any timer setting less than this is + ; rounded up to this minimum interval. + ; MinTimerInterval = 0.5 + ; Sensor settings SensorMaxRange = 96.0 SensorMaxResults = 16 -- cgit v1.1 From b0985f7019d7fc9ea6bb32c4f1d174e6f635c9e3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Mar 2013 17:53:57 -0800 Subject: Fixed typos in TempAttachmentsModule. No changes. --- .../Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index d7fb272..1e7bc02 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments if (m_console != null) { - m_console.AddCommand("TempATtachModule", false, "set auto_grant_attach_perms", "set auto_grant_attach_perms true|false", "Allow objects owned by the region owner os estate managers to obtain attach permissions without asking the user", SetAutoGrantAttachPerms); + m_console.AddCommand("TempAttachModule", false, "set auto_grant_attach_perms", "set auto_grant_attach_perms true|false", "Allow objects owned by the region owner or estate managers to obtain attach permissions without asking the user", SetAutoGrantAttachPerms); } } else -- cgit v1.1 From 66d74e76b19a6586991fdada2661514143d9585b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 3 Mar 2013 09:40:44 -0500 Subject: Add method to remove JsonRpc Handlers from the server --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 ++++++ OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 70c531c..58312ab 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1912,6 +1912,12 @@ namespace OpenSim.Framework.Servers.HttpServer m_rpcHandlers.Remove(method); } + public void RemoveJsonRPCHandler(string method) + { + lock(jsonRpcHandlers) + jsonRpcHandlers.Remove(method); + } + public bool RemoveLLSDHandler(string path, LLSDMethod handler) { lock (m_llsdHandlers) diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 71ca3ff..d162bc1 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -140,6 +140,8 @@ namespace OpenSim.Framework.Servers.HttpServer void RemoveStreamHandler(string httpMethod, string path); void RemoveXmlRPCHandler(string method); + + void RemoveJsonRPCHandler(string method); string GetHTTP404(string host); -- cgit v1.1 From aadf7d32d1b86e56e26243b8e32889369c2eafb2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 4 Mar 2013 12:52:28 -0800 Subject: GridUserService was missing from [Gatekeeper] --- bin/Robust.HG.ini.example | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 91dea8c..7746ebc 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -431,6 +431,7 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService" PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" GridService = "OpenSim.Services.GridService.dll:GridService" AuthenticationService = "OpenSim.Services.Connectors.dll:AuthenticationServicesConnector" SimulationService ="OpenSim.Services.Connectors.dll:SimulationServiceConnector" -- cgit v1.1 From fa9f4ef1baca14ed4ee20712219932f1e6e09990 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 4 Mar 2013 23:20:00 +0000 Subject: Fix issue in the mesh upload flag module where the ID of the last agent to request the capability was always used instead of the original requesting agent for each cap. Should address http://opensimulator.org/mantis/view.php?id=6556 --- .../Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 33b1f77..45d33cd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.ClientStack.Linden public bool Enabled { get; private set; } private Scene m_scene; - private UUID m_agentID; #region ISharedRegionModule Members @@ -118,25 +117,26 @@ namespace OpenSim.Region.ClientStack.Linden public void RegisterCaps(UUID agentID, Caps caps) { IRequestHandler reqHandler - = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), MeshUploadFlag, "MeshUploadFlag", agentID.ToString()); + = new RestHTTPHandler( + "GET", "/CAPS/" + UUID.Random(), ht => MeshUploadFlag(ht, agentID), "MeshUploadFlag", agentID.ToString()); caps.RegisterHandler("MeshUploadFlag", reqHandler); - m_agentID = agentID; + } - private Hashtable MeshUploadFlag(Hashtable mDhttpMethod) + private Hashtable MeshUploadFlag(Hashtable mDhttpMethod, UUID agentID) { // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); OSDMap data = new OSDMap(); - ScenePresence sp = m_scene.GetScenePresence(m_agentID); + ScenePresence sp = m_scene.GetScenePresence(agentID); data["username"] = sp.Firstname + "." + sp.Lastname; data["display_name_next_update"] = new OSDDate(DateTime.Now); data["legacy_first_name"] = sp.Firstname; data["mesh_upload_status"] = "valid"; data["display_name"] = sp.Firstname + " " + sp.Lastname; data["legacy_last_name"] = sp.Lastname; - data["id"] = m_agentID; + data["id"] = agentID; data["is_display_name_default"] = true; //Send back data -- cgit v1.1 From 7556b42d7a208e3e7dfc23550293bad243533328 Mon Sep 17 00:00:00 2001 From: teravus Date: Mon, 4 Mar 2013 21:26:26 -0500 Subject: * Update LibOMV to f8f8e616b37a7ea22b7922b2331999bc06725bf9 * Add zero length blocks to the new packet blocks to remain compatible with older viewers and avoid a NullRef when _packets_.cs calls the Length parameter.. which adds up the Length property all of the blocks. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 6 ++++-- bin/OpenMetaverse.StructuredData.dll | Bin 102400 -> 114688 bytes bin/OpenMetaverse.dll | Bin 1765376 -> 1925120 bytes bin/OpenMetaverseTypes.dll | Bin 114688 -> 122880 bytes 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 5675870..6742d99 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -790,7 +790,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP handshake.RegionInfo3.ColoName = Utils.EmptyBytes; handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType); handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes; - + handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[0]; + OutPacket(handshake, ThrottleOutPacketType.Task); } @@ -3571,6 +3572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP avp.Sender.IsTrial = false; avp.Sender.ID = agentID; + avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); OutPacket(avp, ThrottleOutPacketType.Task); } @@ -4192,7 +4194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP pack.Stat = stats.StatsBlock; pack.Header.Reliable = false; - + pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0]; OutPacket(pack, ThrottleOutPacketType.Task); } diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index 5c0b3c6..c7216ce 100755 Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll index 511096e..3e210ba 100755 Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll index 8bc8885..6cc4c5a 100755 Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ -- cgit v1.1 From 69fbcdf14c00fc882477b18af962a932db0d54ee Mon Sep 17 00:00:00 2001 From: teravus Date: Tue, 5 Mar 2013 00:04:09 -0500 Subject: * Add a Max Payload size property to the Websocket Server Handler. If you would like to restrict the maximum packet size, (and therefore protect against Memory DOSing) then you should set this. I defaulted it to 40MB. This means that in theory, a malicious user could connect and send a packet that claims that the payload is up to 40 mb (even if it doesn't actually turn out to be 40mb. More testing needs to be done on it where the packets are maliciously malformed. --- .../Servers/HttpServer/WebsocketServerHandler.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs index bb8825b..ee96b47 100644 --- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs @@ -108,6 +108,7 @@ namespace OpenSim.Framework.Servers.HttpServer private int _bufferLength; private bool _closing; private bool _upgraded; + private int _maxPayloadBytes = 41943040; private const string HandshakeAcceptText = "HTTP/1.1 101 Switching Protocols\r\n" + @@ -196,6 +197,15 @@ namespace OpenSim.Framework.Servers.HttpServer } /// + /// Max Payload Size in bytes. Defaults to 40MB, but could be set upon connection before calling handshake and upgrade. + /// + public int MaxPayloadSize + { + get { return _maxPayloadBytes; } + set { _maxPayloadBytes = value; } + } + + /// /// This triggers the websocket start the upgrade process /// public void HandshakeAndUpgrade() @@ -367,7 +377,12 @@ namespace OpenSim.Framework.Servers.HttpServer if (headerread) { _socketState.FrameComplete = false; - + if (pheader.PayloadLen > (ulong) _maxPayloadBytes) + { + Close("Invalid Payload size"); + + return; + } if (pheader.PayloadLen > 0) { if ((int) pheader.PayloadLen > _bufferPosition - offset) -- cgit v1.1 From ccd6f443e1092cb410f565e921f7cf4dd8cd2dac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Mar 2013 23:47:36 +0000 Subject: Get attachment script state before taking sp.AttachmentsSyncLock() to avoid race conditions between closing agents and scripts that may be doing attachment manipulation. This is in an effort to resolve http://opensimulator.org/mantis/view.php?id=6557 --- .../Avatar/Attachments/AttachmentsModule.cs | 301 +++++++++++---------- 1 file changed, 161 insertions(+), 140 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 8a3eeaa..3ccf9f4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -241,12 +241,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); + List attachments = sp.GetAttachments(); + + if (attachments.Count <= 0) + return; + + Dictionary scriptStates = new Dictionary(); + + foreach (SceneObjectGroup so in attachments) + { + // Scripts MUST be snapshotted before the object is + // removed from the scene because doing otherwise will + // clobber the run flag + // This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from + // scripts performing attachment operations at the same time. Getting object states stops the scripts. + scriptStates[so] = PrepareScriptInstanceForSave(so, false); + } + lock (sp.AttachmentsSyncLock) { - foreach (SceneObjectGroup so in sp.GetAttachments()) - { - UpdateDetachedObject(sp, so); - } + foreach (SceneObjectGroup so in attachments) + UpdateDetachedObject(sp, so, scriptStates[so]); sp.ClearAttachments(); } @@ -285,32 +300,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) { - lock (sp.AttachmentsSyncLock) - { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", // group.Name, group.LocalId, sp.Name, attachmentPt, silent); - if (group.GetSittingAvatarsCount() != 0) - { + if (group.GetSittingAvatarsCount() != 0) + { // m_log.WarnFormat( // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it", // group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount()); - - return false; - } - - if (sp.GetAttachments(attachmentPt).Contains(group)) - { - // m_log.WarnFormat( - // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", - // group.Name, group.LocalId, sp.Name, AttachmentPt); - - return false; - } - + + return false; + } + + if (sp.GetAttachments(attachmentPt).Contains(group)) + { +// m_log.WarnFormat( +// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", +// group.Name, group.LocalId, sp.Name, AttachmentPt); + + return false; + } + + // Remove any previous attachments + List existingAttachments = sp.GetAttachments(attachmentPt); + string existingAttachmentScriptState = null; + + // At the moment we can only deal with a single attachment + if (existingAttachments.Count != 0 && existingAttachments[0].FromItemID != UUID.Zero) + DetachSingleAttachmentToInv(sp, group); + + lock (sp.AttachmentsSyncLock) + { Vector3 attachPos = group.AbsolutePosition; - + // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim attachmentPt &= 0x7f; @@ -322,14 +345,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { attachPos = Vector3.Zero; } - + // AttachmentPt 0 means the client chose to 'wear' the attachment. if (attachmentPt == 0) { // Check object for stored attachment point attachmentPt = group.AttachmentPoint; } - + // if we still didn't find a suitable attachment point....... if (attachmentPt == 0) { @@ -337,13 +360,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments attachmentPt = (uint)AttachmentPoint.LeftHand; attachPos = Vector3.Zero; } - + group.AttachmentPoint = attachmentPt; group.AbsolutePosition = attachPos; if (sp.PresenceType != PresenceType.Npc) UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp); - + AttachToAgent(sp, group, attachmentPt, attachPos, silent); } @@ -352,21 +375,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) { - // Remove any previous attachments - List attachments = sp.GetAttachments(attachmentPt); - - // At the moment we can only deal with a single attachment - if (attachments.Count != 0) - { - if (attachments[0].FromItemID != UUID.Zero) - DetachSingleAttachmentToInvInternal(sp, attachments[0]); - // Error logging commented because UUID.Zero now means temp attachment -// else -// m_log.WarnFormat( -// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", -// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); - } - // Add the new attachment to inventory if we don't already have it. if (!temp) { @@ -426,12 +434,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name); - lock (sp.AttachmentsSyncLock) + + foreach (KeyValuePair rez in rezlist) { - foreach (KeyValuePair rez in rezlist) - { - RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value); - } + RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value); } } @@ -511,25 +517,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) { + if (so.AttachedAvatar != sp.UUID) + { + m_log.WarnFormat( + "[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}", + so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName); + + return; + } + + // Scripts MUST be snapshotted before the object is + // removed from the scene because doing otherwise will + // clobber the run flag + // This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from + // scripts performing attachment operations at the same time. Getting object states stops the scripts. + string scriptedState = PrepareScriptInstanceForSave(so, true); + lock (sp.AttachmentsSyncLock) { // Save avatar attachment information // m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); - if (so.AttachedAvatar != sp.UUID) - { - m_log.WarnFormat( - "[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}", - so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName); - - return; - } - bool changed = sp.Appearance.DetachAttachment(so.FromItemID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); - DetachSingleAttachmentToInvInternal(sp, so); + sp.RemoveAttachment(so); + UpdateDetachedObject(sp, so, scriptedState); } } @@ -739,8 +753,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return newItem; } - private string GetObjectScriptStates(SceneObjectGroup grp) + /// + /// Prepares the script instance for save. + /// + /// + /// This involves triggering the detach event and getting the script state (which also stops the script) + /// This MUST be done outside sp.AttachmentsSyncLock, since otherwise there is a chance of deadlock if a + /// running script is performing attachment operations. + /// + /// + /// The script state ready for persistence. + /// + /// + /// + /// + /// If true, then fire the script event before we save its state. + /// + private string PrepareScriptInstanceForSave(SceneObjectGroup grp, bool fireDetachEvent) { + if (fireDetachEvent) + m_scene.EventManager.TriggerOnAttach(grp.LocalId, grp.FromItemID, UUID.Zero); + using (StringWriter sw = new StringWriter()) { using (XmlTextWriter writer = new XmlTextWriter(sw)) @@ -752,7 +785,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so) + private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so, string scriptedState) { // Don't save attachments for HG visitors, it // messes up their inventory. When a HG visitor logs @@ -765,11 +798,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments && (m_scene.UserManagementModule == null || m_scene.UserManagementModule.IsLocalGridUser(sp.UUID)); - // Scripts MUST be snapshotted before the object is - // removed from the scene because doing otherwise will - // clobber the run flag - string scriptedState = GetObjectScriptStates(so); - // Remove the object from the scene so no more updates // are sent. Doing this before the below changes will ensure // updates can't cause "HUD artefacts" @@ -793,91 +821,87 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.RemoveScriptInstances(true); } - private void DetachSingleAttachmentToInvInternal(IScenePresence sp, SceneObjectGroup so) - { - // m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name); - - m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero); - sp.RemoveAttachment(so); - - UpdateDetachedObject(sp, so); - } - private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) { if (m_invAccessModule == null) return null; - lock (sp.AttachmentsSyncLock) + SceneObjectGroup objatt; + + if (itemID != UUID.Zero) + objatt = m_invAccessModule.RezObject(sp.ControllingClient, + itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, + false, false, sp.UUID, true); + else + objatt = m_invAccessModule.RezObject(sp.ControllingClient, + null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, + false, false, sp.UUID, true); + + if (objatt == null) { - SceneObjectGroup objatt; + m_log.WarnFormat( + "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", + itemID, sp.Name, attachmentPt); - if (itemID != UUID.Zero) - objatt = m_invAccessModule.RezObject(sp.ControllingClient, - itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, sp.UUID, true); - else - objatt = m_invAccessModule.RezObject(sp.ControllingClient, - null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, sp.UUID, true); + return null; + } - if (objatt != null) - { + // Remove any previous attachments + List attachments = sp.GetAttachments(attachmentPt); + string previousAttachmentScriptedState = null; + + // At the moment we can only deal with a single attachment + if (attachments.Count != 0) + DetachSingleAttachmentToInv(sp, attachments[0]); + + lock (sp.AttachmentsSyncLock) + { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", // objatt.Name, sp.Name, attachmentPt, m_scene.Name); - // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. - objatt.HasGroupChanged = false; - bool tainted = false; - if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) - tainted = true; - - // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal - // course of events. If not, then it's probably not worth trying to recover the situation - // since this is more likely to trigger further exceptions and confuse later debugging. If - // exceptions can be thrown in expected error conditions (not NREs) then make this consistent - // since other normal error conditions will simply return false instead. - // This will throw if the attachment fails - try - { - AttachObjectInternal(sp, objatt, attachmentPt, false, false); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", - objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); - - // Make sure the object doesn't stick around and bail - sp.RemoveAttachment(objatt); - m_scene.DeleteSceneObject(objatt, false); - return null; - } + // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. + objatt.HasGroupChanged = false; + bool tainted = false; + if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) + tainted = true; + + // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal + // course of events. If not, then it's probably not worth trying to recover the situation + // since this is more likely to trigger further exceptions and confuse later debugging. If + // exceptions can be thrown in expected error conditions (not NREs) then make this consistent + // since other normal error conditions will simply return false instead. + // This will throw if the attachment fails + try + { + AttachObjectInternal(sp, objatt, attachmentPt, false, false); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", + objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); - if (tainted) - objatt.HasGroupChanged = true; + // Make sure the object doesn't stick around and bail + sp.RemoveAttachment(objatt); + m_scene.DeleteSceneObject(objatt, false); + return null; + } - // Fire after attach, so we don't get messy perms dialogs - // 4 == AttachedRez - objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); - objatt.ResumeScripts(); + if (tainted) + objatt.HasGroupChanged = true; - // Do this last so that event listeners have access to all the effects of the attachment - m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); + // Fire after attach, so we don't get messy perms dialogs + // 4 == AttachedRez + objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); + objatt.ResumeScripts(); - return objatt; - } - else - { - m_log.WarnFormat( - "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", - itemID, sp.Name, attachmentPt); - } - } + // Do this last so that event listeners have access to all the effects of the attachment + m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); - return null; + return objatt; + } } /// @@ -1027,17 +1051,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp != null) { - lock (sp.AttachmentsSyncLock) + List attachments = sp.GetAttachments(); + + foreach (SceneObjectGroup group in attachments) { - List attachments = sp.GetAttachments(); - - foreach (SceneObjectGroup group in attachments) + if (group.FromItemID == itemID && group.FromItemID != UUID.Zero) { - if (group.FromItemID == itemID && group.FromItemID != UUID.Zero) - { - DetachSingleAttachmentToInv(sp, group); - return; - } + DetachSingleAttachmentToInv(sp, group); + return; } } } @@ -1055,4 +1076,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments #endregion } -} +} \ No newline at end of file -- cgit v1.1 From b272b91317b1fd6c01aee57a0086a26dc233b03e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Mar 2013 23:59:39 +0000 Subject: minor: Fix mono compiler warning in MonitorModule --- OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 4c9ee06..64feec1 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -414,8 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring } private void RegisterStatsManagerRegionStatistics() { - string regionName = m_scene.RegionInfo.RegionName; - MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); }); MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); }); MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); }); -- cgit v1.1