From 5cef8bf64ec3725788ca0ceb70395f8389e52e7c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Nov 2013 00:31:26 +0000 Subject: Make admin_save_oar request submit a request ID and log this for tracking. Previous behaviour of always logging 'name' is unhelpful since this actually an error message parameter which is only filled out if an error has occurred --- .../RemoteController/RemoteAdminPlugin.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index c78cf3b..8b66ee1 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1408,7 +1408,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) { - m_log.Info("[RADMIN]: Received Save OAR Administrator Request"); + m_log.Info("[RADMIN]: Received Save OAR Request"); Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; @@ -1454,8 +1454,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (archiver != null) { + Guid requestId = Guid.NewGuid(); scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; - archiver.ArchiveRegion(filename, options); + + m_log.InfoFormat( + "[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}", + scene.Name, filename, requestId); + + archiver.ArchiveRegion(filename, requestId, options); lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000); @@ -1476,12 +1482,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController throw e; } - m_log.Info("[RADMIN]: Save OAR Administrator Request complete"); + m_log.Info("[RADMIN]: Save OAR Request complete"); } private void RemoteAdminOarSaveCompleted(Guid uuid, string name) { - m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name); + if (name != "") + m_log.ErrorFormat("[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name); + else + m_log.DebugFormat("[RADMIN]: Saved OAR file for request {0}", uuid); + lock (m_saveOarLock) Monitor.Pulse(m_saveOarLock); } -- cgit v1.1 From c896b4179ebc4bdc89b4373e93f4b04174f0c758 Mon Sep 17 00:00:00 2001 From: Eva Comaroski Date: Sun, 17 Nov 2013 12:06:32 +0000 Subject: Added admin_authenticate_user command --- .../RemoteController/RemoteAdminPlugin.cs | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 8b66ee1..354f587 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Xml; using System.Net; @@ -51,6 +52,7 @@ using OpenSim.Services.Interfaces; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using PermissionMask = OpenSim.Framework.PermissionMask; +using RegionInfo = OpenSim.Framework.RegionInfo; namespace OpenSim.ApplicationPlugins.RemoteController { @@ -145,6 +147,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod); availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod); + availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod); // Region state management availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod); @@ -1281,6 +1284,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController } /// + /// Authenticate an user. + /// + /// incoming XML RPC request + /// + /// XmlRpcAuthenticateUserMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// user_firstname + /// avatar's first name + /// user_lastname + /// avatar's last name + /// user_password + /// MD5 hash of avatar's password + /// token_lifetime + /// the lifetime of the returned token (upper bounded to 30s) + /// + /// + /// XmlRpcAuthenticateUserMethod returns + /// + /// namedescription + /// success + /// true or false + /// token + /// the authentication token sent by OpenSim + /// error + /// error message if success is false + /// + /// + private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response, + IPEndPoint remoteClient) + { + m_log.Info("[RADMIN]: AuthenticateUser: new request"); + + var responseData = (Hashtable)response.Value; + var requestData = (Hashtable)request.Params[0]; + + lock (m_requestLock) + { + try + { + CheckStringParameters(requestData, responseData, new[] + { + "user_firstname", + "user_lastname", + "user_password", + "token_lifetime" + }); + + var firstName = (string)requestData["user_firstname"]; + var lastName = (string)requestData["user_lastname"]; + var password = (string)requestData["user_password"]; + + var scene = m_application.SceneManager.CurrentOrFirstScene; + + if (scene.Equals(null)) + { + m_log.Debug("scene does not exist"); + throw new Exception("Scene does not exist."); + } + + var scopeID = scene.RegionInfo.ScopeID; + var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName); + + if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero)) + { + m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName); + throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName)); + } + + if (String.IsNullOrEmpty(password)) + { + m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName, + lastName); + throw new Exception(String.Format("no password provided for {0} {1}", firstName, + lastName)); + } + + int lifetime; + if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false) + { + m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName, + lastName); + throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName, + lastName)); + } + + // Upper bound on lifetime set to 30s. + if (lifetime > 30) + { + m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName, + lastName); + throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName, + lastName)); + } + + var authModule = scene.RequestModuleInterface(); + if (authModule == null) + { + m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded"); + throw new Exception("no authentication module loaded"); + } + + var token = authModule.Authenticate(account.PrincipalID, password, lifetime); + if (String.IsNullOrEmpty(token)) + { + m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName, + lastName); + throw new Exception(String.Format("authentication failed for {0} {1}", firstName, + lastName)); + } + + m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}", + firstName, lastName, token); + + responseData["token"] = token; + responseData["success"] = true; + + } + catch (Exception e) + { + responseData["success"] = false; + responseData["error"] = e.Message; + throw e; + } + + m_log.Info("[RADMIN]: AuthenticateUser: request complete"); + } + } + + /// /// Load an OAR file into a region.. /// /// incoming XML RPC request -- cgit v1.1