diff options
-rw-r--r-- | OpenSim/Data/IRegionData.cs | 5 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/007_GridStore.sql | 6 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 61 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IGridService.cs | 5 | ||||
-rw-r--r-- | prebuild.xml | 1 |
5 files changed, 75 insertions, 3 deletions
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 | |||
72 | RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false | 72 | RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false |
73 | NoDirectLogin = 8, // Region unavailable for direct logins (by name) | 73 | NoDirectLogin = 8, // Region unavailable for direct logins (by name) |
74 | Persistent = 16, // Don't remove on unregister | 74 | Persistent = 16, // Don't remove on unregister |
75 | LockedOut = 32 // Don't allow registration | 75 | LockedOut = 32, // Don't allow registration |
76 | NoMove = 64, // Don't allow moving this region | ||
77 | Reservation = 128, // This is an inactive reservation | ||
78 | Authenticate = 256 // Require authentication | ||
76 | } | 79 | } |
77 | } | 80 | } |
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 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
4 | |||
5 | COMMIT; | ||
6 | |||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4f93ce5..5c55c0b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -34,6 +34,7 @@ using log4net; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Data; | 36 | using OpenSim.Data; |
37 | using OpenSim.Server.Base; | ||
37 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
39 | using OpenMetaverse; | 40 | using OpenMetaverse; |
@@ -50,6 +51,8 @@ namespace OpenSim.Services.GridService | |||
50 | private static GridService m_RootInstance = null; | 51 | private static GridService m_RootInstance = null; |
51 | protected IConfigSource m_config; | 52 | protected IConfigSource m_config; |
52 | 53 | ||
54 | protected IAuthenticationService m_AuthenticationService = null; | ||
55 | |||
53 | public GridService(IConfigSource config) | 56 | public GridService(IConfigSource config) |
54 | : base(config) | 57 | : base(config) |
55 | { | 58 | { |
@@ -60,6 +63,14 @@ namespace OpenSim.Services.GridService | |||
60 | if (gridConfig != null) | 63 | if (gridConfig != null) |
61 | { | 64 | { |
62 | m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); | 65 | m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); |
66 | |||
67 | string authService = gridConfig.GetString("AuthenticationService", String.Empty); | ||
68 | |||
69 | if (authService != String.Empty) | ||
70 | { | ||
71 | Object[] args = new Object[] { config }; | ||
72 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); | ||
73 | } | ||
63 | } | 74 | } |
64 | 75 | ||
65 | if (m_RootInstance == null) | 76 | if (m_RootInstance == null) |
@@ -90,6 +101,46 @@ namespace OpenSim.Services.GridService | |||
90 | // This needs better sanity testing. What if regionInfo is registering in | 101 | // This needs better sanity testing. What if regionInfo is registering in |
91 | // overlapping coords? | 102 | // overlapping coords? |
92 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 103 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
104 | if (region != null) | ||
105 | { | ||
106 | // There is a preexisting record | ||
107 | // | ||
108 | // Get it's flags | ||
109 | // | ||
110 | OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]); | ||
111 | |||
112 | // Is this a reservation? | ||
113 | // | ||
114 | if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) | ||
115 | { | ||
116 | // Regions reserved for the null key cannot be taken. | ||
117 | // | ||
118 | if (region.Data["PrincipalID"] == UUID.Zero.ToString()) | ||
119 | return false; | ||
120 | |||
121 | // Treat it as an auth request | ||
122 | // | ||
123 | // NOTE: Fudging the flags value here, so these flags | ||
124 | // should not be used elsewhere. Don't optimize | ||
125 | // this with the later retrieval of the same flags! | ||
126 | // | ||
127 | rflags |= OpenSim.Data.RegionFlags.Authenticate; | ||
128 | } | ||
129 | |||
130 | if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) | ||
131 | { | ||
132 | // Can we authenticate at all? | ||
133 | // | ||
134 | if (m_AuthenticationService == null) | ||
135 | return false; | ||
136 | |||
137 | if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30)) | ||
138 | return false; | ||
139 | |||
140 | return false; | ||
141 | } | ||
142 | } | ||
143 | |||
93 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) | 144 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) |
94 | { | 145 | { |
95 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | 146 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", |
@@ -99,6 +150,9 @@ namespace OpenSim.Services.GridService | |||
99 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && | 150 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && |
100 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) | 151 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) |
101 | { | 152 | { |
153 | if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) | ||
154 | return false; | ||
155 | |||
102 | // Region reregistering in other coordinates. Delete the old entry | 156 | // Region reregistering in other coordinates. Delete the old entry |
103 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", | 157 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", |
104 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); | 158 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); |
@@ -119,10 +173,13 @@ namespace OpenSim.Services.GridService | |||
119 | 173 | ||
120 | if (region != null) | 174 | if (region != null) |
121 | { | 175 | { |
122 | if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) | 176 | int oldFlags = Convert.ToInt32(region.Data["flags"]); |
177 | if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) | ||
123 | return false; | 178 | return false; |
124 | 179 | ||
125 | rdata.Data["flags"] = region.Data["flags"]; // Preserve fields | 180 | oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; |
181 | |||
182 | rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags | ||
126 | } | 183 | } |
127 | else | 184 | else |
128 | { | 185 | { |
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 | |||
159 | public byte Access; | 159 | public byte Access; |
160 | public int Maturity; | 160 | public int Maturity; |
161 | public string RegionSecret; | 161 | public string RegionSecret; |
162 | public string Token; | ||
162 | 163 | ||
163 | public GridRegion() | 164 | public GridRegion() |
164 | { | 165 | { |
@@ -306,6 +307,7 @@ namespace OpenSim.Services.Interfaces | |||
306 | kvp["access"] = Access.ToString(); | 307 | kvp["access"] = Access.ToString(); |
307 | kvp["regionSecret"] = RegionSecret; | 308 | kvp["regionSecret"] = RegionSecret; |
308 | kvp["owner_uuid"] = EstateOwner.ToString(); | 309 | kvp["owner_uuid"] = EstateOwner.ToString(); |
310 | kvp["token"] = Token.ToString(); | ||
309 | // Maturity doesn't seem to exist in the DB | 311 | // Maturity doesn't seem to exist in the DB |
310 | return kvp; | 312 | return kvp; |
311 | } | 313 | } |
@@ -363,6 +365,9 @@ namespace OpenSim.Services.Interfaces | |||
363 | if (kvp.ContainsKey("owner_uuid")) | 365 | if (kvp.ContainsKey("owner_uuid")) |
364 | EstateOwner = new UUID(kvp["owner_uuid"].ToString()); | 366 | EstateOwner = new UUID(kvp["owner_uuid"].ToString()); |
365 | 367 | ||
368 | if (kvp.ContainsKey("token")) | ||
369 | Token = kvp["token"].ToString(); | ||
370 | |||
366 | } | 371 | } |
367 | } | 372 | } |
368 | 373 | ||
diff --git a/prebuild.xml b/prebuild.xml index fbb782a..284913a 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -1056,6 +1056,7 @@ | |||
1056 | <Reference name="OpenSim.Services.Base"/> | 1056 | <Reference name="OpenSim.Services.Base"/> |
1057 | <Reference name="OpenSim.Services.Connectors"/> | 1057 | <Reference name="OpenSim.Services.Connectors"/> |
1058 | <Reference name="OpenSim.Data"/> | 1058 | <Reference name="OpenSim.Data"/> |
1059 | <Reference name="OpenSim.Server.Base"/> | ||
1059 | <Reference name="Nini.dll" /> | 1060 | <Reference name="Nini.dll" /> |
1060 | <Reference name="log4net.dll"/> | 1061 | <Reference name="log4net.dll"/> |
1061 | 1062 | ||