aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
diff options
context:
space:
mode:
authorAliciaRaven2014-09-06 04:23:59 +0100
committerJustin Clark-Casey (justincc)2014-09-23 00:04:45 +0100
commit3bde737f76b697e569e0333143b07cfd5cde63a6 (patch)
treeb272b29380ca6fc8784028e836c504dab07bfad3 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
parentReplace two connecting bots state booleans in pCampbot with a single state ma... (diff)
downloadopensim-SC_OLD-3bde737f76b697e569e0333143b07cfd5cde63a6.zip
opensim-SC_OLD-3bde737f76b697e569e0333143b07cfd5cde63a6.tar.gz
opensim-SC_OLD-3bde737f76b697e569e0333143b07cfd5cde63a6.tar.bz2
opensim-SC_OLD-3bde737f76b697e569e0333143b07cfd5cde63a6.tar.xz
Include same content filters for IAR file exports that already exist for OAR files. Adds new console switch --perm=CTM to save iar command.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs53
1 files changed, 53 insertions, 0 deletions
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;
43using Ionic.Zlib; 43using Ionic.Zlib;
44using GZipStream = Ionic.Zlib.GZipStream; 44using GZipStream = Ionic.Zlib.GZipStream;
45using CompressionMode = Ionic.Zlib.CompressionMode; 45using CompressionMode = Ionic.Zlib.CompressionMode;
46using PermissionMask = OpenSim.Framework.PermissionMask;
46 47
47namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 48namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
48{ 49{
@@ -55,6 +56,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
55 /// </summary> 56 /// </summary>
56 public bool SaveAssets { get; set; } 57 public bool SaveAssets { get; set; }
57 58
59 /// <summary>
60 /// Determine whether this archive will filter content based on inventory permissions. Default is false
61 /// </summary>
62 public string FilterContent { get; set; }
63
58 /// <value> 64 /// <value>
59 /// Used to select all inventory nodes in a folder but not the folder itself 65 /// Used to select all inventory nodes in a folder but not the folder itself
60 /// </value> 66 /// </value>
@@ -123,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
123 m_assetGatherer = new UuidGatherer(m_scene.AssetService); 129 m_assetGatherer = new UuidGatherer(m_scene.AssetService);
124 130
125 SaveAssets = true; 131 SaveAssets = true;
132 FilterContent = string.Empty;
126 } 133 }
127 134
128 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut) 135 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
@@ -171,6 +178,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
171 } 178 }
172 } 179 }
173 180
181 // Check For Permissions Filter Flags
182 if (!CanUserArchiveObject(m_userInfo.PrincipalID, inventoryItem))
183 {
184 m_log.InfoFormat(
185 "[INVENTORY ARCHIVER]: Insufficient permissions, skipping inventory item {0} {1} at {2}",
186 inventoryItem.Name, inventoryItem.ID, path);
187 return;
188 }
189
174 if (options.ContainsKey("verbose")) 190 if (options.ContainsKey("verbose"))
175 m_log.InfoFormat( 191 m_log.InfoFormat(
176 "[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})", 192 "[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})",
@@ -244,6 +260,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
244 } 260 }
245 261
246 /// <summary> 262 /// <summary>
263 /// Checks whether the user has permission to export an inventory item to an IAR.
264 /// </summary>
265 /// <param name="UserID">The user</param>
266 /// <param name="InvItem">The inventory item</param>
267 /// <returns>Whether the user is allowed to export the object to an IAR</returns>
268 private bool CanUserArchiveObject(UUID UserID, InventoryItemBase InvItem)
269 {
270 if (FilterContent == string.Empty)
271 return true;// Default To Allow Export
272
273 bool permitted = true;
274
275 bool canCopy = (InvItem.CurrentPermissions & (uint)PermissionMask.Copy) != 0;
276 bool canTransfer = (InvItem.CurrentPermissions & (uint)PermissionMask.Transfer) != 0;
277 bool canMod = (InvItem.CurrentPermissions & (uint)PermissionMask.Modify) != 0;
278
279 if (FilterContent.Contains("C") && !canCopy)
280 permitted = false;
281
282 if (FilterContent.Contains("T") && !canTransfer)
283 permitted = false;
284
285 if (FilterContent.Contains("M") && !canMod)
286 permitted = false;
287
288 return permitted;
289 }
290
291 /// <summary>
247 /// Execute the inventory write request 292 /// Execute the inventory write request
248 /// </summary> 293 /// </summary>
249 public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService) 294 public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService)
@@ -251,6 +296,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
251 if (options.ContainsKey("noassets") && (bool)options["noassets"]) 296 if (options.ContainsKey("noassets") && (bool)options["noassets"])
252 SaveAssets = false; 297 SaveAssets = false;
253 298
299 // Set Permission filter if flag is set
300 if (options.ContainsKey("perm"))
301 {
302 Object temp;
303 if (options.TryGetValue("perm", out temp))
304 FilterContent = temp.ToString().ToUpper();
305 }
306
254 try 307 try
255 { 308 {
256 InventoryFolderBase inventoryFolder = null; 309 InventoryFolderBase inventoryFolder = null;