From 8fdf70b87e51bdd2035f5ab54a335fbb50d79e80 Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Wed, 16 Oct 2013 20:15:04 -0500 Subject: * Fixes mantis mantis 0006803 [PGSQL] - Simulator crashes - Mono.Security.dll missing. The root of the issue is that the Postgres driver relies on Mono.Security.dll from the mono project. Unfortunately, when using Mono, including the dll in the distribution causes conflicts. This solution puts Mono.Security.dll in bin/lib/NET/ and, if windows .NET is the runtime, informs the assembly loader to load bin/lib/NET/Mono.Security.dll when .NET is scanning for the Mono.Security namespace. On Mono, the included Mono.Security assembly is ignored. --- OpenSim/Data/PGSQL/PGSQLFramework.cs | 23 +++++++++++++++++++++++ OpenSim/Data/PGSQL/PGSQLManager.cs | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/PGSQL/PGSQLFramework.cs b/OpenSim/Data/PGSQL/PGSQLFramework.cs index 494b0aa..48f8dd3 100644 --- a/OpenSim/Data/PGSQL/PGSQLFramework.cs +++ b/OpenSim/Data/PGSQL/PGSQLFramework.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Data; +using System.Reflection; using OpenMetaverse; using OpenSim.Framework; using Npgsql; @@ -50,8 +51,30 @@ namespace OpenSim.Data.PGSQL protected PGSqlFramework(string connectionString) { m_connectionString = connectionString; + InitializeMonoSecurity(); } + public void InitializeMonoSecurity() + { + if (!Util.IsPlatformMono) + { + AppDomain currentDomain = AppDomain.CurrentDomain; + currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + } + } + + private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args) + { + Assembly MyAssembly = null; + + if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security") + { + MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll"); + } + + //Return the loaded assembly. + return MyAssembly; + } ////////////////////////////////////////////////////////////// // // All non queries are funneled through one connection diff --git a/OpenSim/Data/PGSQL/PGSQLManager.cs b/OpenSim/Data/PGSQL/PGSQLManager.cs index 3ddaf38..2084fe9 100644 --- a/OpenSim/Data/PGSQL/PGSQLManager.cs +++ b/OpenSim/Data/PGSQL/PGSQLManager.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Data; using System.IO; using System.Reflection; +using OpenSim.Framework; using log4net; using OpenMetaverse; using Npgsql; @@ -56,6 +57,29 @@ namespace OpenSim.Data.PGSQL public PGSQLManager(string connection) { connectionString = connection; + InitializeMonoSecurity(); + } + + public void InitializeMonoSecurity() + { + if (!Util.IsPlatformMono) + { + AppDomain currentDomain = AppDomain.CurrentDomain; + currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + } + } + + private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args) + { + Assembly MyAssembly = null; + + if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security") + { + MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll"); + } + + //Return the loaded assembly. + return MyAssembly; } /// -- cgit v1.1 From f83343d3022d568f4fdbbfa79fee867ba4d2e9ec Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Wed, 16 Oct 2013 21:20:11 -0500 Subject: * One More thing, add an appdomain data element to ensure that we don't duplicate the assembly resolving. --- OpenSim/Data/PGSQL/PGSQLFramework.cs | 10 ++++++++-- OpenSim/Data/PGSQL/PGSQLManager.cs | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/PGSQL/PGSQLFramework.cs b/OpenSim/Data/PGSQL/PGSQLFramework.cs index 48f8dd3..1028e4e 100644 --- a/OpenSim/Data/PGSQL/PGSQLFramework.cs +++ b/OpenSim/Data/PGSQL/PGSQLFramework.cs @@ -58,8 +58,14 @@ namespace OpenSim.Data.PGSQL { if (!Util.IsPlatformMono) { - AppDomain currentDomain = AppDomain.CurrentDomain; - currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + + if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null) + { + AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true"); + + AppDomain currentDomain = AppDomain.CurrentDomain; + currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + } } } diff --git a/OpenSim/Data/PGSQL/PGSQLManager.cs b/OpenSim/Data/PGSQL/PGSQLManager.cs index 2084fe9..97f40b2 100644 --- a/OpenSim/Data/PGSQL/PGSQLManager.cs +++ b/OpenSim/Data/PGSQL/PGSQLManager.cs @@ -64,8 +64,13 @@ namespace OpenSim.Data.PGSQL { if (!Util.IsPlatformMono) { - AppDomain currentDomain = AppDomain.CurrentDomain; - currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null) + { + AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true"); + + AppDomain currentDomain = AppDomain.CurrentDomain; + currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); + } } } -- cgit v1.1 From 67ffb64764aa109eee479444318b095730644c6d Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Wed, 16 Oct 2013 23:38:13 -0300 Subject: Corrected estateID to EstateID on getEstates function at PGSQLEstateData.cs --- OpenSim/Data/PGSQL/PGSQLEstateData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/PGSQL/PGSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs index 141b8ed..5ad0eaa 100644 --- a/OpenSim/Data/PGSQL/PGSQLEstateData.cs +++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs @@ -452,7 +452,7 @@ namespace OpenSim.Data.PGSQL public List GetEstates(string search) { List result = new List(); - string sql = "select \"estateID\" from estate_settings where lower(\"EstateName\") = lower(:EstateName)"; + string sql = "select \"EstateID\" from estate_settings where lower(\"EstateName\") = lower(:EstateName)"; using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) { conn.Open(); -- cgit v1.1