aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs231
1 files changed, 204 insertions, 27 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index e50dac6..cf2e037 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization;
31using System.IO; 32using System.IO;
32using System.Xml; 33using System.Xml;
33using System.Net; 34using System.Net;
@@ -51,6 +52,7 @@ using OpenSim.Services.Interfaces;
51using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; 52using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53using PermissionMask = OpenSim.Framework.PermissionMask; 54using PermissionMask = OpenSim.Framework.PermissionMask;
55using RegionInfo = OpenSim.Framework.RegionInfo;
54 56
55namespace OpenSim.ApplicationPlugins.RemoteController 57namespace OpenSim.ApplicationPlugins.RemoteController
56{ 58{
@@ -149,6 +151,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
149 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); 151 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
150 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod); 152 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
151 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod); 153 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
154 availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
152 155
153 // Region state management 156 // Region state management
154 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod); 157 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
@@ -161,6 +164,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
161 availableMethods["admin_acl_add"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListAdd); 164 availableMethods["admin_acl_add"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListAdd);
162 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); 165 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove);
163 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); 166 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
167 availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload);
164 168
165 // Misc 169 // Misc
166 availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch); 170 availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch);
@@ -438,18 +442,26 @@ namespace OpenSim.ApplicationPlugins.RemoteController
438 // k, (string)requestData[k], ((string)requestData[k]).Length); 442 // k, (string)requestData[k], ((string)requestData[k]).Length);
439 // } 443 // }
440 444
441 CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"}); 445 CheckStringParameters(requestData, responseData, new string[] { "filename" });
442 CheckRegionParams(requestData, responseData); 446 CheckRegionParams(requestData, responseData);
443 447
444 Scene scene = null; 448 Scene scene = null;
445 GetSceneFromRegionParams(requestData, responseData, out scene); 449 GetSceneFromRegionParams(requestData, responseData, out scene);
446 string file = (string)requestData["filename"];
447 450
448 responseData["accepted"] = true; 451 if (scene != null)
452 {
453 string file = (string)requestData["filename"];
449 454
450 LoadHeightmap(file, scene.RegionInfo.RegionID); 455 responseData["accepted"] = true;
451 456
452 responseData["success"] = true; 457 LoadHeightmap(file, scene.RegionInfo.RegionID);
458
459 responseData["success"] = true;
460 }
461 else
462 {
463 responseData["success"] = false;
464 }
453 465
454 m_log.Info("[RADMIN]: Load height maps request complete"); 466 m_log.Info("[RADMIN]: Load height maps request complete");
455 } 467 }
@@ -463,23 +475,30 @@ namespace OpenSim.ApplicationPlugins.RemoteController
463 475
464// m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); 476// m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString());
465 477
466 CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" }); 478 CheckStringParameters(requestData, responseData, new string[] { "filename" });
467 CheckRegionParams(requestData, responseData); 479 CheckRegionParams(requestData, responseData);
468 480
469 Scene region = null; 481 Scene scene = null;
470 GetSceneFromRegionParams(requestData, responseData, out region); 482 GetSceneFromRegionParams(requestData, responseData, out scene);
471 483
472 string file = (string)requestData["filename"]; 484 if (scene != null)
473 m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); 485 {
486 string file = (string)requestData["filename"];
487 m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);
474 488
475 responseData["accepted"] = true; 489 responseData["accepted"] = true;
476 490
477 ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); 491 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
478 if (null == terrainModule) throw new Exception("terrain module not available"); 492 if (null == terrainModule) throw new Exception("terrain module not available");
479 493
480 terrainModule.SaveToFile(file); 494 terrainModule.SaveToFile(file);
481 495
482 responseData["success"] = true; 496 responseData["success"] = true;
497 }
498 else
499 {
500 responseData["success"] = false;
501 }
483 502
484 m_log.Info("[RADMIN]: Save height maps request complete"); 503 m_log.Info("[RADMIN]: Save height maps request complete");
485 } 504 }
@@ -831,6 +850,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
831 850
832 IScene newScene; 851 IScene newScene;
833 m_application.CreateRegion(region, out newScene); 852 m_application.CreateRegion(region, out newScene);
853 newScene.Start();
834 854
835 // If an access specification was provided, use it. 855 // If an access specification was provided, use it.
836 // Otherwise accept the default. 856 // Otherwise accept the default.
@@ -1225,7 +1245,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1225 { 1245 {
1226 GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString()); 1246 GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString());
1227 if (userInfo != null) 1247 if (userInfo != null)
1228 responseData["lastlogin"] = userInfo.Login; 1248 responseData["lastlogin"] = Util.ToUnixTime(userInfo.Login);
1229 else 1249 else
1230 responseData["lastlogin"] = 0; 1250 responseData["lastlogin"] = 0;
1231 1251
@@ -1395,6 +1415,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1395 } 1415 }
1396 1416
1397 /// <summary> 1417 /// <summary>
1418 /// Authenticate an user.
1419 /// <summary>
1420 /// <param name="request">incoming XML RPC request</param>
1421 /// <remarks>
1422 /// XmlRpcAuthenticateUserMethod takes the following XMLRPC
1423 /// parameters
1424 /// <list type="table">
1425 /// <listheader><term>parameter name</term><description>description</description></listheader>
1426 /// <item><term>password</term>
1427 /// <description>admin password as set in OpenSim.ini</description></item>
1428 /// <item><term>user_firstname</term>
1429 /// <description>avatar's first name</description></item>
1430 /// <item><term>user_lastname</term>
1431 /// <description>avatar's last name</description></item>
1432 /// <item><term>user_password</term>
1433 /// <description>MD5 hash of avatar's password</description></item>
1434 /// <item><term>token_lifetime</term>
1435 /// <description>the lifetime of the returned token (upper bounded to 30s)</description></item>
1436 /// </list>
1437 ///
1438 /// XmlRpcAuthenticateUserMethod returns
1439 /// <list type="table">
1440 /// <listheader><term>name</term><description>description</description></listheader>
1441 /// <item><term>success</term>
1442 /// <description>true or false</description></item>
1443 /// <item><term>token</term>
1444 /// <description>the authentication token sent by OpenSim</description></item>
1445 /// <item><term>error</term>
1446 /// <description>error message if success is false</description></item>
1447 /// </list>
1448 /// </remarks>
1449 private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
1450 IPEndPoint remoteClient)
1451 {
1452 m_log.Info("[RADMIN]: AuthenticateUser: new request");
1453
1454 var responseData = (Hashtable)response.Value;
1455 var requestData = (Hashtable)request.Params[0];
1456
1457 lock (m_requestLock)
1458 {
1459 try
1460 {
1461 CheckStringParameters(requestData, responseData, new[]
1462 {
1463 "user_firstname",
1464 "user_lastname",
1465 "user_password",
1466 "token_lifetime"
1467 });
1468
1469 var firstName = (string)requestData["user_firstname"];
1470 var lastName = (string)requestData["user_lastname"];
1471 var password = (string)requestData["user_password"];
1472
1473 var scene = m_application.SceneManager.CurrentOrFirstScene;
1474
1475 if (scene.Equals(null))
1476 {
1477 m_log.Debug("scene does not exist");
1478 throw new Exception("Scene does not exist.");
1479 }
1480
1481 var scopeID = scene.RegionInfo.ScopeID;
1482 var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
1483
1484 if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
1485 {
1486 m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName);
1487 throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName));
1488 }
1489
1490 if (String.IsNullOrEmpty(password))
1491 {
1492 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
1493 lastName);
1494 throw new Exception(String.Format("no password provided for {0} {1}", firstName,
1495 lastName));
1496 }
1497
1498 int lifetime;
1499 if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false)
1500 {
1501 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
1502 lastName);
1503 throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName,
1504 lastName));
1505 }
1506
1507 // Upper bound on lifetime set to 30s.
1508 if (lifetime > 30)
1509 {
1510 m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
1511 lastName);
1512 throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName,
1513 lastName));
1514 }
1515
1516 var authModule = scene.RequestModuleInterface<IAuthenticationService>();
1517 if (authModule == null)
1518 {
1519 m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded");
1520 throw new Exception("no authentication module loaded");
1521 }
1522
1523 var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
1524 if (String.IsNullOrEmpty(token))
1525 {
1526 m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
1527 lastName);
1528 throw new Exception(String.Format("authentication failed for {0} {1}", firstName,
1529 lastName));
1530 }
1531
1532 m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
1533 firstName, lastName, token);
1534
1535 responseData["token"] = token;
1536 responseData["success"] = true;
1537
1538 }
1539 catch (Exception e)
1540 {
1541 responseData["success"] = false;
1542 responseData["error"] = e.Message;
1543 throw e;
1544 }
1545
1546 m_log.Info("[RADMIN]: AuthenticateUser: request complete");
1547 }
1548 }
1549
1550 /// <summary>
1398 /// Load an OAR file into a region.. 1551 /// Load an OAR file into a region..
1399 /// <summary> 1552 /// <summary>
1400 /// <param name="request">incoming XML RPC request</param> 1553 /// <param name="request">incoming XML RPC request</param>
@@ -1522,7 +1675,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1522 /// </remarks> 1675 /// </remarks>
1523 private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1676 private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1524 { 1677 {
1525 m_log.Info("[RADMIN]: Received Save OAR Administrator Request"); 1678 m_log.Info("[RADMIN]: Received Save OAR Request");
1526 1679
1527 Hashtable responseData = (Hashtable)response.Value; 1680 Hashtable responseData = (Hashtable)response.Value;
1528 Hashtable requestData = (Hashtable)request.Params[0]; 1681 Hashtable requestData = (Hashtable)request.Params[0];
@@ -1568,8 +1721,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1568 1721
1569 if (archiver != null) 1722 if (archiver != null)
1570 { 1723 {
1724 Guid requestId = Guid.NewGuid();
1571 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; 1725 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
1572 archiver.ArchiveRegion(filename, options); 1726
1727 m_log.InfoFormat(
1728 "[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}",
1729 scene.Name, filename, requestId);
1730
1731 archiver.ArchiveRegion(filename, requestId, options);
1573 1732
1574 lock (m_saveOarLock) 1733 lock (m_saveOarLock)
1575 Monitor.Wait(m_saveOarLock,5000); 1734 Monitor.Wait(m_saveOarLock,5000);
@@ -1590,12 +1749,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1590 throw e; 1749 throw e;
1591 } 1750 }
1592 1751
1593 m_log.Info("[RADMIN]: Save OAR Administrator Request complete"); 1752 m_log.Info("[RADMIN]: Save OAR Request complete");
1594 } 1753 }
1595 1754
1596 private void RemoteAdminOarSaveCompleted(Guid uuid, string name) 1755 private void RemoteAdminOarSaveCompleted(Guid uuid, string name)
1597 { 1756 {
1598 m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name); 1757 if (name != "")
1758 m_log.ErrorFormat("[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name);
1759 else
1760 m_log.DebugFormat("[RADMIN]: Saved OAR file for request {0}", uuid);
1761
1599 lock (m_saveOarLock) 1762 lock (m_saveOarLock)
1600 Monitor.Pulse(m_saveOarLock); 1763 Monitor.Pulse(m_saveOarLock);
1601 } 1764 }
@@ -1902,6 +2065,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1902 m_log.Info("[RADMIN]: Access List List Request complete"); 2065 m_log.Info("[RADMIN]: Access List List Request complete");
1903 } 2066 }
1904 2067
2068 private void XmlRpcEstateReload(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2069 {
2070 m_log.Info("[RADMIN]: Received Estate Reload Request");
2071
2072 Hashtable responseData = (Hashtable)response.Value;
2073// Hashtable requestData = (Hashtable)request.Params[0];
2074
2075 m_application.SceneManager.ForEachScene(s =>
2076 s.RegionInfo.EstateSettings = m_application.EstateDataService.LoadEstateSettings(s.RegionInfo.RegionID, false)
2077 );
2078
2079 responseData["success"] = true;
2080
2081 m_log.Info("[RADMIN]: Estate Reload Request complete");
2082 }
2083
1905 private void XmlRpcGetAgentsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 2084 private void XmlRpcGetAgentsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1906 { 2085 {
1907 Hashtable responseData = (Hashtable)response.Value; 2086 Hashtable responseData = (Hashtable)response.Value;
@@ -2763,15 +2942,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2763 /// </summary> 2942 /// </summary>
2764 private void ApplyNextOwnerPermissions(InventoryItemBase item) 2943 private void ApplyNextOwnerPermissions(InventoryItemBase item)
2765 { 2944 {
2766 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 2945 if (item.InvType == (int)InventoryType.Object)
2767 { 2946 {
2768 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 2947 uint perms = item.CurrentPermissions;
2769 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 2948 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
2770 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 2949 item.CurrentPermissions = perms;
2771 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
2772 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
2773 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
2774 } 2950 }
2951
2775 item.CurrentPermissions &= item.NextPermissions; 2952 item.CurrentPermissions &= item.NextPermissions;
2776 item.BasePermissions &= item.NextPermissions; 2953 item.BasePermissions &= item.NextPermissions;
2777 item.EveryOnePermissions &= item.NextPermissions; 2954 item.EveryOnePermissions &= item.NextPermissions;