Include same content filters for IAR file exports that already exist for OAR files. Adds new console switch --perm=CTM to save iar command.

mb-throttle-test
AliciaRaven 2014-09-06 04:23:59 +01:00 committed by Justin Clark-Casey (justincc)
parent c73b02d583
commit 3bde737f76
2 changed files with 54 additions and 0 deletions

View File

@ -43,6 +43,7 @@ using OpenSim.Services.Interfaces;
using Ionic.Zlib; using Ionic.Zlib;
using GZipStream = Ionic.Zlib.GZipStream; using GZipStream = Ionic.Zlib.GZipStream;
using CompressionMode = Ionic.Zlib.CompressionMode; using CompressionMode = Ionic.Zlib.CompressionMode;
using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
@ -55,6 +56,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// </summary> /// </summary>
public bool SaveAssets { get; set; } public bool SaveAssets { get; set; }
/// <summary>
/// Determine whether this archive will filter content based on inventory permissions. Default is false
/// </summary>
public string FilterContent { get; set; }
/// <value> /// <value>
/// Used to select all inventory nodes in a folder but not the folder itself /// Used to select all inventory nodes in a folder but not the folder itself
/// </value> /// </value>
@ -123,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_assetGatherer = new UuidGatherer(m_scene.AssetService); m_assetGatherer = new UuidGatherer(m_scene.AssetService);
SaveAssets = true; SaveAssets = true;
FilterContent = string.Empty;
} }
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut) protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> 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")) if (options.ContainsKey("verbose"))
m_log.InfoFormat( m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})", "[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})",
@ -243,6 +259,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
} }
} }
/// <summary>
/// Checks whether the user has permission to export an inventory item to an IAR.
/// </summary>
/// <param name="UserID">The user</param>
/// <param name="InvItem">The inventory item</param>
/// <returns>Whether the user is allowed to export the object to an IAR</returns>
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;
}
/// <summary> /// <summary>
/// Execute the inventory write request /// Execute the inventory write request
/// </summary> /// </summary>
@ -251,6 +296,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (options.ContainsKey("noassets") && (bool)options["noassets"]) if (options.ContainsKey("noassets") && (bool)options["noassets"])
SaveAssets = false; 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 try
{ {
InventoryFolderBase inventoryFolder = null; InventoryFolderBase inventoryFolder = null;

View File

@ -439,6 +439,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
options["excludefolders"] = new List<String>(); options["excludefolders"] = new List<String>();
((List<String>)options["excludefolders"]).Add(v); ((List<String>)options["excludefolders"]).Add(v);
}); });
ops.Add("perm=", delegate(string v) { options["perm"] = v; });
List<string> mainParams = ops.Parse(cmdparams); List<string> mainParams = ops.Parse(cmdparams);