diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index a5b5aa24c7..ce81deb598 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})", @@ -243,6 +259,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 /// @@ -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 5854428096..dc67738d96 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);