From 7e8c996d1b13212a65b75393e1a2f96683e9bb2d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 11 May 2017 17:15:02 +0100 Subject: add a grid services god account --- .../UserAccountService/UserAccountService.cs | 86 ++++++++++++++-------- 1 file changed, 56 insertions(+), 30 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index a22754f..48929ee 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -43,6 +43,7 @@ namespace OpenSim.Services.UserAccountService public class UserAccountService : UserAccountServiceBase, IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly UUID UUID_GRID_GOD = new UUID("6571e388-6218-4574-87db-f9379718315e"); private static UserAccountService m_RootInstance; /// @@ -85,38 +86,63 @@ namespace OpenSim.Services.UserAccountService m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); - // In case there are several instances of this class in the same process, - // the console commands are only registered for the root instance - if (m_RootInstance == null && MainConsole.Instance != null) + // create a system grid god account + UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD); + if(ggod == null) + { + UserAccountData d = new UserAccountData(); + + d.FirstName = "GRID"; + d.LastName = "SERVICES"; + d.PrincipalID = UUID_GRID_GOD; + d.ScopeID = UUID.Zero; + d.Data = new Dictionary(); + d.Data["Email"] = string.Empty; + d.Data["Created"] = Util.UnixTimeSinceEpoch().ToString(); + d.Data["UserLevel"] = "240"; + d.Data["UserFlags"] = "0"; + d.Data["ServiceURLs"] = string.Empty; + + m_Database.Store(d); + } + + if (m_RootInstance == null) { m_RootInstance = this; - MainConsole.Instance.Commands.AddCommand("Users", false, - "create user", - "create user [ [ [ [ [ []]]]]]", - "Create a new user", HandleCreateUser); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "reset user password", - "reset user password [ [ []]]", - "Reset a user password", HandleResetUserPassword); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "reset user email", - "reset user email [ [ []]]", - "Reset a user email address", HandleResetUserEmail); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "set user level", - "set user level [ [ []]]", - "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " - + "this account will be treated as god-moded. " - + "It will also affect the 'login level' command. ", - HandleSetUserLevel); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "show account", - "show account ", - "Show account details for the given user", HandleShowAccount); + + // In case there are several instances of this class in the same process, + // the console commands are only registered for the root instance + if (MainConsole.Instance != null) + { + + MainConsole.Instance.Commands.AddCommand("Users", false, + "create user", + "create user [ [ [ [ [ []]]]]]", + "Create a new user", HandleCreateUser); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "reset user password", + "reset user password [ [ []]]", + "Reset a user password", HandleResetUserPassword); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "reset user email", + "reset user email [ [ []]]", + "Reset a user email address", HandleResetUserEmail); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "set user level", + "set user level [ [ []]]", + "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " + + "this account will be treated as god-moded. " + + "It will also affect the 'login level' command. ", + HandleSetUserLevel); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "show account", + "show account ", + "Show account details for the given user", HandleShowAccount); + } } } -- cgit v1.1 From 211a1fe9d413f5571efb2deb1a436ae8639f1c1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 11 May 2017 17:59:37 +0100 Subject: do not allow multiple logins of same avatar. No HG case, that needs work on some paths. option m_allowDuplicatePresences is checked, but is is a total nonsense.. Presences control will get broken if allowed, No one ever added code to suport it correctly. --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 5 +- OpenSim/Services/LLLoginService/LLLoginService.cs | 72 +++++++++++++++++++++- 2 files changed, 72 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 32e14a1..823fd36 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -82,9 +82,8 @@ namespace OpenSim.Services.LLLoginService "false"); AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", + "Please wait a a minute or two and retry. " + + "If this takes longer than a few minutes please contact the grid owner. ", "false"); InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index fc45f86..6a289d1 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -40,6 +40,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Server.Base; +using OpenSim.Services.Connectors.InstantMessage; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; @@ -89,6 +90,7 @@ namespace OpenSim.Services.LLLoginService protected string m_DeniedClients; protected string m_MessageUrl; protected string m_DSTZone; + protected bool m_allowDuplicatePresences = false; IConfig m_LoginServerConfig; // IConfig m_ClientsConfig; @@ -140,6 +142,11 @@ namespace OpenSim.Services.LLLoginService if (groupConfig != null) m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); + IConfig presenceConfig = config.Configs["PresenceService"]; + if (presenceConfig != null) + { + m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); + } // Clean up some of these vars if (m_MapTileURL != String.Empty) @@ -370,6 +377,29 @@ namespace OpenSim.Services.LLLoginService return LLFailedLoginResponse.UserProblem; } + if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e")) + { + // really? + return LLFailedLoginResponse.UserProblem; + } + + string PrincipalIDstr = account.PrincipalID.ToString(); + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr); + + if(!m_allowDuplicatePresences) + { + if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) + { + if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo)) + { + m_log.InfoFormat( + "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in", + firstName, lastName); + return LLFailedLoginResponse.AlreadyLoggedInProblem; + } + } + } + // // Get the user's inventory // @@ -406,7 +436,7 @@ namespace OpenSim.Services.LLLoginService // if (m_PresenceService != null) { - success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); + success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession); if (!success) { @@ -421,7 +451,6 @@ namespace OpenSim.Services.LLLoginService // Change Online status and get the home region // GridRegion home = null; - GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString()); // We are only going to complain about no home if the user actually tries to login there, to avoid // spamming the console. @@ -504,6 +533,10 @@ namespace OpenSim.Services.LLLoginService return new LLFailedLoginResponse("key", reason, "false"); } + + // only now we can assume a login + guinfo = m_GridUserService.LoggedIn(PrincipalIDstr); + // Get Friends list FriendInfo[] friendsList = new FriendInfo[0]; if (m_FriendsService != null) @@ -1080,6 +1113,41 @@ namespace OpenSim.Services.LLLoginService break; } } + + private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo) + { + UUID regionID = guinfo.LastRegionID; + GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); + if(regInfo == null) + return false; + + string regURL = regInfo.ServerURI; + if(String.IsNullOrEmpty(regURL)) + return false; + + UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e"); + + GridInstantMessage msg = new GridInstantMessage(); + msg.imSessionID = UUID.Zero.Guid; + msg.fromAgentID = guuid.Guid; + msg.toAgentID = agentID.Guid; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = "GRID"; + msg.message = string.Format("New login detected"); + msg.dialog = 250; // God kick + msg.fromGroup = false; + msg.offline = (byte)0; + msg.ParentEstateID = 0; + msg.Position = Vector3.Zero; + msg.RegionID = scopeID.Guid; + msg.binaryBucket = new byte[1] {0}; + InstantMessageServiceConnector.SendInstantMessage(regURL,msg); + + m_GridUserService.LoggedOut(agentID.ToString(), + UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); + + return true; + } } #endregion -- cgit v1.1 From f09fafff349af9e020871f622130508e882a1b35 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 11 May 2017 20:24:47 +0100 Subject: some cleanup --- OpenSim/Services/LLLoginService/LLLoginService.cs | 43 ++++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 6a289d1..3ccdc9c 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -865,6 +865,9 @@ namespace OpenSim.Services.LLLoginService reason = string.Empty; uint circuitCode = 0; AgentCircuitData aCircuit = null; + dest = null; + + bool success = false; if (m_UserAgentService == null) { @@ -875,28 +878,14 @@ namespace OpenSim.Services.LLLoginService simConnector = m_LocalSimulationService; else if (m_RemoteSimulationService != null) simConnector = m_RemoteSimulationService; - } - else // User Agent Service is on - { - if (gatekeeper == null) // login to local grid - { - if (hostName == string.Empty) - SetHostAndPort(m_GatekeeperURL); - gatekeeper = new GridRegion(destination); - gatekeeper.ExternalHostName = hostName; - gatekeeper.HttpPort = (uint)port; - gatekeeper.ServerURI = m_GatekeeperURL; - } - m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL); - } - - bool success = false; + if(simConnector == null) + return null; - if (m_UserAgentService == null && simConnector != null) - { circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, + clientIP.Address.ToString(), viewer, channel, mac, id0); + success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); if (!success && m_GridService != null) { @@ -918,10 +907,22 @@ namespace OpenSim.Services.LLLoginService } } - if (m_UserAgentService != null) + else { + if (gatekeeper == null) // login to local grid + { + if (hostName == string.Empty) + SetHostAndPort(m_GatekeeperURL); + + gatekeeper = new GridRegion(destination); + gatekeeper.ExternalHostName = hostName; + gatekeeper.HttpPort = (uint)port; + gatekeeper.ServerURI = m_GatekeeperURL; + } circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, + clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit.teleportFlags |= (uint)flags; success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); if (!success && m_GridService != null) -- cgit v1.1 From cc95b7e2d4d93be36c71c0d72b9b812e161a208f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 11 May 2017 20:26:06 +0100 Subject: don't allow multiple presences of same avatar also on HG gatekeeper --- .../Services/HypergridService/GatekeeperService.cs | 121 +++++++++++++++++---- .../Services/HypergridService/UserAgentService.cs | 1 - 2 files changed, 99 insertions(+), 23 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index b80700f..9bf3cf8 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -35,8 +35,8 @@ using OpenSim.Framework; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; +using OpenSim.Services.Connectors.InstantMessage; using OpenSim.Services.Connectors.Hypergrid; - using OpenMetaverse; using Nini.Config; @@ -71,6 +71,7 @@ namespace OpenSim.Services.HypergridService private static string m_ExternalName; private static Uri m_Uri; private static GridRegion m_DefaultGatewayRegion; + private bool m_allowDuplicatePresences = false; public GatekeeperService(IConfigSource config, ISimulationService simService) { @@ -144,6 +145,12 @@ namespace OpenSim.Services.HypergridService if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); + IConfig presenceConfig = config.Configs["PresenceService"]; + if (presenceConfig != null) + { + m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); + } + m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); } } @@ -369,6 +376,36 @@ namespace OpenSim.Services.HypergridService return false; } + if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e")) + { + // really? + reason = "Invalid account ID"; + return false; + } + + if(m_GridUserService != null) + { + string PrincipalIDstr = account.PrincipalID.ToString(); + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr); + + if(!m_allowDuplicatePresences) + { + if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) + { + if(SendAgentGodKillToRegion(UUID.Zero, account.PrincipalID, guinfo)) + { + m_log.InfoFormat( + "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in", + account.FirstName, account.LastName); + reason = "You appear to be already logged in on destiny grid " + + "Please wait a a minute or two and retry. " + + "If this takes longer than a few minutes please contact the grid owner. "; + return false; + } + } + } + } + m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); bool isFirstLogin = false; @@ -389,26 +426,6 @@ namespace OpenSim.Services.HypergridService return false; } - m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); - - // Also login foreigners with GridUser service - if (m_GridUserService != null && account == null) - { - string userId = aCircuit.AgentID.ToString(); - string first = aCircuit.firstname, last = aCircuit.lastname; - if (last.StartsWith("@")) - { - string[] parts = aCircuit.firstname.Split('.'); - if (parts.Length >= 2) - { - first = parts[0]; - last = parts[1]; - } - } - - userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last; - m_GridUserService.LoggedIn(userId); - } } // @@ -465,7 +482,33 @@ namespace OpenSim.Services.HypergridService true, aCircuit.startpos, new List(), ctx, out reason)) return false; - return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason); + bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason); + + if(didit) + { + m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); + + if(!isFirstLogin && m_GridUserService != null && account == null) + { + // Also login foreigners with GridUser service + string userId = aCircuit.AgentID.ToString(); + string first = aCircuit.firstname, last = aCircuit.lastname; + if (last.StartsWith("@")) + { + string[] parts = aCircuit.firstname.Split('.'); + if (parts.Length >= 2) + { + first = parts[0]; + last = parts[1]; + } + } + + userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last; + m_GridUserService.LoggedIn(userId); + } + } + + return didit; } protected bool Authenticate(AgentCircuitData aCircuit) @@ -563,6 +606,40 @@ namespace OpenSim.Services.HypergridService return exception; } + private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo) + { + UUID regionID = guinfo.LastRegionID; + GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); + if(regInfo == null) + return false; + + string regURL = regInfo.ServerURI; + if(String.IsNullOrEmpty(regURL)) + return false; + + UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e"); + + GridInstantMessage msg = new GridInstantMessage(); + msg.imSessionID = UUID.Zero.Guid; + msg.fromAgentID = guuid.Guid; + msg.toAgentID = agentID.Guid; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = "GRID"; + msg.message = string.Format("New login detected"); + msg.dialog = 250; // God kick + msg.fromGroup = false; + msg.offline = (byte)0; + msg.ParentEstateID = 0; + msg.Position = Vector3.Zero; + msg.RegionID = scopeID.Guid; + msg.binaryBucket = new byte[1] {0}; + InstantMessageServiceConnector.SendInstantMessage(regURL,msg); + + m_GridUserService.LoggedOut(agentID.ToString(), + UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); + + return true; + } #endregion } } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index ba3cb2f..6f2cdd5 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -254,7 +254,6 @@ namespace OpenSim.Services.HypergridService } } - // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination GridRegion region = new GridRegion(gatekeeper); region.ServerURI = gatekeeper.ServerURI; -- cgit v1.1