* Patch for #973 - Object Rez from Inventory ignores permissions - Thanks tglion!

0.6.0-stable
Adam Frisby 2008-04-23 13:22:06 +00:00
parent 3370d581e1
commit e456cb7533
4 changed files with 126 additions and 11 deletions

View File

@ -159,6 +159,44 @@ namespace OpenSim.Region.Environment
return permission; return permission;
} }
/// <summary>
/// Permissions check - can user enter an object?
/// </summary>
/// <param name="user">User attempting move an object</param>
/// <param name="oldPos">Source object-position</param>
/// <param name="newPos">Target object-position</param>
/// <returns>Has permission?</returns>
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 #region Object Permissions
public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)

View File

@ -981,6 +981,12 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup group = GetGroupByPrim(localID); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
{ {
LLVector3 oldPos = group.AbsolutePosition;
if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos))
{
group.SendGroupTerseUpdate();
return;
}
if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))
{ {
group.UpdateSinglePosition(pos, localID); group.UpdateSinglePosition(pos, localID);
@ -999,6 +1005,12 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup group = GetGroupByPrim(localID); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
{ {
LLVector3 oldPos = group.AbsolutePosition;
if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos))
{
group.SendGroupTerseUpdate();
return;
}
if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))
{ {
group.UpdateGroupPosition(pos); group.UpdateGroupPosition(pos);

View File

@ -855,9 +855,23 @@ namespace OpenSim.Region.Environment.Scenes
} }
if (selectedEnt != null) 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 = CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
@ -871,8 +885,8 @@ namespace OpenSim.Region.Environment.Scenes
AssetCache.AddAsset(asset); AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase(); InventoryItemBase item = new InventoryItemBase();
item.Creator = objectGroup.RootPart.CreatorID;
item.Owner = remoteClient.AgentId; item.Owner = remoteClient.AgentId;
item.Creator = remoteClient.AgentId;
item.ID = LLUUID.Random(); item.ID = LLUUID.Random();
item.AssetID = asset.FullID; item.AssetID = asset.FullID;
item.Description = asset.Description; item.Description = asset.Description;
@ -880,12 +894,18 @@ namespace OpenSim.Region.Environment.Scenes
item.AssetType = asset.Type; item.AssetType = asset.Type;
item.InvType = asset.InvType; item.InvType = asset.InvType;
item.Folder = DeRezPacket.AgentBlock.DestinationID; item.Folder = DeRezPacket.AgentBlock.DestinationID;
item.CurrentPermissions = 2147483647; item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
item.NextPermissions = 2147483647; if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) {
item.EveryOnePermissions = item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask; item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
item.BasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask; item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
item.CurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask; }
else
{
item.BasePermissions = objectGroup.RootPart.BaseMask;
item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
}
userInfo.AddItem(remoteClient.AgentId, item); userInfo.AddItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemCreateUpdate(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 // FIXME: Nasty hardcoding. If Destination is 1 then client wants us to take a copy
if (DeRezPacket.AgentBlock.Destination != 1) 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), RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
BypassRayCast, bRayEndIsIntersection); BypassRayCast, bRayEndIsIntersection);
if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos))
{
return;
}
// Rez object // Rez object
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
@ -967,6 +992,21 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.Name = item.Name; rootPart.Name = item.Name;
rootPart.Description = item.Description; rootPart.Description = item.Description;
List<SceneObjectPart> partList = new List<SceneObjectPart>(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(); rootPart.TrimPermissions();
group.ApplyPhysics(m_physicalPrim); group.ApplyPhysics(m_physicalPrim);
group.StartScripts(); group.StartScripts();

View File

@ -115,6 +115,31 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void ChangeInventoryOwner(LLUUID ownerId)
{
lock (TaskInventory)
{
if (0 == TaskInventory.Count)
{
return;
}
HasInventoryChanged = true;
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(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;
}
}
}
}
/// <summary> /// <summary>
/// Start all the scripts contained in this prim's inventory /// Start all the scripts contained in this prim's inventory
/// </summary> /// </summary>