Include same content filters for IAR file exports that already exist for OAR files. Adds new console switch --perm=CTM to save iar command.
parent
c73b02d583
commit
3bde737f76
|
@ -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
|
|||
/// </summary>
|
||||
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>
|
||||
/// Used to select all inventory nodes in a folder but not the folder itself
|
||||
/// </value>
|
||||
|
@ -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<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"))
|
||||
m_log.InfoFormat(
|
||||
"[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>
|
||||
/// Execute the inventory write request
|
||||
/// </summary>
|
||||
|
@ -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;
|
||||
|
|
|
@ -439,6 +439,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
options["excludefolders"] = new List<String>();
|
||||
((List<String>)options["excludefolders"]).Add(v);
|
||||
});
|
||||
ops.Add("perm=", delegate(string v) { options["perm"] = v; });
|
||||
|
||||
List<string> mainParams = ops.Parse(cmdparams);
|
||||
|
||||
|
|
Loading…
Reference in New Issue