diff options
Diffstat (limited to '')
4 files changed, 189 insertions, 41 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 514a65b..f9e2b2f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -433,11 +433,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
433 | 433 | ||
434 | string reason; | 434 | string reason; |
435 | string version; | 435 | string version; |
436 | if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) | 436 | if (!m_aScene.SimulationService.QueryAccess( |
437 | finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) | ||
437 | { | 438 | { |
438 | sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason); | 439 | sp.ControllingClient.SendTeleportFailed(reason); |
439 | ResetFromTransit(sp.UUID); | 440 | ResetFromTransit(sp.UUID); |
440 | 441 | ||
442 | m_log.DebugFormat( | ||
443 | "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", | ||
444 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); | ||
445 | |||
441 | return; | 446 | return; |
442 | } | 447 | } |
443 | 448 | ||
@@ -480,10 +485,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
480 | bool logout = false; | 485 | bool logout = false; |
481 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | 486 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) |
482 | { | 487 | { |
483 | sp.ControllingClient.SendTeleportFailed( | 488 | sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", reason)); |
484 | String.Format("Teleport refused: {0}", reason)); | ||
485 | ResetFromTransit(sp.UUID); | 489 | ResetFromTransit(sp.UUID); |
486 | 490 | ||
491 | m_log.DebugFormat( | ||
492 | "[ENTITY TRANSFER MODULE]: Teleport of {0} from {1} to {2} was refused because {3}", | ||
493 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); | ||
494 | |||
487 | return; | 495 | return; |
488 | } | 496 | } |
489 | 497 | ||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 190f63b..8c97f58 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -450,19 +450,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
450 | } | 450 | } |
451 | 451 | ||
452 | /// <summary> | 452 | /// <summary> |
453 | /// Is the given user an administrator (in other words, a god)? | 453 | /// Is the user regarded as an administrator? |
454 | /// </summary> | 454 | /// </summary> |
455 | /// <param name="user"></param> | 455 | /// <param name="user"></param> |
456 | /// <returns></returns> | 456 | /// <returns></returns> |
457 | protected bool IsAdministrator(UUID user) | 457 | protected bool IsAdministrator(UUID user) |
458 | { | 458 | { |
459 | if (user == UUID.Zero) return false; | 459 | if (user == UUID.Zero) |
460 | 460 | return false; | |
461 | if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) | 461 | |
462 | { | 462 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) |
463 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) | 463 | return true; |
464 | return true; | ||
465 | } | ||
466 | 464 | ||
467 | if (IsEstateManager(user) && m_RegionManagerIsGod) | 465 | if (IsEstateManager(user) && m_RegionManagerIsGod) |
468 | return true; | 466 | return true; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 34362bf..8a6a6b4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -4139,35 +4139,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4139 | 4139 | ||
4140 | switch (m_scene.SpawnPointRouting) | 4140 | switch (m_scene.SpawnPointRouting) |
4141 | { | 4141 | { |
4142 | case "closest": | ||
4143 | |||
4144 | float distance = 9999; | ||
4145 | int closest = -1; | ||
4146 | |||
4147 | for (int i = 0; i < spawnPoints.Length; i++) | ||
4148 | { | ||
4149 | Vector3 spawnPosition = spawnPoints[i].GetLocation( | ||
4150 | telehub.AbsolutePosition, | ||
4151 | telehub.GroupRotation | ||
4152 | ); | ||
4153 | Vector3 offset = spawnPosition - pos; | ||
4154 | float d = Vector3.Mag(offset); | ||
4155 | if (d >= distance) | ||
4156 | continue; | ||
4157 | ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); | ||
4158 | if (land == null) | ||
4159 | continue; | ||
4160 | if (land.IsEitherBannedOrRestricted(UUID)) | ||
4161 | continue; | ||
4162 | distance = d; | ||
4163 | closest = i; | ||
4164 | } | ||
4165 | if (closest == -1) | ||
4166 | return; | ||
4167 | |||
4168 | pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | ||
4169 | return; | ||
4170 | |||
4171 | case "random": | 4142 | case "random": |
4172 | 4143 | ||
4173 | do | 4144 | do |
@@ -4219,7 +4190,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
4219 | return; | 4190 | return; |
4220 | 4191 | ||
4221 | default: | 4192 | default: |
4193 | case "closest": | ||
4194 | |||
4195 | float distance = 9999; | ||
4196 | int closest = -1; | ||
4197 | |||
4198 | for (int i = 0; i < spawnPoints.Length; i++) | ||
4199 | { | ||
4200 | Vector3 spawnPosition = spawnPoints[i].GetLocation( | ||
4201 | telehub.AbsolutePosition, | ||
4202 | telehub.GroupRotation | ||
4203 | ); | ||
4204 | Vector3 offset = spawnPosition - pos; | ||
4205 | float d = Vector3.Mag(offset); | ||
4206 | if (d >= distance) | ||
4207 | continue; | ||
4208 | ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); | ||
4209 | if (land == null) | ||
4210 | continue; | ||
4211 | if (land.IsEitherBannedOrRestricted(UUID)) | ||
4212 | continue; | ||
4213 | distance = d; | ||
4214 | closest = i; | ||
4215 | } | ||
4216 | if (closest == -1) | ||
4217 | return; | ||
4218 | |||
4219 | pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | ||
4222 | return; | 4220 | return; |
4221 | |||
4223 | } | 4222 | } |
4224 | } | 4223 | } |
4225 | } | 4224 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index ea4fb66..41bff7f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
37 | using OpenSim.Region.CoreModules.Framework; | 37 | using OpenSim.Region.CoreModules.Framework; |
38 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | 38 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; |
39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
40 | using OpenSim.Region.CoreModules.World.Permissions; | ||
40 | using OpenSim.Tests.Common; | 41 | using OpenSim.Tests.Common; |
41 | using OpenSim.Tests.Common.Mock; | 42 | using OpenSim.Tests.Common.Mock; |
42 | using System.IO; | 43 | using System.IO; |
@@ -161,6 +162,148 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
161 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | 162 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
162 | } | 163 | } |
163 | 164 | ||
165 | /// <summary> | ||
166 | /// Test teleport procedures when the target simulator returns false when queried about access. | ||
167 | /// </summary> | ||
168 | [Test] | ||
169 | public void TestSameSimulatorSeparatedRegionsQueryAccessFails() | ||
170 | { | ||
171 | TestHelpers.InMethod(); | ||
172 | // TestHelpers.EnableLogging(); | ||
173 | |||
174 | UUID userId = TestHelpers.ParseTail(0x1); | ||
175 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); | ||
176 | |||
177 | EntityTransferModule etm = new EntityTransferModule(); | ||
178 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
179 | |||
180 | IConfigSource config = new IniConfigSource(); | ||
181 | config.AddConfig("Modules"); | ||
182 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); | ||
183 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); | ||
184 | |||
185 | config.AddConfig("EntityTransfer"); | ||
186 | |||
187 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
188 | // for a callback from the destination scene before removing its avatar data. | ||
189 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); | ||
190 | |||
191 | config.AddConfig("Startup"); | ||
192 | config.Configs["Startup"].Set("serverside_object_permissions", true); | ||
193 | |||
194 | SceneHelpers sh = new SceneHelpers(); | ||
195 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
196 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); | ||
197 | |||
198 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | ||
199 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | ||
200 | // IsAdministrator if no permissions module is present is true. | ||
201 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule() }); | ||
202 | |||
203 | // Shared scene modules | ||
204 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); | ||
205 | |||
206 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
207 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
208 | |||
209 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
210 | sp.AbsolutePosition = preTeleportPosition; | ||
211 | |||
212 | // Make sceneB return false on query access | ||
213 | sceneB.RegionInfo.RegionSettings.AgentLimit = 0; | ||
214 | |||
215 | sceneA.RequestTeleportLocation( | ||
216 | sp.ControllingClient, | ||
217 | sceneB.RegionInfo.RegionHandle, | ||
218 | teleportPosition, | ||
219 | teleportLookAt, | ||
220 | (uint)TeleportFlags.ViaLocation); | ||
221 | |||
222 | // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); | ||
223 | |||
224 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); | ||
225 | |||
226 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); | ||
227 | Assert.That(sceneASp, Is.Not.Null); | ||
228 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); | ||
229 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); | ||
230 | |||
231 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
232 | |||
233 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
234 | // position instead). | ||
235 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
236 | |||
237 | // TestHelpers.DisableLogging(); | ||
238 | } | ||
239 | |||
240 | /// <summary> | ||
241 | /// Test teleport procedures when the target simulator create agent step is refused. | ||
242 | /// </summary> | ||
243 | [Test] | ||
244 | public void TestSameSimulatorSeparatedRegionsCreateAgentFails() | ||
245 | { | ||
246 | TestHelpers.InMethod(); | ||
247 | // TestHelpers.EnableLogging(); | ||
248 | |||
249 | UUID userId = TestHelpers.ParseTail(0x1); | ||
250 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); | ||
251 | |||
252 | EntityTransferModule etm = new EntityTransferModule(); | ||
253 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
254 | |||
255 | IConfigSource config = new IniConfigSource(); | ||
256 | config.AddConfig("Modules"); | ||
257 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); | ||
258 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); | ||
259 | |||
260 | config.AddConfig("EntityTransfer"); | ||
261 | |||
262 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
263 | // for a callback from the destination scene before removing its avatar data. | ||
264 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); | ||
265 | |||
266 | SceneHelpers sh = new SceneHelpers(); | ||
267 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
268 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); | ||
269 | |||
270 | // Shared scene modules | ||
271 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); | ||
272 | |||
273 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
274 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
275 | |||
276 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
277 | sp.AbsolutePosition = preTeleportPosition; | ||
278 | |||
279 | // Make sceneB refuse CreateAgent | ||
280 | sceneB.LoginsDisabled = true; | ||
281 | |||
282 | sceneA.RequestTeleportLocation( | ||
283 | sp.ControllingClient, | ||
284 | sceneB.RegionInfo.RegionHandle, | ||
285 | teleportPosition, | ||
286 | teleportLookAt, | ||
287 | (uint)TeleportFlags.ViaLocation); | ||
288 | |||
289 | // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); | ||
290 | |||
291 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); | ||
292 | |||
293 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); | ||
294 | Assert.That(sceneASp, Is.Not.Null); | ||
295 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); | ||
296 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); | ||
297 | |||
298 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
299 | |||
300 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
301 | // position instead). | ||
302 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
303 | |||
304 | // TestHelpers.DisableLogging(); | ||
305 | } | ||
306 | |||
164 | [Test] | 307 | [Test] |
165 | public void TestSameSimulatorNeighbouringRegionsTeleport() | 308 | public void TestSameSimulatorNeighbouringRegionsTeleport() |
166 | { | 309 | { |