From 3ecf712e4dd5318442e7c853eb43299840594ce5 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 14:20:39 -0800 Subject: Add userFlags check to isBanned. This checks bans against DenyAnonymous and DenyMinors. Note that the ban doesn't actually work yet due to some stuff mel's working on . --- OpenSim/Region/Framework/Scenes/Scene.cs | 43 +++++++++++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++ 2 files changed, 47 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a4f630a..2ca82ca 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2443,7 +2443,15 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(sceneObject.OwnerID, out sp)) + { + flags = sp.UserFlags; + } + + + if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) { m_log.Info("[INTERREGION]: Denied prim crossing for " + "banned avatar"); @@ -2472,7 +2480,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart RootPrim = sceneObject.RootPart; // Fix up attachment Parent Local ID - ScenePresence sp = GetScenePresence(sceneObject.OwnerID); + sp = GetScenePresence(sceneObject.OwnerID); if (sp != null) { @@ -3617,8 +3625,29 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(agent.AgentID, out sp)) { + flags = sp.UserFlags; + } + if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) + { + //Add some more info to help users + if (!m_regInfo.EstateSettings.IsBanned(agent.AgentID, 32)) + { + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the region requires age verification", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + reason = String.Format("Denied access to region (0): Region requires age verification"); + return false; + } + if (!m_regInfo.EstateSettings.IsBanned(agent.AgentID, 4)) + { + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the region requires payment info on file", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + reason = String.Format("Denied access to region (0): Region requires payment info on file"); + return false; + } m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", @@ -3807,7 +3836,13 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence - if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(cAgentData.AgentID, out sp)) + { + flags = sp.UserFlags; + } + if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); return false; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6a3983f..c4ae0f0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -113,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_attachments; } } + protected List m_attachments = new List(); private Dictionary scriptedcontrols = new Dictionary(); @@ -136,6 +137,12 @@ namespace OpenSim.Region.Framework.Scenes private bool m_updateflag; private byte m_movementflag; private Vector3? m_forceToApply; + private int m_userFlags; + public int UserFlags + { + get { return m_userFlags; } + } + private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID; public bool SitGround = false; @@ -763,6 +770,7 @@ namespace OpenSim.Region.Framework.Scenes m_localId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + m_userFlags = account.UserFlags; if (account != null) m_userLevel = account.UserLevel; -- cgit v1.1 From 6b27587bc7631d6fd083f3b4f752d9ddcfda4830 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 16:25:08 -0800 Subject: Add a "useCached" parameter to GetUserAccount. Add a function to Scene to get the user flags. It has to be here due to access restrictions :/ --- OpenSim/Region/Framework/Scenes/Scene.cs | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2ca82ca..99248c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2443,14 +2443,7 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(sceneObject.OwnerID, out sp)) - { - flags = sp.UserFlags; - } - - + int flags = GetUserFlags(sceneObject.OwnerID); if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) { m_log.Info("[INTERREGION]: Denied prim crossing for " + @@ -2480,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart RootPrim = sceneObject.RootPart; // Fix up attachment Parent Local ID - sp = GetScenePresence(sceneObject.OwnerID); + ScenePresence sp = GetScenePresence(sceneObject.OwnerID); if (sp != null) { @@ -2554,7 +2547,22 @@ namespace OpenSim.Region.Framework.Scenes } return 2; // StateSource.PrimCrossing } - + public int GetUserFlags(UUID user) + { + //Unfortunately the SP approach means that the value is cached until region is restarted + /* + ScenePresence sp; + if (TryGetScenePresence(user, out sp)) + { + return sp.UserFlags; + } + else + { + */ + UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false); + return uac.UserFlags; + //} + } #endregion #region Add/Remove Avatar Methods @@ -3625,12 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(agent.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(agent.AgentID); if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) { //Add some more info to help users @@ -3836,12 +3839,7 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(cAgentData.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(cAgentData.AgentID); if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); -- cgit v1.1 From 31fb448cfc9c43532c38a58fff75fb6c0e67d632 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 17:06:17 -0800 Subject: Mostly revert the last commit with the aim of searching for a better solution --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 99248c1..236e9c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2559,7 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes else { */ - UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false); + UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); return uac.UserFlags; //} } -- cgit v1.1