aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorDr Scofield2009-05-05 16:17:52 +0000
committerDr Scofield2009-05-05 16:17:52 +0000
commite0a06f641668cd5c25a7854af2faf8a61c4053ee (patch)
treec2a4620c4bdc0e479ca16528cd9e0524529a7998 /OpenSim/Region/Framework/Scenes/Scene.cs
parent* Fix http://opensimulator.org/mantis/view.php?id=3585 (diff)
downloadopensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.zip
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.gz
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.bz2
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.xz
- moving banned check and public/private check to
Scene.NewUserConnection() - adding reason reporting this enforces estate bans very early on and prevents us from circulating client objects that we'd then have to retract once we realize that the client is not allowed into the region
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs159
1 files changed, 75 insertions, 84 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a516a5a..77ca3bc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1859,87 +1859,46 @@ namespace OpenSim.Region.Framework.Scenes
1859 1859
1860 public override void AddNewClient(IClientAPI client) 1860 public override void AddNewClient(IClientAPI client)
1861 { 1861 {
1862 bool welcome = true; 1862 SubscribeToClientEvents(client);
1863 1863 ScenePresence presence;
1864 if (m_regInfo.EstateSettings.IsBanned(client.AgentId) && (!Permissions.IsGod(client.AgentId)))
1865 {
1866 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
1867 client.AgentId, client.FirstName, client.LastName, RegionInfo.RegionName);
1868 client.SendAlertMessage("Denied access to region " + RegionInfo.RegionName + ". You have been banned from that region.");
1869 welcome = false;
1870 }
1871 else if (!m_regInfo.EstateSettings.PublicAccess && !m_regInfo.EstateSettings.HasAccess(client.AgentId) && !Permissions.IsGod(client.AgentId))
1872 {
1873 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
1874 client.AgentId, client.FirstName, client.LastName, RegionInfo.RegionName);
1875 client.SendAlertMessage("Denied access to private region " + RegionInfo.RegionName + ". You do not have access to this region.");
1876 welcome = false;
1877 }
1878 1864
1879 if (!welcome) 1865 if (m_restorePresences.ContainsKey(client.AgentId))
1880 { 1866 {
1881 try 1867 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
1882 { 1868
1883 IEventQueue eq = RequestModuleInterface<IEventQueue>(); 1869 presence = m_restorePresences[client.AgentId];
1884 if (eq != null) 1870 m_restorePresences.Remove(client.AgentId);
1885 { 1871
1886 eq.DisableSimulator(RegionInfo.RegionHandle, client.AgentId); 1872 // This is one of two paths to create avatars that are
1887 } 1873 // used. This tends to get called more in standalone
1888 else 1874 // than grid, not really sure why, but as such needs
1889 client.SendShutdownConnectionNotice(); 1875 // an explicity appearance lookup here.
1890 1876 AvatarAppearance appearance = null;
1891 client.Close(false); 1877 GetAvatarAppearance(client, out appearance);
1892 CapsModule.RemoveCapsHandler(client.AgentId); 1878 presence.Appearance = appearance;
1893 m_authenticateHandler.RemoveCircuit(client.CircuitCode); 1879
1894 } 1880 presence.initializeScenePresence(client, RegionInfo, this);
1895 catch (Exception e) 1881
1882 m_sceneGraph.AddScenePresence(presence);
1883
1884 lock (m_restorePresences)
1896 { 1885 {
1897 m_log.DebugFormat("[SCENE]: Exception while closing unwelcome client {0} {1}: {2}", client.FirstName, client.LastName, e.Message); 1886 Monitor.PulseAll(m_restorePresences);
1898 } 1887 }
1899 } 1888 }
1900 else 1889 else
1901 { 1890 {
1902 SubscribeToClientEvents(client); 1891 m_log.DebugFormat(
1903 ScenePresence presence; 1892 "[SCENE]: Adding new child agent for {0} in {1}",
1904 1893 client.Name, RegionInfo.RegionName);
1905 if (m_restorePresences.ContainsKey(client.AgentId)) 1894
1906 { 1895 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
1907 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); 1896
1908 1897 CreateAndAddScenePresence(client);
1909 presence = m_restorePresences[client.AgentId];
1910 m_restorePresences.Remove(client.AgentId);
1911
1912 // This is one of two paths to create avatars that are
1913 // used. This tends to get called more in standalone
1914 // than grid, not really sure why, but as such needs
1915 // an explicity appearance lookup here.
1916 AvatarAppearance appearance = null;
1917 GetAvatarAppearance(client, out appearance);
1918 presence.Appearance = appearance;
1919
1920 presence.initializeScenePresence(client, RegionInfo, this);
1921
1922 m_sceneGraph.AddScenePresence(presence);
1923
1924 lock (m_restorePresences)
1925 {
1926 Monitor.PulseAll(m_restorePresences);
1927 }
1928 }
1929 else
1930 {
1931 m_log.DebugFormat(
1932 "[SCENE]: Adding new child agent for {0} in {1}",
1933 client.Name, RegionInfo.RegionName);
1934
1935 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
1936
1937 CreateAndAddScenePresence(client);
1938 }
1939
1940 m_LastLogin = Environment.TickCount;
1941 EventManager.TriggerOnNewClient(client);
1942 } 1898 }
1899
1900 m_LastLogin = Environment.TickCount;
1901 EventManager.TriggerOnNewClient(client);
1943 } 1902 }
1944 1903
1945 protected virtual void SubscribeToClientEvents(IClientAPI client) 1904 protected virtual void SubscribeToClientEvents(IClientAPI client)
@@ -2404,7 +2363,8 @@ namespace OpenSim.Region.Framework.Scenes
2404 /// <param name="agent"></param> 2363 /// <param name="agent"></param>
2405 public void HandleNewUserConnection(AgentCircuitData agent) 2364 public void HandleNewUserConnection(AgentCircuitData agent)
2406 { 2365 {
2407 NewUserConnection(agent); 2366 string reason;
2367 NewUserConnection(agent, out reason);
2408 } 2368 }
2409 2369
2410 /// <summary> 2370 /// <summary>
@@ -2415,10 +2375,36 @@ namespace OpenSim.Region.Framework.Scenes
2415 /// </summary> 2375 /// </summary>
2416 /// <param name="regionHandle"></param> 2376 /// <param name="regionHandle"></param>
2417 /// <param name="agent"></param> 2377 /// <param name="agent"></param>
2418 public bool NewUserConnection(AgentCircuitData agent) 2378 /// <param name="reason"></param>
2379 public bool NewUserConnection(AgentCircuitData agent, out string reason)
2419 { 2380 {
2420 bool goodUserConnection = AuthenticateUser(agent); 2381 bool goodUserConnection = AuthenticateUser(agent);
2421 2382
2383 reason = String.Empty;
2384
2385 if (goodUserConnection &&
2386 m_regInfo.EstateSettings.IsBanned(agent.AgentID) &&
2387 (!Permissions.IsGod(agent.AgentID)))
2388 {
2389 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
2390 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
2391 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
2392 RegionInfo.RegionName);
2393 goodUserConnection = false;
2394 }
2395 else if (goodUserConnection &&
2396 !m_regInfo.EstateSettings.PublicAccess &&
2397 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
2398 !Permissions.IsGod(agent.AgentID))
2399 {
2400 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
2401 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
2402 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
2403 RegionInfo.RegionName);
2404 goodUserConnection = false;
2405 }
2406
2407
2422 if (goodUserConnection) 2408 if (goodUserConnection)
2423 { 2409 {
2424 CapsModule.NewUserConnection(agent); 2410 CapsModule.NewUserConnection(agent);
@@ -2431,7 +2417,7 @@ namespace OpenSim.Region.Framework.Scenes
2431 agent.AgentID, RegionInfo.RegionName); 2417 agent.AgentID, RegionInfo.RegionName);
2432 2418
2433 sp.AdjustKnownSeeds(); 2419 sp.AdjustKnownSeeds();
2434 2420
2435 return true; 2421 return true;
2436 } 2422 }
2437 2423
@@ -2440,13 +2426,13 @@ namespace OpenSim.Region.Framework.Scenes
2440 "[CONNECTION BEGIN]: Region {0} told of incoming client {1} {2} {3} (circuit code {4})", 2426 "[CONNECTION BEGIN]: Region {0} told of incoming client {1} {2} {3} (circuit code {4})",
2441 RegionInfo.RegionName, agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode); 2427 RegionInfo.RegionName, agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode);
2442 2428
2443 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 2429 // if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
2444 { 2430 // {
2445 m_log.WarnFormat( 2431 // m_log.WarnFormat(
2446 "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist", 2432 // "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist",
2447 agent.AgentID, RegionInfo.RegionName); 2433 // agent.AgentID, RegionInfo.RegionName);
2448 //return false; 2434 // //return false;
2449 } 2435 // }
2450 2436
2451 CapsModule.AddCapsHandler(agent.AgentID); 2437 CapsModule.AddCapsHandler(agent.AgentID);
2452 2438
@@ -2481,7 +2467,12 @@ namespace OpenSim.Region.Framework.Scenes
2481 } 2467 }
2482 else 2468 else
2483 { 2469 {
2484 m_log.WarnFormat("[CONNECTION BEGIN]: failed to authenticate user {0} {1}. Denying connection.", agent.firstname, agent.lastname); 2470 m_log.WarnFormat("[CONNECTION BEGIN]: failed to authenticate user {0} {1}: {2}. Denying connection.",
2471 agent.firstname, agent.lastname, reason);
2472 if (String.IsNullOrEmpty(reason))
2473 {
2474 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
2475 }
2485 return false; 2476 return false;
2486 } 2477 }
2487 } 2478 }