From 0d5f182c0235139a7bb343bf9856e064cf19e2da Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:13:57 +0000 Subject: Add a handful of new region flags and a small migration --- OpenSim/Data/IRegionData.cs | 5 ++++- OpenSim/Data/MySQL/Resources/007_GridStore.sql | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Data/MySQL/Resources/007_GridStore.sql diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 140bc96..9ed5dd0 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs @@ -72,6 +72,9 @@ namespace OpenSim.Data RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false NoDirectLogin = 8, // Region unavailable for direct logins (by name) Persistent = 16, // Don't remove on unregister - LockedOut = 32 // Don't allow registration + LockedOut = 32, // Don't allow registration + NoMove = 64, // Don't allow moving this region + Reservation = 128, // This is an inactive reservation + Authenticate = 256 // Require authentication } } diff --git a/OpenSim/Data/MySQL/Resources/007_GridStore.sql b/OpenSim/Data/MySQL/Resources/007_GridStore.sql new file mode 100644 index 0000000..3f88d3d --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_GridStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; + +COMMIT; + -- cgit v1.1 From 344d27b19d4a1b0ca98a1e7cc4932eb996a9d59c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:23:59 +0000 Subject: Implement the NoMove behavior. Cause Reservation flag to be reset on first connect --- OpenSim/Services/GridService/GridService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4f93ce5..6e2c0d7 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -99,6 +99,9 @@ namespace OpenSim.Services.GridService if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) + return false; + // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); @@ -119,10 +122,13 @@ namespace OpenSim.Services.GridService if (region != null) { - if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + int oldFlags = Convert.ToInt32(region.Data["flags"]); + if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) return false; - rdata.Data["flags"] = region.Data["flags"]; // Preserve fields + oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; + + rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags } else { -- cgit v1.1 From d49cc7ca905a54f72707e5fa728c4dfa68a514fb Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:35:10 +0000 Subject: Implement "Reservation" flag behavior. --- OpenSim/Services/GridService/GridService.cs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6e2c0d7..6826940 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -90,6 +90,40 @@ namespace OpenSim.Services.GridService // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if (region != null) + { + // There is a preexisting record + // + // Get it's flags + // + OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]); + + // Is this a reservation? + // + if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) + { + // Regions reserved for the null key cannot be taken. + // + if (region.Data["PrincipalID"] == UUID.Zero.ToString()) + return false; + + // Treat it as an auth request + // + // NOTE: Fudging the flags value here, so these flags + // should not be used elsewhere. Don't optimize + // this with the later retrieval of the same flags! + // + rflags |= OpenSim.Data.RegionFlags.Authenticate; + } + + if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) + { + // TODO: Authenticate the principal + + return false; + } + } + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", -- cgit v1.1 From 686660650b4f5724fc0b4858d50ff4deeafb8ffe Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:57:31 +0000 Subject: Implement region registration with authentication --- OpenSim/Services/GridService/GridService.cs | 19 ++++++++++++++++++- OpenSim/Services/Interfaces/IGridService.cs | 5 +++++ prebuild.xml | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6826940..5c55c0b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -34,6 +34,7 @@ using log4net; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; +using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; @@ -50,6 +51,8 @@ namespace OpenSim.Services.GridService private static GridService m_RootInstance = null; protected IConfigSource m_config; + protected IAuthenticationService m_AuthenticationService = null; + public GridService(IConfigSource config) : base(config) { @@ -60,6 +63,14 @@ namespace OpenSim.Services.GridService if (gridConfig != null) { m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); + + string authService = gridConfig.GetString("AuthenticationService", String.Empty); + + if (authService != String.Empty) + { + Object[] args = new Object[] { config }; + m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); + } } if (m_RootInstance == null) @@ -118,7 +129,13 @@ namespace OpenSim.Services.GridService if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) { - // TODO: Authenticate the principal + // Can we authenticate at all? + // + if (m_AuthenticationService == null) + return false; + + if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30)) + return false; return false; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index cd27145..6b6b347 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -159,6 +159,7 @@ namespace OpenSim.Services.Interfaces public byte Access; public int Maturity; public string RegionSecret; + public string Token; public GridRegion() { @@ -306,6 +307,7 @@ namespace OpenSim.Services.Interfaces kvp["access"] = Access.ToString(); kvp["regionSecret"] = RegionSecret; kvp["owner_uuid"] = EstateOwner.ToString(); + kvp["token"] = Token.ToString(); // Maturity doesn't seem to exist in the DB return kvp; } @@ -363,6 +365,9 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("owner_uuid")) EstateOwner = new UUID(kvp["owner_uuid"].ToString()); + if (kvp.ContainsKey("token")) + Token = kvp["token"].ToString(); + } } diff --git a/prebuild.xml b/prebuild.xml index fbb782a..284913a 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1056,6 +1056,7 @@ + -- cgit v1.1