From 3bde737f76b697e569e0333143b07cfd5cde63a6 Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Sat, 6 Sep 2014 04:23:59 +0100 Subject: Include same content filters for IAR file exports that already exist for OAR files. Adds new console switch --perm=CTM to save iar command. --- .../Archiver/InventoryArchiveWriteRequest.cs | 53 ++++++++++++++++++++++ .../Inventory/Archiver/InventoryArchiverModule.cs | 1 + 2 files changed, 54 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index a5b5aa2..ce81deb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -43,6 +43,7 @@ using OpenSim.Services.Interfaces; using Ionic.Zlib; using GZipStream = Ionic.Zlib.GZipStream; using CompressionMode = Ionic.Zlib.CompressionMode; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { @@ -55,6 +56,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public bool SaveAssets { get; set; } + /// + /// Determine whether this archive will filter content based on inventory permissions. Default is false + /// + public string FilterContent { get; set; } + /// /// Used to select all inventory nodes in a folder but not the folder itself /// @@ -123,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_assetGatherer = new UuidGatherer(m_scene.AssetService); SaveAssets = true; + FilterContent = string.Empty; } protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids, bool timedOut) @@ -171,6 +178,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } + // Check For Permissions Filter Flags + if (!CanUserArchiveObject(m_userInfo.PrincipalID, inventoryItem)) + { + m_log.InfoFormat( + "[INVENTORY ARCHIVER]: Insufficient permissions, 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} (asset UUID {2})", @@ -244,6 +260,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } /// + /// Checks whether the user has permission to export an inventory item to an IAR. + /// + /// The user + /// The inventory item + /// Whether the user is allowed to export the object to an IAR + private bool CanUserArchiveObject(UUID UserID, InventoryItemBase InvItem) + { + if (FilterContent == string.Empty) + return true;// Default To Allow Export + + bool permitted = true; + + bool canCopy = (InvItem.CurrentPermissions & (uint)PermissionMask.Copy) != 0; + bool canTransfer = (InvItem.CurrentPermissions & (uint)PermissionMask.Transfer) != 0; + bool canMod = (InvItem.CurrentPermissions & (uint)PermissionMask.Modify) != 0; + + if (FilterContent.Contains("C") && !canCopy) + permitted = false; + + if (FilterContent.Contains("T") && !canTransfer) + permitted = false; + + if (FilterContent.Contains("M") && !canMod) + permitted = false; + + return permitted; + } + + /// /// Execute the inventory write request /// public void Execute(Dictionary options, IUserAccountService userAccountService) @@ -251,6 +296,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (options.ContainsKey("noassets") && (bool)options["noassets"]) SaveAssets = false; + // Set Permission filter if flag is set + if (options.ContainsKey("perm")) + { + Object temp; + if (options.TryGetValue("perm", out temp)) + FilterContent = temp.ToString().ToUpper(); + } + try { InventoryFolderBase inventoryFolder = null; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 5854428..dc67738 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -439,6 +439,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver options["excludefolders"] = new List(); ((List)options["excludefolders"]).Add(v); }); + ops.Add("perm=", delegate(string v) { options["perm"] = v; }); List mainParams = ops.Parse(cmdparams); -- cgit v1.1