From 93edc75147d5a819cc4e30699ecb859820aa9b7f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Sep 2010 00:00:54 +0100 Subject: Disallow modification of system folders. Prevent changing the type of folders and prevent resetting the version number --- OpenSim/Services/InventoryService/XInventoryService.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 84306e7..02d7170 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -293,13 +293,28 @@ namespace OpenSim.Services.InventoryService public virtual bool AddFolder(InventoryFolderBase folder) { + InventoryFolderBase check = GetFolder(folder); + if (check != null) + return false; + XInventoryFolder xFolder = ConvertFromOpenSim(folder); return m_Database.StoreFolder(xFolder); } public virtual bool UpdateFolder(InventoryFolderBase folder) { - return AddFolder(folder); + XInventoryFolder xFolder = ConvertFromOpenSim(folder); + InventoryFolderBase check = GetFolder(folder); + if (check == null) + return AddFolder(folder); + + if (check.Type != -1 || xFolder.type != -1) + return false; + + xFolder.version = check.Version; + xFolder.folderID = check.ID; + + return m_Database.StoreFolder(xFolder); } public virtual bool MoveFolder(InventoryFolderBase folder) -- cgit v1.1 From 7efe7feef5cb4bb001387eb3b90e819a61ef9107 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Sep 2010 00:02:07 +0100 Subject: Update: Allow the version to increase only --- OpenSim/Services/InventoryService/XInventoryService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 02d7170..febb0af 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -311,7 +311,8 @@ namespace OpenSim.Services.InventoryService if (check.Type != -1 || xFolder.type != -1) return false; - xFolder.version = check.Version; + if (xFolder.version < check.Version) + xFolder.version = check.Version; xFolder.folderID = check.ID; return m_Database.StoreFolder(xFolder); -- cgit v1.1 From 203b7de2663934ae5e7f88061d97284dac961568 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Sep 2010 00:04:17 +0100 Subject: Allow increasing the version in system folders --- OpenSim/Services/InventoryService/XInventoryService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index febb0af..97af44d 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -309,7 +309,13 @@ namespace OpenSim.Services.InventoryService return AddFolder(folder); if (check.Type != -1 || xFolder.type != -1) - return false; + { + if (xFolder.version > check.Version) + return false; + check.Version = xFolder.version; + xFolder = ConvertFromOpenSim(check); + return m_Database.StoreFolder(xFolder); + } if (xFolder.version < check.Version) xFolder.version = check.Version; -- cgit v1.1 From bbdf6cab50bb5f5486130cf1443087d1f4fb84e2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Sep 2010 00:20:57 +0100 Subject: Fix cast issue --- OpenSim/Services/InventoryService/XInventoryService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 97af44d..fb395ec 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -312,7 +312,7 @@ namespace OpenSim.Services.InventoryService { if (xFolder.version > check.Version) return false; - check.Version = xFolder.version; + check.Version = (ushort)xFolder.version; xFolder = ConvertFromOpenSim(check); return m_Database.StoreFolder(xFolder); } -- cgit v1.1 From fe63fad394b89314777f2c2713c349b3a3017256 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Sep 2010 22:26:15 +0100 Subject: minor: remove mono compiler warning --- OpenSim/Services/InventoryService/HGInventoryService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/InventoryService/HGInventoryService.cs index 6e6b019..d62c008 100644 --- a/OpenSim/Services/InventoryService/HGInventoryService.cs +++ b/OpenSim/Services/InventoryService/HGInventoryService.cs @@ -44,7 +44,7 @@ namespace OpenSim.Services.InventoryService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected IXInventoryData m_Database; + protected new IXInventoryData m_Database; public HGInventoryService(IConfigSource config) : base(config) -- cgit v1.1