From d66f3993de49d80d1db9f139ff08485c2d7d9664 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 14 Nov 2008 18:54:38 +0000 Subject: [PATCH] Add group permissions to agent inventory. Contains a migration. May contain nuts. Please back up your inventory data store. This revision changes the interface version!! No older regions can connect to these new UGAIM, and the new regions can't connect to the old UGAIM. Fixes a long-standing issue of permissions loss Currently persisted on MySQL only. --- .../Rest/Inventory/RestInventoryServices.cs | 8 +++++ OpenSim/Data/MySQL/MySQLInventoryData.cs | 6 ++-- OpenSim/Framework/InventoryItemBase.cs | 11 +++++++ OpenSim/Framework/Servers/VersionInfo.cs | 2 +- .../ClientStack/LindenUDP/LLClientView.cs | 14 ++++----- .../AssetTransaction/AssetXferUploader.cs | 1 + .../Environment/Scenes/Scene.Inventory.cs | 31 ++++++++++++++----- OpenSim/Region/Environment/Scenes/Scene.cs | 2 ++ .../Scenes/SceneObjectGroup.Inventory.cs | 3 ++ 9 files changed, 59 insertions(+), 19 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index a62a2080c7..90545690c2 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -1329,6 +1329,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory rdata.writer.WriteStartElement(String.Empty, "Permissions", String.Empty); rdata.writer.WriteAttributeString("current", String.Empty, i.CurrentPermissions.ToString("X")); rdata.writer.WriteAttributeString("next", String.Empty, i.NextPermissions.ToString("X")); + rdata.writer.WriteAttributeString("group", String.Empty, i.GroupPermissions.ToString("X")); rdata.writer.WriteAttributeString("everyone", String.Empty, i.EveryOnePermissions.ToString("X")); rdata.writer.WriteAttributeString("base", String.Empty, i.BasePermissions.ToString("X")); rdata.writer.WriteEndElement(); @@ -1950,6 +1951,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory case "next" : ic.NextPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); break; + case "group" : + ic.GroupPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); + break; case "everyone" : ic.EveryOnePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); break; @@ -2061,6 +2065,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory ic.Item.CurrentPermissions = ic.CurrentPermissions; ic.Item.EveryOnePermissions = ic.EveryOnePermissions; ic.Item.BasePermissions = ic.BasePermissions; + ic.Item.GroupPermissions = ic.GroupPermissions; ic.Item.NextPermissions = ic.NextPermissions; // If no type was specified for this item, we can attempt to @@ -2258,11 +2263,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory internal /*static*/ const uint DefaultNext = 0x82000; internal /*static*/ const uint DefaultBase = 0x7FFFFFFF; internal /*static*/ const uint DefaultEveryOne = 0x0; + internal /*static*/ const uint DefaultGroup = 0x0; internal uint CurrentPermissions = 0x00; internal uint NextPermissions = 0x00; internal uint BasePermissions = 0x00; internal uint EveryOnePermissions = 0x00; + internal uint GroupPermissions = 0x00; internal XmlInventoryCollection() { @@ -2286,6 +2293,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory CurrentPermissions = DefaultCurrent; NextPermissions = DefaultNext; BasePermissions = DefaultBase; + GroupPermissions = DefaultGroup; EveryOnePermissions = DefaultEveryOne; } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 755dbab777..efc781da2a 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -333,6 +333,7 @@ namespace OpenSim.Data.MySQL item.InvType = (int) reader["invType"]; item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; @@ -455,12 +456,12 @@ namespace OpenSim.Data.MySQL string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" - + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType" + + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType" + ", creationDate, groupID, groupOwned, flags) VALUES "; sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" - + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate" + + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" + ", ?groupID, ?groupOwned, ?flags)"; try @@ -482,6 +483,7 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); + result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); result.Parameters.AddWithValue("?salePrice", item.SalePrice); result.Parameters.AddWithValue("?saleType", item.SaleType); result.Parameters.AddWithValue("?creationDate", item.CreationDate); diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 25cef3f350..cd96e01caa 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -74,6 +74,11 @@ namespace OpenSim.Framework /// private uint _everyOnePermissions; + /// + /// + /// + private uint _groupPermissions; + /// /// The folder this item is contained in /// @@ -190,6 +195,12 @@ namespace OpenSim.Framework set { _everyOnePermissions = value; } } + public uint GroupPermissions + { + get { return _groupPermissions; } + set { _groupPermissions = value; } + } + public int AssetType { get { return _assetType; } diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index c6a43ecf09..4b3f829382 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -48,6 +48,6 @@ namespace OpenSim /// of the code that is too old. /// /// - public readonly static int MajorInterfaceVersion = 0; + public readonly static int MajorInterfaceVersion = 1; } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index bb43750d8e..ea82a374f6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1561,10 +1561,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP descend.ItemData[i].OwnerID = item.Owner; descend.ItemData[i].Type = (sbyte)item.AssetType; - //descend.ItemData[i].GroupID = new UUID("00000000-0000-0000-0000-000000000000"); descend.ItemData[i].GroupID = item.GroupID; descend.ItemData[i].GroupOwned = item.GroupOwned; - descend.ItemData[i].GroupMask = 0; + descend.ItemData[i].GroupMask = item.GroupPermissions; descend.ItemData[i].CreationDate = item.CreationDate; descend.ItemData[i].SalePrice = item.SalePrice; descend.ItemData[i].SaleType = item.SaleType; @@ -1708,10 +1707,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions; inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType; - //inventoryReply.InventoryData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000"); inventoryReply.InventoryData[0].GroupID = item.GroupID; inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned; - inventoryReply.InventoryData[0].GroupMask = 0; + inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions; inventoryReply.InventoryData[0].Flags = item.Flags; inventoryReply.InventoryData[0].SalePrice = item.SalePrice; inventoryReply.InventoryData[0].SaleType = item.SaleType; @@ -1763,10 +1761,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions; bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType; - //bulkUpdate.ItemData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000"); bulkUpdate.ItemData[0].GroupID = item.GroupID; bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned; - bulkUpdate.ItemData[0].GroupMask = 0; + bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions; bulkUpdate.ItemData[0].Flags = item.Flags; bulkUpdate.ItemData[0].SalePrice = item.SalePrice; bulkUpdate.ItemData[0].SaleType = item.SaleType; @@ -1811,10 +1808,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions; InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType; - //InventoryReply.InventoryData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupID = Item.GroupID; InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned; - InventoryReply.InventoryData[0].GroupMask = 0; + InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions; InventoryReply.InventoryData[0].Flags = Item.Flags; InventoryReply.InventoryData[0].SalePrice = Item.SalePrice; InventoryReply.InventoryData[0].SaleType = Item.SaleType; @@ -5213,6 +5209,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP itemUpd.Description = Util.FieldToString(update.InventoryData[i].Description); itemUpd.GroupID = update.InventoryData[i].GroupID; itemUpd.GroupOwned = update.InventoryData[i].GroupOwned; + itemUpd.GroupPermissions = update.InventoryData[i].GroupMask; itemUpd.NextPermissions = update.InventoryData[i].NextOwnerMask; itemUpd.EveryOnePermissions = update.InventoryData[i].EveryoneMask; itemUpd.CreationDate = update.InventoryData[i].CreationDate; @@ -5419,6 +5416,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask; item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask; item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask; + item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask; item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned; item.GroupID = rezScriptx.InventoryBlock.GroupID; item.AssetType = rezScriptx.InventoryBlock.Type; diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs index 2bac3c7e57..05b7fa3eb5 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs @@ -293,6 +293,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction item.Folder = InventFolder; item.BasePermissions = 0x7fffffff; item.CurrentPermissions = 0x7fffffff; + item.GroupPermissions=0; item.EveryOnePermissions=0; item.NextPermissions = nextPerm; item.Flags = (uint) wearableType; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 2c0c872fac..74392cc995 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -355,11 +355,11 @@ namespace OpenSim.Region.Environment.Scenes item.NextPermissions = itemUpd.NextPermissions; item.CurrentPermissions |= 8; // Slam! item.EveryOnePermissions = itemUpd.EveryOnePermissions; + item.GroupPermissions = itemUpd.GroupPermissions; - // TODO: Requires sanity checks - //item.GroupID = itemUpd.GroupID; - //item.GroupOwned = itemUpd.GroupOwned; - //item.CreationDate = itemUpd.CreationDate; + item.GroupID = itemUpd.GroupID; + item.GroupOwned = itemUpd.GroupOwned; + item.CreationDate = itemUpd.CreationDate; // The client sends zero if its newly created? if (itemUpd.CreationDate == 0) @@ -480,12 +480,14 @@ namespace OpenSim.Region.Environment.Scenes itemCopy.NextPermissions = item.NextPermissions; itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; + itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; } else { itemCopy.CurrentPermissions = item.CurrentPermissions; itemCopy.NextPermissions = item.NextPermissions; itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; + itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; itemCopy.BasePermissions = item.BasePermissions; } itemCopy.GroupID = UUID.Zero; @@ -584,13 +586,13 @@ namespace OpenSim.Region.Environment.Scenes { CreateNewInventoryItem( remoteClient, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType, - item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, Util.UnixTimeSinceEpoch()); + item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); } else { CreateNewInventoryItem( remoteClient, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType, - item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions, Util.UnixTimeSinceEpoch()); + item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); } } else @@ -690,7 +692,7 @@ namespace OpenSim.Region.Environment.Scenes { CreateNewInventoryItem( remoteClient, folderID, name, flags, callbackID, asset, invType, - (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, creationDate); + (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); } /// @@ -705,7 +707,7 @@ namespace OpenSim.Region.Environment.Scenes /// private void CreateNewInventoryItem( IClientAPI remoteClient, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType, - uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, int creationDate) + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) { CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); @@ -726,6 +728,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = currentMask; item.NextPermissions = nextOwnerMask; item.EveryOnePermissions = everyoneMask; + item.GroupPermissions = groupMask; item.BasePermissions = baseMask; item.CreationDate = creationDate; @@ -978,6 +981,7 @@ namespace OpenSim.Region.Environment.Scenes agentItem.CurrentPermissions = taskItem.NextPermissions | 8; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; + agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; } else { @@ -985,6 +989,7 @@ namespace OpenSim.Region.Environment.Scenes agentItem.CurrentPermissions = taskItem.CurrentPermissions; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions; + agentItem.GroupPermissions = taskItem.GroupPermissions; } if (!ExternalChecks.ExternalChecksBypassPermissions()) @@ -1416,6 +1421,7 @@ namespace OpenSim.Region.Environment.Scenes taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; + taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; @@ -1728,6 +1734,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = item.BasePermissions; item.NextPermissions = objectGroup.RootPart.NextOwnerMask; item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; item.CurrentPermissions |= 8; // Slam! } else @@ -1736,6 +1743,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = objectGroup.GetEffectivePermissions(); item.NextPermissions = objectGroup.RootPart.NextOwnerMask; item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask; } // TODO: add the new fields (Flags, Sale info, etc) @@ -1876,6 +1884,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = grp.RootPart.NextOwnerMask; item.NextPermissions = grp.RootPart.NextOwnerMask; item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; + item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; } else { @@ -1883,6 +1892,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = grp.RootPart.OwnerMask; item.NextPermissions = grp.RootPart.NextOwnerMask; item.EveryOnePermissions = grp.RootPart.EveryoneMask; + item.GroupPermissions = grp.RootPart.GroupMask; } item.CreationDate = Util.UnixTimeSinceEpoch(); @@ -2041,6 +2051,7 @@ namespace OpenSim.Region.Environment.Scenes { part.EveryoneMask = item.EveryOnePermissions; part.NextOwnerMask = item.NextPermissions; + part.GroupMask = 0; // DO NOT propagate here } } group.ApplyNextOwnerPermissions(); @@ -2059,6 +2070,8 @@ namespace OpenSim.Region.Environment.Scenes { part.EveryoneMask = item.EveryOnePermissions; part.NextOwnerMask = item.NextPermissions; + + part.GroupMask = 0; // DO NOT propagate here } } @@ -2282,6 +2295,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = item.BasePermissions; item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask; item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask & returnobjects[i].RootPart.NextOwnerMask; + item.GroupPermissions = returnobjects[i].RootPart.GroupMask & returnobjects[i].RootPart.NextOwnerMask; item.CurrentPermissions |= 8; // Slam! } else @@ -2290,6 +2304,7 @@ namespace OpenSim.Region.Environment.Scenes item.CurrentPermissions = returnobjects[i].GetEffectivePermissions(); item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask; item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask; + item.GroupPermissions = returnobjects[i].RootPart.GroupMask; } // TODO: add the new fields (Flags, Sale info, etc) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5550140c8f..71acc9f919 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -4301,6 +4301,8 @@ namespace OpenSim.Region.Environment.Scenes item.NextPermissions = part.NextOwnerMask; item.EveryOnePermissions = part.EveryoneMask & part.NextOwnerMask; + item.GroupPermissions = part.GroupMask & + part.NextOwnerMask; item.CurrentPermissions |= 8; // Slam! item.CreationDate = Util.UnixTimeSinceEpoch(); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index 225f7cf954..442720ae2b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs @@ -166,6 +166,8 @@ namespace OpenSim.Region.Environment.Scenes item.NextPermissions; taskItem.EveryonePermissions = item.EveryOnePermissions & item.NextPermissions; + taskItem.GroupPermissions = item.GroupPermissions & + item.NextPermissions; taskItem.NextPermissions = item.NextPermissions; taskItem.CurrentPermissions |= 8; } else { @@ -173,6 +175,7 @@ namespace OpenSim.Region.Environment.Scenes taskItem.CurrentPermissions = item.CurrentPermissions; taskItem.CurrentPermissions |= 8; taskItem.EveryonePermissions = item.EveryOnePermissions; + taskItem.GroupPermissions = item.GroupPermissions; taskItem.NextPermissions = item.NextPermissions; }