From ab7c0e75472b354e34325fdf6280b77edb0567fe Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 13 Apr 2012 22:32:33 +0100 Subject: [PATCH 1/8] Remove hardcoded god requirement from osSetRegionWaterHeight, osSetRegionSunSettings and, osSetEstateSunSettings no matter the threat level. Change threat level on osSetRegionSunSettings and osSetEstateSunSettings from nuisance to high to match similar functions. If you had enabled these functions but had relied on the hardcoded god check in the code, then please adjust your OSSL permissions config. Thanks to Oren Hurvitz for pointing this out. --- .../Shared/Api/Implementation/OSSL_Api.cs | 61 ++++++++----------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a5dcba47c8..2c0de93ea6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1179,12 +1179,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); m_host.AddScriptLPS(1); - //Check to make sure that the script's owner is the estate manager/master - //World.Permissions.GenericEstatePermission( - if (World.Permissions.IsGod(m_host.OwnerID)) - { - World.EventManager.TriggerRequestChangeWaterHeight((float)height); - } + + World.EventManager.TriggerRequestChangeWaterHeight((float)height); } /// @@ -1195,27 +1191,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) { - CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); + CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); m_host.AddScriptLPS(1); - //Check to make sure that the script's owner is the estate manager/master - //World.Permissions.GenericEstatePermission( - if (World.Permissions.IsGod(m_host.OwnerID)) - { - while (sunHour > 24.0) - sunHour -= 24.0; - while (sunHour < 0) - sunHour += 24.0; + while (sunHour > 24.0) + sunHour -= 24.0; + while (sunHour < 0) + sunHour += 24.0; - World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; - World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 - World.RegionInfo.RegionSettings.FixedSun = sunFixed; - World.RegionInfo.RegionSettings.Save(); + World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; + World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 + World.RegionInfo.RegionSettings.FixedSun = sunFixed; + World.RegionInfo.RegionSettings.Save(); - World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); - } + World.EventManager.TriggerEstateToolsSunUpdate( + World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); } /// @@ -1225,26 +1217,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetEstateSunSettings(bool sunFixed, double sunHour) { - CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); + CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); m_host.AddScriptLPS(1); - //Check to make sure that the script's owner is the estate manager/master - //World.Permissions.GenericEstatePermission( - if (World.Permissions.IsGod(m_host.OwnerID)) - { - while (sunHour > 24.0) - sunHour -= 24.0; - while (sunHour < 0) - sunHour += 24.0; + while (sunHour > 24.0) + sunHour -= 24.0; - World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; - World.RegionInfo.EstateSettings.SunPosition = sunHour; - World.RegionInfo.EstateSettings.FixedSun = sunFixed; - World.RegionInfo.EstateSettings.Save(); + while (sunHour < 0) + sunHour += 24.0; - World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); - } + World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; + World.RegionInfo.EstateSettings.SunPosition = sunHour; + World.RegionInfo.EstateSettings.FixedSun = sunFixed; + World.RegionInfo.EstateSettings.Save(); + + World.EventManager.TriggerEstateToolsSunUpdate( + World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); } /// From eced0916894709e20c16ffc260599772913d7ff3 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 13 Apr 2012 22:52:24 +0100 Subject: [PATCH 2/8] Change threat level of osNpcStopMoveToTarget from Low to High to match other NPC functions, and change OSSL permissions name to osNpcStopMoveToTarget instead of osNpcStopMoveTo Thanks to Oren Hurvitz for pointing out these mistakes. --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 72c1bf6dbf..2680ad0667 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2514,7 +2514,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopMoveToTarget(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); + CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); From a366c05ae2fdfbcce1bc592166f89e3e286bcae4 Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 10 Feb 2012 14:09:46 -0500 Subject: [PATCH 3/8] Added ability to exclude inventory items or folders when saving IAR files. --- .../Archiver/InventoryArchiveWriteRequest.cs | 88 +++++++++---- .../Archiver/InventoryArchiverModule.cs | 124 ++++++++++-------- 2 files changed, 128 insertions(+), 84 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index a26c73a07c..0ee7606a13 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Constructor /// public InventoryArchiveWriteRequest( - Guid id, InventoryArchiverModule module, Scene scene, + Guid id, InventoryArchiverModule module, Scene scene, UserAccount userInfo, string invPath, string savePath) : this( id, @@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Constructor /// public InventoryArchiveWriteRequest( - Guid id, InventoryArchiverModule module, Scene scene, + Guid id, InventoryArchiverModule module, Scene scene, UserAccount userInfo, string invPath, Stream saveStream) { m_id = id; @@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { Exception reportedException = null; bool succeeded = true; - + try { m_archiveWriter.Close(); @@ -146,6 +146,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary options, IUserAccountService userAccountService) { + if (options.ContainsKey("exclude")) + { + if (((List)options["exclude"]).Contains(inventoryItem.Name) || + ((List)options["exclude"]).Contains(inventoryItem.ID.ToString())) + { + if (options.ContainsKey("verbose")) + { + m_log.InfoFormat( + "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}", + inventoryItem.Name, inventoryItem.ID, path); + } + return; + } + } + if (options.ContainsKey("verbose")) m_log.InfoFormat( "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", @@ -175,12 +190,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// protected void SaveInvFolder( - InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, + InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, Dictionary options, IUserAccountService userAccountService) { + if (options.ContainsKey("excludefolders")) + { + if (((List)options["excludefolders"]).Contains(inventoryFolder.Name) || + ((List)options["excludefolders"]).Contains(inventoryFolder.ID.ToString())) + { + if (options.ContainsKey("verbose")) + { + m_log.InfoFormat( + "[INVENTORY ARCHIVER]: Skipping folder {0} at {1}", + inventoryFolder.Name, path); + } + return; + } + } + if (options.ContainsKey("verbose")) m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name); - + if (saveThisFolderItself) { path += CreateArchiveFolderName(inventoryFolder); @@ -189,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_archiveWriter.WriteDir(path); } - InventoryCollection contents + InventoryCollection contents = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); foreach (InventoryFolderBase childFolder in contents.Folders) @@ -216,16 +246,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver InventoryFolderBase inventoryFolder = null; InventoryItemBase inventoryItem = null; InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); - + bool saveFolderContentsOnly = false; - + // Eliminate double slashes and any leading / on the path. string[] components = m_invPath.Split( new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); - + int maxComponentIndex = components.Length - 1; - + // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the // folder itself. This may get more sophisicated later on if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) @@ -233,13 +263,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver saveFolderContentsOnly = true; maxComponentIndex--; } - + m_invPath = String.Empty; for (int i = 0; i <= maxComponentIndex; i++) { m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; } - + // Annoyingly Split actually returns the original string if the input string consists only of delimiters // Therefore if we still start with a / after the split, then we need the root folder if (m_invPath.Length == 0) @@ -249,25 +279,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); - List candidateFolders + List candidateFolders = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); if (candidateFolders.Count > 0) inventoryFolder = candidateFolders[0]; } - + // The path may point to an item instead if (inventoryFolder == null) inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); - + if (null == inventoryFolder && null == inventoryItem) { - // We couldn't find the path indicated + // We couldn't find the path indicated string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); Exception e = new InventoryArchiverException(errorMessage); m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); throw e; } - + m_archiveWriter = new TarArchiveWriter(m_saveStream); m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); @@ -281,10 +311,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { m_log.DebugFormat( "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", - inventoryFolder.Name, - inventoryFolder.ID, + inventoryFolder.Name, + inventoryFolder.ID, m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); - + //recurse through all dirs getting dirs and files SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); } @@ -293,10 +323,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, m_invPath); - + SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); } - + // Don't put all this profile information into the archive right now. //SaveUsers(); @@ -355,7 +385,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// These names are prepended with an inventory folder's UUID so that more than one folder can have the /// same name - /// + /// /// /// public static string CreateArchiveFolderName(InventoryFolderBase folder) @@ -369,7 +399,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// These names are prepended with an inventory item's UUID so that more than one item can have the /// same name - /// + /// /// /// public static string CreateArchiveItemName(InventoryItemBase item) @@ -415,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public string CreateControlFile(Dictionary options) { int majorVersion, minorVersion; - + if (options.ContainsKey("home")) { majorVersion = 1; @@ -425,10 +455,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { majorVersion = 0; minorVersion = 3; - } - + } + m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); - + StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; @@ -450,4 +480,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return s; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ac22c3f079..cf870100a4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -47,18 +47,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + public string Name { get { return "Inventory Archiver Module"; } } - + public bool IsSharedModule { get { return true; } } /// - /// Enable or disable checking whether the iar user is actually logged in + /// Enable or disable checking whether the iar user is actually logged in /// // public bool DisablePresenceChecks { get; set; } - + public event InventoryArchiveSaved OnInventoryArchiveSaved; - + /// /// The file to load and save inventory if no filename has been specified /// @@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Pending save completions initiated from the console /// protected List m_pendingConsoleSaves = new List(); - + /// /// All scenes that this module knows about /// @@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { scene.RegisterModuleInterface(this); OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; - + scene.AddCommand( "Archiving", this, "load iar", "load iar [-m|--merge] []", @@ -119,11 +119,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver + " is the filesystem path or URI from which to load the IAR." + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), HandleLoadInvConsoleCommand); - + scene.AddCommand( "Archiving", this, "save iar", - "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]", - "Save user inventory archive (IAR).", + "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-e|--exclude=] [-f|--excludefolder=] [-v|--verbose]", + "Save user inventory archive (IAR).", " is the user's first name.\n" + " is the user's last name.\n" + " is the path inside the user's inventory for the folder/item to be saved.\n" @@ -131,32 +131,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) + "-h|--home= adds the url of the profile service to the saved user information.\n" + "-c|--creators preserves information about foreign creators.\n" + + "-e|--exclude= don't save the inventory item in archive" + Environment.NewLine + + "-f|--excludefolder= don't save contents of the folder in archive" + Environment.NewLine + "-v|--verbose extra debug messages.\n" + "--noassets stops assets being saved to the IAR.", HandleSaveInvConsoleCommand); m_aScene = scene; } - + m_scenes[scene.RegionInfo.RegionID] = scene; } public void PostInitialise() {} public void Close() {} - + /// /// Trigger the inventory archive saved event. /// protected internal void TriggerInventoryArchiveSaved( - Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException) { InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; if (handlerInventoryArchiveSaved != null) handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); } - + public bool ArchiveInventory( Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) { @@ -164,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } public bool ArchiveInventory( - Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, + Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, Dictionary options) { if (m_scenes.Count > 0) @@ -188,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + return true; // } // else @@ -202,15 +204,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + public bool ArchiveInventory( - Guid id, string firstName, string lastName, string invPath, string pass, string savePath, + Guid id, string firstName, string lastName, string invPath, string pass, string savePath, Dictionary options) { if (m_scenes.Count > 0) { UserAccount userInfo = GetUserInfo(firstName, lastName, pass); - + if (userInfo != null) { // if (CheckPresence(userInfo.PrincipalID)) @@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + return true; // } // else @@ -239,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // } } } - + return false; } @@ -247,9 +249,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary()); } - + public bool DearchiveInventory( - string firstName, string lastName, string invPath, string pass, Stream loadStream, + string firstName, string lastName, string invPath, string pass, Stream loadStream, Dictionary options) { if (m_scenes.Count > 0) @@ -295,22 +297,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + public bool DearchiveInventory( - string firstName, string lastName, string invPath, string pass, string loadPath, + string firstName, string lastName, string invPath, string pass, string loadPath, Dictionary options) { if (m_scenes.Count > 0) { UserAccount userInfo = GetUserInfo(firstName, lastName, pass); - + if (userInfo != null) { // if (CheckPresence(userInfo.PrincipalID)) // { InventoryArchiveReadRequest request; bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); - + try { request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); @@ -324,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + UpdateClientWithLoadedNodes(userInfo, request.Execute()); return true; @@ -340,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + /// /// Load inventory from an inventory file archive /// @@ -351,26 +353,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { Dictionary options = new Dictionary(); OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); - + List mainParams = optionSet.Parse(cmdparams); - + if (mainParams.Count < 6) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] []"); + "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] []"); return; } - + string firstName = mainParams[2]; string lastName = mainParams[3]; string invPath = mainParams[4]; string pass = mainParams[5]; string loadPath = (mainParams.Count > 6 ? mainParams[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, pass, loadPath, options)) m_log.InfoFormat( "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", @@ -381,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); } } - + /// /// Save inventory to a file archive /// @@ -398,6 +400,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); + ops.Add("e|exclude=", delegate(string v) + { + if (!options.ContainsKey("exclude")) + options["exclude"] = new List(); + ((List)options["exclude"]).Add(v); + }); + ops.Add("f|excludefolder=", delegate(string v) + { + if (!options.ContainsKey("excludefolders")) + options["excludefolders"] = new List(); + ((List)options["excludefolders"]).Add(v); + }); List mainParams = ops.Parse(cmdparams); @@ -406,10 +420,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (mainParams.Count < 6) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]"); + "[INVENTORY ARCHIVER]: save iar [-h|--home=] [--noassets] [] [-c|--creators] [-e|--exclude=] [-f|--excludefolder=] [-v|--verbose]"); return; } - + if (options.ContainsKey("home")) m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR"); @@ -418,7 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string invPath = mainParams[4]; string pass = mainParams[5]; string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); - + m_log.InfoFormat( "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); @@ -433,9 +447,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); } } - + private void SaveInvConsoleCommandCompleted( - Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException) { lock (m_pendingConsoleSaves) @@ -445,7 +459,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else return; } - + if (succeeded) { m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); @@ -453,11 +467,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", + "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", userInfo.FirstName, userInfo.LastName, reportedException.Message); } } - + /// /// Get user information for the given name. /// @@ -467,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected UserAccount GetUserInfo(string firstName, string lastName, string pass) { - UserAccount account + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); - + if (null == account) { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", + "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", firstName, lastName); return null; } @@ -488,7 +502,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", + "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", firstName, lastName); return null; } @@ -499,7 +513,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return null; } } - + /// /// Notify the client of loaded nodes if they are logged in /// @@ -508,22 +522,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (loadedNodes.Count == 0) return; - + foreach (Scene scene in m_scenes.Values) { ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); - + if (user != null && !user.IsChildAgent) { foreach (InventoryNodeBase node in loadedNodes) { // m_log.DebugFormat( -// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", +// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", // user.Name, node.Name); - + user.ControllingClient.SendBulkUpdateInventory(node); } - + break; } } @@ -538,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // { // if (DisablePresenceChecks) // return true; -// +// // foreach (Scene scene in m_scenes.Values) // { // ScenePresence p; From eeec1f32c6a8396b7714fc7448e56c4d4cc9b3ba Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 14 Apr 2012 01:01:28 +0100 Subject: [PATCH 4/8] Add very basic TestGetRootPartPosition() test --- .../Scenes/Tests/SceneObjectSpatialTests.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs new file mode 100644 index 0000000000..10c78b5609 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using System.Threading; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + /// + /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) + /// + [TestFixture] + public class SceneObjectSpatialTests + { + [Test] + public void TestGetRootPartPosition() + { + TestHelpers.InMethod(); + + Scene scene = SceneHelpers.SetupScene(); + UUID ownerId = TestHelpers.ParseTail(0x1); + Vector3 partPosition = new Vector3(10, 20, 30); + + SceneObjectGroup so + = SceneHelpers.CreateSceneObject(1, ownerId, "obj1", 0x10); + so.AbsolutePosition = partPosition; + scene.AddNewSceneObject(so, false); + + Assert.That(so.AbsolutePosition, Is.EqualTo(partPosition)); + Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition)); + } + } +} \ No newline at end of file From 4bdd9d51bc0ccfa5b15a6e77228f69dafada03b7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 14 Apr 2012 01:04:26 +0100 Subject: [PATCH 5/8] Correct whitespace error introduced by previous commit --- OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 11b21d4af2..69df392322 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Rotation llGetLocalRot(); LSL_Float llGetMass(); LSL_Integer llGetMemoryLimit(); - void llGetNextEmail(string address, string subject); + void llGetNextEmail(string address, string subject); LSL_String llGetNotecardLine(string name, int line); LSL_Key llGetNumberOfNotecardLines(string name); LSL_Integer llGetNumberOfPrims(); From 4d652c704186e9e399ffc6fc1bdf1f1dca056370 Mon Sep 17 00:00:00 2001 From: Talun Date: Sat, 14 Apr 2012 00:37:55 +0100 Subject: [PATCH 6/8] Missing or unimplemented LSL memory functions. Implemented to behave as if scripts were LSO. Signed-off-by: nebadon --- .../Shared/Api/Implementation/LSL_Api.cs | 52 ++++++++++++------- .../Shared/Api/Interface/ILSL_Api.cs | 7 ++- .../Shared/Api/Runtime/LSL_Constants.cs | 3 ++ .../Shared/Api/Runtime/LSL_Stub.cs | 25 +++++++++ 4 files changed, 68 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 078a22a142..a19427da73 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10949,6 +10949,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return 1; } + public LSL_Integer llGetMemoryLimit() + { + m_host.AddScriptLPS(1); + // The value returned for LSO scripts in SL + return 16384; + } + + public LSL_Integer llSetMemoryLimit(LSL_Integer limit) + { + m_host.AddScriptLPS(1); + // Treat as an LSO script + return ScriptBaseClass.FALSE; + } + + public LSL_Integer llGetSPMaxMemory() + { + m_host.AddScriptLPS(1); + // The value returned for LSO scripts in SL + return 16384; + } + + public LSL_Integer llGetUsedMemory() + { + m_host.AddScriptLPS(1); + // The value returned for LSO scripts in SL + return 16384; + } + + public void llScriptProfiler(LSL_Integer flags) + { + m_host.AddScriptLPS(1); + // This does nothing for LSO scripts in SL + } + #region Not Implemented // // Listing the unimplemented lsl functions here, please move @@ -10961,24 +10995,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api NotImplemented("llGetEnv"); } - public void llGetSPMaxMemory() - { - m_host.AddScriptLPS(1); - NotImplemented("llGetSPMaxMemory"); - } - - public void llGetUsedMemory() - { - m_host.AddScriptLPS(1); - NotImplemented("llGetUsedMemory"); - } - - public void llScriptProfiler(LSL_Integer flags) - { - m_host.AddScriptLPS(1); - NotImplemented("llScriptProfiler"); - } - public void llSetSoundQueueing(int queue) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 0f53bc3210..11b21d4af2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -147,7 +147,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector llGetLocalPos(); LSL_Rotation llGetLocalRot(); LSL_Float llGetMass(); - void llGetNextEmail(string address, string subject); + LSL_Integer llGetMemoryLimit(); + void llGetNextEmail(string address, string subject); LSL_String llGetNotecardLine(string name, int line); LSL_Key llGetNumberOfNotecardLines(string name); LSL_Integer llGetNumberOfPrims(); @@ -185,6 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llGetScriptName(); LSL_Integer llGetScriptState(string name); LSL_String llGetSimulatorHostname(); + LSL_Integer llGetSPMaxMemory(); LSL_Integer llGetStartParameter(); LSL_Integer llGetStatus(int status); LSL_String llGetSubString(string src, int start, int end); @@ -198,6 +200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llGetTimestamp(); LSL_Vector llGetTorque(); LSL_Integer llGetUnixTime(); + LSL_Integer llGetUsedMemory(); LSL_Vector llGetVel(); LSL_Float llGetWallclock(); void llGiveInventory(string destination, string inventory); @@ -319,6 +322,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSay(int channelID, string text); void llScaleTexture(double u, double v, int face); LSL_Integer llScriptDanger(LSL_Vector pos); + void llScriptProfiler(LSL_Integer flag); LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); void llSensor(string name, string id, int type, double range, double arc); void llSensorRemove(); @@ -342,6 +346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSetLinkTexture(int linknumber, string texture, int face); void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); void llSetLocalRot(LSL_Rotation rot); + LSL_Integer llSetMemoryLimit(LSL_Integer limit); void llSetObjectDesc(string desc); void llSetObjectName(string name); void llSetObjectPermMask(int mask, int value); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index f58f9d6e49..fd7c41e682 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -381,6 +381,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_SCULPT_FLAG_INVERT = 64; public const int PRIM_SCULPT_FLAG_MIRROR = 128; + public const int PROFILE_NONE = 0; + public const int PROFILE_SCRIPT_MEMORY = 1; + public const int MASK_BASE = 0; public const int MASK_OWNER = 1; public const int MASK_GROUP = 2; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index f8e3c367bc..3c2f7bdf44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -569,6 +569,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetMass(); } + public LSL_Integer llGetMemoryLimit() + { + return m_LSL_Functions.llGetMemoryLimit(); + } + public void llGetNextEmail(string address, string subject) { m_LSL_Functions.llGetNextEmail(address, subject); @@ -759,6 +764,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetSimulatorHostname(); } + public LSL_Integer llGetSPMaxMemory() + { + return m_LSL_Functions.llGetSPMaxMemory(); + } + public LSL_Integer llGetStartParameter() { return m_LSL_Functions.llGetStartParameter(); @@ -824,6 +834,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetUnixTime(); } + public LSL_Integer llGetUsedMemory() + { + return m_LSL_Functions.llGetUsedMemory(); + } + public LSL_Vector llGetVel() { return m_LSL_Functions.llGetVel(); @@ -1423,6 +1438,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llScriptDanger(pos); } + public void llScriptProfiler(LSL_Integer flags) + { + m_LSL_Functions.llScriptProfiler(flags); + } + public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) { return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); @@ -1533,6 +1553,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetLocalRot(rot); } + public LSL_Integer llSetMemoryLimit(LSL_Integer limit) + { + return m_LSL_Functions.llSetMemoryLimit(limit); + } + public void llSetObjectDesc(string desc) { m_LSL_Functions.llSetObjectDesc(desc); From 2254a718c83df18746be1c9ccfad48928eb48cb3 Mon Sep 17 00:00:00 2001 From: nebadon Date: Fri, 13 Apr 2012 17:09:23 -0700 Subject: [PATCH 7/8] Add Talun to the CONTRIBUTORS.txt, Thank you for the great patches Talun --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 287073bbf8..1370449405 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -144,6 +144,7 @@ what it is today. * SignpostMarv * SpotOn3D * Strawberry Fride +* Talun * tglion * tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud) * tyre From 3ae98611f2efd7c8fb7acc172f9252241dd5c918 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 14 Apr 2012 01:43:03 +0100 Subject: [PATCH 8/8] Add simple RelativePosition and OffsetPosition checks to TestGetRootPartPosition --- .../Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index 10c78b5609..19526c02fb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs @@ -60,6 +60,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(so.AbsolutePosition, Is.EqualTo(partPosition)); Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition)); + Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); + Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); } } } \ No newline at end of file