From e456cb7533dff72aa22a87f261a758e294e707b1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 23 Apr 2008 13:22:06 +0000 Subject: * Patch for #973 - Object Rez from Inventory ignores permissions - Thanks tglion! --- OpenSim/Region/Environment/PermissionManager.cs | 38 +++++++++++++ OpenSim/Region/Environment/Scenes/InnerScene.cs | 12 +++++ .../Region/Environment/Scenes/Scene.Inventory.cs | 62 ++++++++++++++++++---- .../Scenes/SceneObjectPart.Inventory.cs | 25 +++++++++ 4 files changed, 126 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 12ef110..0343d21 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -159,6 +159,44 @@ namespace OpenSim.Region.Environment return permission; } + /// + /// Permissions check - can user enter an object? + /// + /// User attempting move an object + /// Source object-position + /// Target object-position + /// Has permission? + public virtual bool CanObjectEntry(LLUUID user, LLVector3 oldPos, LLVector3 newPos) + { + ILandObject land1 = m_scene.LandChannel.getLandObject(oldPos.X, oldPos.Y); + ILandObject land2 = m_scene.LandChannel.getLandObject(newPos.X, newPos.Y); + if (land1 == null || land2 == null) + { + return false; + } + + if (land1.landData.globalID == land2.landData.globalID) + { + return true; + } + + if ((land2.landData.landFlags & ((int)Parcel.ParcelFlags.AllowAllObjectEntry)) != 0) + { + return true; + } + + //TODO: check for group rights + + if (GenericParcelPermission(user, newPos)) + { + return true; + } + + SendPermissionError(user, "Not allowed to move objects in this parcel!"); + + return false; + } + #region Object Permissions public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 329f900..2b28b2a 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -981,6 +981,12 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { + LLVector3 oldPos = group.AbsolutePosition; + if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) + { + group.SendGroupTerseUpdate(); + return; + } if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateSinglePosition(pos, localID); @@ -999,6 +1005,12 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { + LLVector3 oldPos = group.AbsolutePosition; + if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) + { + group.SendGroupTerseUpdate(); + return; + } if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) { group.UpdateGroupPosition(pos); diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index e4a9551..9bf6728 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -855,9 +855,23 @@ namespace OpenSim.Region.Environment.Scenes } if (selectedEnt != null) { - if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) + bool permission; + if (DeRezPacket.AgentBlock.Destination == 1) + { // Take Copy + permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, + ((SceneObjectGroup) selectedEnt).UUID); + } + else + { // Take + permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId, + ((SceneObjectGroup) selectedEnt).UUID); + } + + if (permission) { - string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); + SceneObjectGroup objectGroup = (SceneObjectGroup) selectedEnt; + string sceneObjectXml = objectGroup.ToXmlString(); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) @@ -871,8 +885,8 @@ namespace OpenSim.Region.Environment.Scenes AssetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); + item.Creator = objectGroup.RootPart.CreatorID; item.Owner = remoteClient.AgentId; - item.Creator = remoteClient.AgentId; item.ID = LLUUID.Random(); item.AssetID = asset.FullID; item.Description = asset.Description; @@ -880,12 +894,18 @@ namespace OpenSim.Region.Environment.Scenes item.AssetType = asset.Type; item.InvType = asset.InvType; item.Folder = DeRezPacket.AgentBlock.DestinationID; - item.CurrentPermissions = 2147483647; - item.NextPermissions = 2147483647; - item.EveryOnePermissions = - ((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask; - item.BasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask; - item.CurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) { + item.BasePermissions = objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + } + else + { + item.BasePermissions = objectGroup.RootPart.BaseMask; + item.CurrentPermissions = objectGroup.RootPart.OwnerMask; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + } userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); @@ -894,7 +914,7 @@ namespace OpenSim.Region.Environment.Scenes // FIXME: Nasty hardcoding. If Destination is 1 then client wants us to take a copy if (DeRezPacket.AgentBlock.Destination != 1) { - DeleteSceneObjectGroup((SceneObjectGroup) selectedEnt); + DeleteSceneObjectGroup(objectGroup); } } } @@ -941,6 +961,11 @@ namespace OpenSim.Region.Environment.Scenes RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), BypassRayCast, bRayEndIsIntersection); + if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos)) + { + return; + } + // Rez object CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) @@ -966,7 +991,22 @@ namespace OpenSim.Region.Environment.Scenes // object itself before we rez. rootPart.Name = item.Name; rootPart.Description = item.Description; - + + List partList = new List(group.Children.Values); + foreach (SceneObjectPart part in partList) + { + if (part.OwnerID != item.Owner) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.EveryoneMask = item.EveryOnePermissions; + part.BaseMask = item.BasePermissions; + part.OwnerMask = item.CurrentPermissions; + part.NextOwnerMask = item.NextPermissions; + part.ChangeInventoryOwner(item.Owner); + } + } + rootPart.TrimPermissions(); group.ApplyPhysics(m_physicalPrim); group.StartScripts(); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 9b99df7..6e815a6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -115,6 +115,31 @@ namespace OpenSim.Region.Environment.Scenes } } + public void ChangeInventoryOwner(LLUUID ownerId) + { + lock (TaskInventory) + { + if (0 == TaskInventory.Count) + { + return; + } + + HasInventoryChanged = true; + + IList items = new List(TaskInventory.Values); + foreach (TaskInventoryItem item in items) + { + if (ownerId != item.OwnerID) + { + item.LastOwnerID = item.OwnerID; + item.OwnerID = ownerId; + item.BaseMask = item.NextOwnerMask & (uint)PermissionMask.All; + item.OwnerMask = item.NextOwnerMask & (uint)PermissionMask.All; + } + } + } + } + /// /// Start all the scripts contained in this prim's inventory /// -- cgit v1.1