From 7c925744f6094a01aae40972e56fb0ec4d6f3ba5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 15 Sep 2009 07:55:29 +0100 Subject: Some OSGrid specific changes, please use this or later for OSGrid use --- .../Inventory/Archiver/InventoryArchiverModule.cs | 49 +++++++++++++++------- .../Archiver/Tests/InventoryArchiverTests.cs | 14 +++---- .../Interfaces/IInventoryArchiverModule.cs | 6 +-- 3 files changed, 45 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 00faabb..1937637 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -91,12 +91,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "load iar", - "load iar []", + "load iar []", "Load user inventory archive. EXPERIMENTAL", HandleLoadInvConsoleCommand); scene.AddCommand( this, "save iar", - "save iar []", + "save iar []", "Save user inventory archive. EXPERIMENTAL", HandleSaveInvConsoleCommand); m_aScene = scene; @@ -121,11 +121,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); } - public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); + if (userInfo.UserProfile.PasswordHash != md5PasswdHash) + return false; if (userInfo != null) { @@ -146,11 +149,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, string savePath) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); + if (userInfo.UserProfile.PasswordHash != md5PasswdHash) + return false; + if (userInfo != null) { @@ -171,11 +178,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) + public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); + if (userInfo.UserProfile.PasswordHash != md5PasswdHash) + return false; + if (userInfo != null) { @@ -199,11 +210,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) + public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); + if (userInfo.UserProfile.PasswordHash != md5PasswdHash) + return false; + if (userInfo != null) { @@ -233,10 +248,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams) { - if (cmdparams.Length < 5) + if (cmdparams.Length < 6) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is load iar []"); + "[INVENTORY ARCHIVER]: usage is load iar []"); return; } @@ -245,13 +260,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string firstName = cmdparams[2]; string lastName = cmdparams[3]; string invPath = cmdparams[4]; - string loadPath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME); + string pass = cmdparams[5]; + string loadPath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); m_log.InfoFormat( "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", loadPath, invPath, firstName, lastName); - if (DearchiveInventory(firstName, lastName, invPath, loadPath)) + if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath)) m_log.InfoFormat( "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", loadPath, firstName, lastName); @@ -266,7 +282,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (cmdparams.Length < 5) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is save iar []"); + "[INVENTORY ARCHIVER]: usage is save iar []"); return; } @@ -275,14 +291,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string firstName = cmdparams[2]; string lastName = cmdparams[3]; string invPath = cmdparams[4]; - string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME); + string pass = cmdparams[5]; + string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); m_log.InfoFormat( "[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); Guid id = Guid.NewGuid(); - ArchiveInventory(id, firstName, lastName, invPath, savePath); + ArchiveInventory(id, firstName, lastName, invPath, pass, savePath); lock (m_pendingConsoleSaves) m_pendingConsoleSaves.Add(id); @@ -373,8 +390,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver foreach (Scene scene in m_scenes.Values) { - if (scene.GetScenePresence(userId) != null) + ScenePresence p; + if ((p = scene.GetScenePresence(userId)) != null) + { + p.ControllingClient.SendAgentAlertMessage("Inventory operation has been started", false); return true; + } } return false; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index cc16c47..8a414f9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests mre.Reset(); archiverModule.ArchiveInventory( - Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); + Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); mre.WaitOne(60000, false); byte[] archive = archiveWriteStream.ToArray(); @@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests userItemCreatorFirstName, userItemCreatorLastName, "hampshire", String.Empty, 1000, 1000, userItemCreatorUuid); - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream); + archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); @@ -274,7 +274,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Now try loading to a root child folder UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", archiveReadStream); + archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "troll", archiveReadStream); InventoryItemBase foundItem2 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName); @@ -283,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Now try loading to a more deeply nested folder UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", archiveReadStream); + archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "troll", archiveReadStream); InventoryItemBase foundItem3 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName); @@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests userAdminService.AddUser( userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream); + archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); @@ -408,7 +408,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests userAdminService.AddUser( userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream); + archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); // Check that a suitable temporary user profile has been created. UserProfileData user2Profile @@ -492,4 +492,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Assert.That(folder2, Is.Not.Null, "Could not find folder b"); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs index ca7abf8..1622564 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces /// The inventory path in which to place the loaded folders and items /// The stream from which the inventory archive will be loaded /// true if the first stage of the operation succeeded, false otherwise - bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream); + bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream); /// /// Archive a user's inventory folder to the given stream @@ -69,6 +69,6 @@ namespace OpenSim.Region.Framework.Interfaces /// The inventory path from which the inventory should be saved. /// The stream to which the inventory archive will be saved /// true if the first stage of the operation succeeded, false otherwise - bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream); + bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream); } -} \ No newline at end of file +} -- cgit v1.1