update folded permitions if taking from world, or after unfold

httptests
UbitUmarov 2017-04-29 22:09:45 +01:00
parent 04117d9f75
commit 522695c821
4 changed files with 30 additions and 23 deletions

View File

@ -65,9 +65,9 @@ namespace OpenSim.Framework
return str;
}
public static void ApplyFoldedPermissions(uint source, ref uint target)
public static void ApplyFoldedPermissions(uint foldedSourcePerms, ref uint targetPerms)
{
uint folded = source & (uint)PermissionMask.FoldedMask;
uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
if(folded == 0) // invalid we need to ignore
return;
@ -75,15 +75,15 @@ namespace OpenSim.Framework
folded &= (uint)PermissionMask.UnfoldedMask; // not really necessary but well
folded |= ~(uint)PermissionMask.UnfoldedMask;
uint tmp = target;
uint tmp = targetPerms;
tmp &= folded;
target = tmp;
targetPerms = tmp;
}
// do not touch MOD
public static void ApplyNoModFoldedPermissions(uint source, ref uint target)
public static void ApplyNoModFoldedPermissions(uint foldedSourcePerms, ref uint target)
{
uint folded = source & (uint)PermissionMask.FoldedMask;
uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
if(folded == 0) // invalid we need to ignore
return;
@ -96,5 +96,21 @@ namespace OpenSim.Framework
target = tmp;
}
public static uint FixAndFoldPermissions(uint perms)
{
uint tmp = perms;
// C & T rule
if((tmp & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0)
tmp |= (uint)PermissionMask.Transfer;
// unlock
tmp |= (uint)PermissionMask.Move;
tmp &= ~(uint)PermissionMask.FoldedMask;
tmp |= ((tmp >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask);
return tmp;
}
}
}

View File

@ -594,16 +594,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
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;
// unlock
basePerms |= (uint)PermissionMask.Move;
basePerms &= ~(uint)PermissionMask.FoldedMask;
basePerms |= ((basePerms >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask);
basePerms = PermissionsUtil.FixAndFoldPermissions(basePerms);
item.BasePermissions = basePerms;
item.CurrentPermissions = item.BasePermissions;
@ -1146,9 +1137,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0)
{
// We have permissions stored there so use them
part.NextOwnerMask = ((item.BasePermissions & 7) << 13);
if ((item.BasePermissions & (uint)PermissionMask.FoldedExport) != 0)
part.NextOwnerMask |= (uint)PermissionMask.Export;
part.NextOwnerMask = ((item.BasePermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift);
part.NextOwnerMask |= (uint)PermissionMask.Move;
}
else

View File

@ -210,9 +210,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
item.BasePermissions = perms & part.NextOwnerMask;
perms &= part.NextOwnerMask;
// we need to rebuild folded here
item.BasePermissions = PermissionsUtil.FixAndFoldPermissions(perms);
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = part.NextOwnerMask;

View File

@ -1272,14 +1272,16 @@ namespace OpenSim.Region.Framework.Scenes
{
uint perms = agentItem.BasePermissions;
PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms );
agentItem.BasePermissions = perms;
// perms |= (uint)PermissionMask.Move;
// agentItem.BasePermissions = perms;
agentItem.BasePermissions = PermissionsUtil.FixAndFoldPermissions(perms);
}
else
agentItem.BasePermissions &= taskItem.CurrentPermissions;
// always unlock
agentItem.BasePermissions |= (uint)PermissionMask.Move;
agentItem.CurrentPermissions = agentItem.BasePermissions;
agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;