recover PermissionsUtil.ApplyFoldedPermissions (well my version). its use easys code readability

httptests
UbitUmarov 2017-04-29 19:07:04 +01:00
parent 725ccbb477
commit 04117d9f75
6 changed files with 59 additions and 36 deletions

View File

@ -3087,15 +3087,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// </summary>
private void ApplyNextOwnerPermissions(InventoryItemBase item)
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
if (item.InvType == (int)InventoryType.Object)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
uint perms = item.CurrentPermissions;
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
item.CurrentPermissions = perms;
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryOnePermissions &= item.NextPermissions;

View File

@ -64,5 +64,37 @@ namespace OpenSim.Framework
str = ".";
return str;
}
public static void ApplyFoldedPermissions(uint source, ref uint target)
{
uint folded = source & (uint)PermissionMask.FoldedMask;
if(folded == 0) // invalid we need to ignore
return;
folded <<= (int)PermissionMask.FoldingShift;
folded &= (uint)PermissionMask.UnfoldedMask; // not really necessary but well
folded |= ~(uint)PermissionMask.UnfoldedMask;
uint tmp = target;
tmp &= folded;
target = tmp;
}
// do not touch MOD
public static void ApplyNoModFoldedPermissions(uint source, ref uint target)
{
uint folded = source & (uint)PermissionMask.FoldedMask;
if(folded == 0) // invalid we need to ignore
return;
folded <<= (int)PermissionMask.FoldingShift;
folded &= (uint)PermissionMask.UnfoldedMask; // not really necessary but well
folded |= (~(uint)PermissionMask.UnfoldedMask | (uint)PermissionMask.Modify);
uint tmp = target;
tmp &= folded;
target = tmp;
}
}
}

View File

@ -92,8 +92,8 @@ namespace OpenSim.Framework
// explicitly given
All = 0x8e000,
AllAndExport = 0x9e000,
AllEffective = 0x9e000
AllEffective = 0x9e000,
UnfoldedMask = 0x1e000
}
/// <summary>

View File

@ -573,7 +573,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions,
IClientAPI remoteClient)
{
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export | PermissionMask.FoldedMask);
// For the porposes of inventory, an object is modify if the prims
// are modify. This allows renaming an object that contains no
@ -586,19 +586,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
effectivePerms &= groupPerms;
}
effectivePerms |= (uint)PermissionMask.Move;
if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
if ((effectivePerms & (uint)PermissionMask.FoldedCopy) == 0)
effectivePerms &= ~(uint)PermissionMask.Copy;
if ((effectivePerms & (uint)PermissionMask.FoldedTransfer) == 0)
effectivePerms &= ~(uint)PermissionMask.Transfer;
if ((effectivePerms & (uint)PermissionMask.FoldedExport) == 0)
effectivePerms &= ~(uint)PermissionMask.Export;
PermissionsUtil.ApplyNoModFoldedPermissions(effectivePerms, ref effectivePerms);
uint basePerms = effectivePerms & so.RootPart.NextOwnerMask;
// rebuild folded perms since we don't have then on inworld objects
// possible existent ones where already unfolded
if((basePerms & (uint)PermissionMask.Copy) == 0)
basePerms |= (uint)PermissionMask.Transfer;

View File

@ -208,19 +208,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
perms = group.GetEffectivePermissions(false);
// if((perms & (uint)PermissionMask.FoldedMask) != 0)
{
if ((perms & (uint)PermissionMask.FoldedCopy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((perms & (uint)PermissionMask.FoldedTransfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((perms & (uint)PermissionMask.FoldedModify) == 0)
perms &= ~(uint)PermissionMask.Modify;
if ((perms & (uint)PermissionMask.FoldedExport) == 0)
perms &= ~(uint)PermissionMask.Export;
}
PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;
// we need to rebuild folded here
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = part.NextOwnerMask;
item.EveryOnePermissions = part.EveryoneMask &
part.NextOwnerMask;

View File

@ -1267,17 +1267,19 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: Fix this after the inventory fixer exists and has beenr run
if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
{
agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
agentItem.BasePermissions = taskItem.BasePermissions & taskItem.NextPermissions;
if (taskItem.InvType == (int)InventoryType.Object)
{
if((taskItem.CurrentPermissions & (uint)PermissionMask.FoldedMask) != 0)
agentItem.BasePermissions &=
(((taskItem.CurrentPermissions & (uint)PermissionMask.FoldedMask ) << (int)PermissionMask.FoldingShift) |
(taskItem.CurrentPermissions & (uint)PermissionMask.Move));
uint perms = agentItem.BasePermissions;
PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms );
agentItem.BasePermissions = perms;
}
else
agentItem.BasePermissions &= taskItem.CurrentPermissions;
// always unlock
agentItem.BasePermissions |= (uint)PermissionMask.Move;
agentItem.CurrentPermissions = agentItem.BasePermissions;
agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;