From 667b54f5a2a04fa5a2859397868d270eab3913f1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 23 Jul 2011 01:59:14 +0100 Subject: [PATCH] Don't load current/next/everyone/base permissions from the library item xml files - always use PermissionMask.All instead (which was the existing default). Library items always need the same permissions, so it doesn't make sense to load them from the xml files. This just opens the door to permissions mistakes. --- OpenSim/Framework/InventoryFolderImpl.cs | 8 +- .../InventoryAccess/InventoryAccessModule.cs | 4 + .../Framework/Library/LibraryModule.cs | 8 +- .../Framework/Scenes/Scene.Inventory.cs | 5 +- .../InventoryService/LibraryService.cs | 37 +-- .../AnimationsLibraryItems.xml | 6 - .../BodyPartsLibraryItems.xml | 33 +-- .../ClothingLibrary/ClothingLibraryItems.xml | 14 +- .../GesturesLibrary/GesturesLibraryItems.xml | 80 +---- .../LandmarksLibraryItems.xml | 4 - .../NotecardsLibraryItems.xml | 14 +- .../ObjectsLibrary/ObjectsLibraryItems.xml | 4 - .../OpenSimLibrary/OpenSimLibrary.xml | 4 - .../PhotosLibrary/PhotosLibraryItems.xml | 4 - .../ScriptsLibrary/ScriptsLibraryItems.xml | 223 ++++---------- .../SoundsLibrary/SoundsLibraryItems.xml | 4 - .../TexturesLibrary/TexturesLibraryItems.xml | 274 ++++-------------- 17 files changed, 159 insertions(+), 567 deletions(-) diff --git a/OpenSim/Framework/InventoryFolderImpl.cs b/OpenSim/Framework/InventoryFolderImpl.cs index 29c7682c2b..139776bb39 100644 --- a/OpenSim/Framework/InventoryFolderImpl.cs +++ b/OpenSim/Framework/InventoryFolderImpl.cs @@ -27,13 +27,15 @@ using System; using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenMetaverse; namespace OpenSim.Framework { public class InventoryFolderImpl : InventoryFolderBase { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly string PATH_DELIMITER = "/"; @@ -402,6 +404,10 @@ namespace OpenSim.Framework { foreach (InventoryItemBase item in Items.Values) { +// m_log.DebugFormat( +// "[INVENTORY FOLDER IMPL]: Returning item {0} {1}, OwnerPermissions {2:X}", +// item.Name, item.ID, item.CurrentPermissions); + itemList.Add(item); } } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index b714f2b6ab..493314700c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -984,11 +984,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) { InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); + if (assetRequestItem == null) { ILibraryService lib = m_Scene.RequestModuleInterface(); + if (lib != null) assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); + if (assetRequestItem == null) return false; } @@ -1019,6 +1022,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", Name, requestID, itemID, assetRequestItem.AssetID); + return false; } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d570608369..2ef445744b 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -185,6 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); archread.Execute(); } + foreach (InventoryNodeBase node in nodes) FixPerms(node); } @@ -197,18 +198,23 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread.Close(); } } - } private void FixPerms(InventoryNodeBase node) { + m_log.DebugFormat("[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID); + if (node is InventoryItemBase) { InventoryItemBase item = (InventoryItemBase)node; +// item.BasePermissions = (uint)PermissionMask.All; item.BasePermissions = 0x7FFFFFFF; item.EveryOnePermissions = 0x7FFFFFFF; item.CurrentPermissions = 0x7FFFFFFF; item.NextPermissions = 0x7FFFFFFF; +// item.EveryOnePermissions = (uint)PermissionMask.Copy; +// item.CurrentPermissions = (uint)PermissionMask.None; +// item.NextPermissions = (uint)PermissionMask.All; } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 30421d4224..afc1a4fce4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -724,7 +724,10 @@ namespace OpenSim.Region.Framework.Scenes newName = item.Name; } - if (remoteClient.AgentId == oldAgentID || (LibraryService != null && LibraryService.LibraryRootFolder != null && oldAgentID == LibraryService.LibraryRootFolder.Owner)) + if (remoteClient.AgentId == oldAgentID + || (LibraryService != null + && LibraryService.LibraryRootFolder != null + && oldAgentID == LibraryService.LibraryRootFolder.Owner)) { CreateNewInventoryItem( remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType, diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs index 383f311fdf..b46add30cf 100644 --- a/OpenSim/Services/InventoryService/LibraryService.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs @@ -93,26 +93,6 @@ namespace OpenSim.Services.InventoryService LoadLibraries(pLibrariesLocation); } - public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, - int assetType, int invType, UUID parentFolderID) - { - InventoryItemBase item = new InventoryItemBase(); - item.Owner = libOwner; - item.CreatorId = libOwner.ToString(); - item.ID = inventoryID; - item.AssetID = assetID; - item.Description = description; - item.Name = name; - item.AssetType = assetType; - item.InvType = invType; - item.Folder = parentFolderID; - item.BasePermissions = 0x7FFFFFFF; - item.EveryOnePermissions = 0x7FFFFFFF; - item.CurrentPermissions = 0x7FFFFFFF; - item.NextPermissions = 0x7FFFFFFF; - return item; - } - /// /// Use the asset set information at path to load assets /// @@ -193,22 +173,27 @@ namespace OpenSim.Services.InventoryService item.Description = config.GetString("description", item.Name); item.InvType = config.GetInt("inventoryType", 0); item.AssetType = config.GetInt("assetType", item.InvType); - item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); - item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); - item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); - item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); - item.Flags = (uint)config.GetInt("flags", 0); + item.CurrentPermissions = (uint)PermissionMask.All; + item.NextPermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = (uint)PermissionMask.All; +// item.EveryOnePermissions = (uint)PermissionMask.All - (uint)PermissionMask.Modify; + item.BasePermissions = (uint)PermissionMask.All; if (libraryFolders.ContainsKey(item.Folder)) { InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; + try { +// m_log.DebugFormat( +// "[LIBRARY INVENTORY]: Adding item {0} {1}, OwnerPermissions {2:X} to {3}", +// item.Name, item.ID, item.CurrentPermissions, item.Folder); + parentFolder.Items.Add(item.ID, item); } catch (Exception) { - m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); + m_log.WarnFormat("[LIBRARY INVENTORY]: Item {1} [{0}] not added, duplicate item", item.ID, item.Name); } } else diff --git a/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml b/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml index 2a6ceb4529..9cfadf0361 100644 --- a/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml +++ b/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml @@ -108,8 +108,6 @@ - - diff --git a/bin/inventory/BodyPartsLibrary/BodyPartsLibraryItems.xml b/bin/inventory/BodyPartsLibrary/BodyPartsLibraryItems.xml index aa8d9d964b..d9adf1c53c 100644 --- a/bin/inventory/BodyPartsLibrary/BodyPartsLibraryItems.xml +++ b/bin/inventory/BodyPartsLibrary/BodyPartsLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> + diff --git a/bin/inventory/ClothingLibrary/ClothingLibraryItems.xml b/bin/inventory/ClothingLibrary/ClothingLibraryItems.xml index 9e297f063e..a12bb8af21 100644 --- a/bin/inventory/ClothingLibrary/ClothingLibraryItems.xml +++ b/bin/inventory/ClothingLibrary/ClothingLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> + diff --git a/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml b/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml index 1312129ca6..ca3ce2d18c 100644 --- a/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml +++ b/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml @@ -7,11 +7,8 @@ - - - - +
@@ -20,11 +17,8 @@ - - - -
+
@@ -33,11 +27,8 @@ - - - -
+
@@ -46,11 +37,8 @@ - - - -
+
@@ -59,11 +47,8 @@ - - - -
+
@@ -72,11 +57,8 @@ - - - -
+
@@ -85,11 +67,8 @@ - - - -
+
@@ -98,11 +77,8 @@ - - - -
+
@@ -111,11 +87,8 @@ - - - -
+
@@ -124,11 +97,8 @@ - - - -
+
@@ -137,11 +107,8 @@ - - - -
+
@@ -150,11 +117,8 @@ - - - -
+
@@ -163,11 +127,8 @@ - - - -
+
@@ -176,11 +137,8 @@ - - - -
+
@@ -189,11 +147,8 @@ - - - -
+
@@ -202,9 +157,6 @@ - - - -
+ diff --git a/bin/inventory/LandmarksLibrary/LandmarksLibraryItems.xml b/bin/inventory/LandmarksLibrary/LandmarksLibraryItems.xml index 4047a5838e..44194cd52f 100644 --- a/bin/inventory/LandmarksLibrary/LandmarksLibraryItems.xml +++ b/bin/inventory/LandmarksLibrary/LandmarksLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> diff --git a/bin/inventory/NotecardsLibrary/NotecardsLibraryItems.xml b/bin/inventory/NotecardsLibrary/NotecardsLibraryItems.xml index 713c365755..e232bcc350 100644 --- a/bin/inventory/NotecardsLibrary/NotecardsLibraryItems.xml +++ b/bin/inventory/NotecardsLibrary/NotecardsLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> @@ -24,11 +20,8 @@ - - - - +
@@ -37,9 +30,6 @@ - - - -
+ diff --git a/bin/inventory/ObjectsLibrary/ObjectsLibraryItems.xml b/bin/inventory/ObjectsLibrary/ObjectsLibraryItems.xml index 4047a5838e..44194cd52f 100644 --- a/bin/inventory/ObjectsLibrary/ObjectsLibraryItems.xml +++ b/bin/inventory/ObjectsLibrary/ObjectsLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> diff --git a/bin/inventory/OpenSimLibrary/OpenSimLibrary.xml b/bin/inventory/OpenSimLibrary/OpenSimLibrary.xml index 7eb8de3c1a..bef59d8add 100644 --- a/bin/inventory/OpenSimLibrary/OpenSimLibrary.xml +++ b/bin/inventory/OpenSimLibrary/OpenSimLibrary.xml @@ -10,10 +10,6 @@ - - - - --> diff --git a/bin/inventory/PhotosLibrary/PhotosLibraryItems.xml b/bin/inventory/PhotosLibrary/PhotosLibraryItems.xml index 4047a5838e..44194cd52f 100644 --- a/bin/inventory/PhotosLibrary/PhotosLibraryItems.xml +++ b/bin/inventory/PhotosLibrary/PhotosLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> diff --git a/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml b/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml index 9641f7db6b..df9d867b5d 100644 --- a/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml +++ b/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml @@ -25,11 +25,8 @@ - - - - +
@@ -38,11 +35,8 @@ - - - -
+
@@ -51,11 +45,8 @@ - - - -
+
@@ -64,11 +55,8 @@ - - - -
+
@@ -77,11 +65,8 @@ - - - -
+
@@ -90,11 +75,8 @@ - - - -
+
@@ -103,11 +85,8 @@ - - - -
+
@@ -116,11 +95,8 @@ - - - -
+
@@ -129,11 +105,8 @@ - - - -
+
@@ -142,11 +115,8 @@ - - - -
+
@@ -155,11 +125,8 @@ - - - -
+
@@ -169,11 +136,8 @@ - - - -
+ @@ -187,6 +151,7 @@ +
@@ -195,11 +160,8 @@ - - - -
+
@@ -208,11 +170,8 @@ - - - -
+
@@ -221,11 +180,8 @@ - - - -
+
@@ -234,11 +190,8 @@ - - - -
+
@@ -248,11 +201,8 @@ - - - -
+
@@ -261,11 +211,8 @@ - - - -
+
@@ -274,11 +221,8 @@ - - - -
+ @@ -288,213 +232,166 @@
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+
- + - - - -
+ +
@@ -503,11 +400,8 @@ - - - -
+
@@ -516,11 +410,8 @@ - - - -
+
@@ -529,9 +420,5 @@ - - - -
diff --git a/bin/inventory/SoundsLibrary/SoundsLibraryItems.xml b/bin/inventory/SoundsLibrary/SoundsLibraryItems.xml index 4047a5838e..44194cd52f 100644 --- a/bin/inventory/SoundsLibrary/SoundsLibraryItems.xml +++ b/bin/inventory/SoundsLibrary/SoundsLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> diff --git a/bin/inventory/TexturesLibrary/TexturesLibraryItems.xml b/bin/inventory/TexturesLibrary/TexturesLibraryItems.xml index adba99aae5..a018a0de78 100644 --- a/bin/inventory/TexturesLibrary/TexturesLibraryItems.xml +++ b/bin/inventory/TexturesLibrary/TexturesLibraryItems.xml @@ -9,10 +9,6 @@ - - - - --> @@ -24,11 +20,8 @@ - - - - +
@@ -37,11 +30,8 @@ - - - -
+
@@ -50,11 +40,8 @@ - - - -
+
@@ -63,11 +50,8 @@ - - - -
+
@@ -76,11 +60,8 @@ - - - -
+
@@ -89,11 +70,8 @@ - - - -
+
@@ -102,11 +80,8 @@ - - - -
+
@@ -115,11 +90,8 @@ - - - -
+
@@ -128,11 +100,8 @@ - - - -
+
@@ -141,11 +110,8 @@ - - - -
+
@@ -154,11 +120,8 @@ - - - -
+
@@ -167,11 +130,8 @@ - - - -
+
@@ -180,11 +140,8 @@ - - - -
+
@@ -193,11 +150,8 @@ - - - -
+
@@ -206,11 +160,8 @@ - - - -
+
@@ -219,11 +170,8 @@ - - - -
+
@@ -232,11 +180,8 @@ - - - -
+
@@ -245,11 +190,8 @@ - - - -
+
@@ -258,11 +200,8 @@ - - - -
+
@@ -271,11 +210,8 @@ - - - -
+
@@ -284,11 +220,8 @@ - - - -
+
@@ -297,11 +230,8 @@ - - - -
+
@@ -310,11 +240,8 @@ - - - -
+
@@ -323,11 +250,8 @@ - - - -
+
@@ -336,11 +260,8 @@ - - - -
+
@@ -349,11 +270,8 @@ - - - -
+
@@ -362,11 +280,8 @@ - - - -
+
@@ -375,11 +290,8 @@ - - - -
+
@@ -388,11 +300,8 @@ - - - -
+
@@ -401,11 +310,8 @@ - - - -
+
@@ -414,11 +320,8 @@ - - - -
+
@@ -427,11 +330,8 @@ - - - -
+
@@ -440,11 +340,8 @@ - - - -
+
@@ -453,11 +350,8 @@ - - - -
+
@@ -466,11 +360,8 @@ - - - -
+
@@ -479,11 +370,8 @@ - - - -
+
@@ -492,11 +380,8 @@ - - - -
+
@@ -505,11 +390,8 @@ - - - -
+
@@ -518,11 +400,8 @@ - - - -
+
@@ -531,11 +410,8 @@ - - - -
+
@@ -544,11 +420,8 @@ - - - -
+
@@ -557,11 +430,8 @@ - - - -
+
@@ -570,11 +440,8 @@ - - - -
+
@@ -583,11 +450,8 @@ - - - -
+
@@ -596,11 +460,8 @@ - - - -
+
@@ -609,11 +470,8 @@ - - - -
+
@@ -622,11 +480,8 @@ - - - -
+
@@ -635,10 +490,6 @@ - - - -
@@ -649,11 +500,8 @@ - - - -
+
@@ -662,11 +510,8 @@ - - - -
+
@@ -675,11 +520,8 @@ - - - -
+
@@ -688,10 +530,6 @@ - - - -
@@ -702,10 +540,6 @@ - - - -
@@ -716,10 +550,6 @@ - - - -
@@ -730,9 +560,5 @@ - - - -