mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
Fix the new permissions error introduced with the inventory fix
The fix to allow setting perms in inventory accidentally caused folded permissions to be used as a mask for the next owner perms. The current solution isn't optimal but better than anything else we have had. Legacy objects may experience a net loss of permissions if trying to set their perms in inventory, this is deemed preferable to the prior privilege escalation possibility. New items will handle properly.
This commit is contained in:
@@ -647,7 +647,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// Modify
|
||||
uint permsMask = ~ ((uint)PermissionMask.Copy |
|
||||
(uint)PermissionMask.Transfer |
|
||||
(uint)PermissionMask.Modify);
|
||||
(uint)PermissionMask.Modify |
|
||||
(uint)PermissionMask.Export);
|
||||
|
||||
// Now, reduce the next perms to the mask bits
|
||||
// relevant to the operation
|
||||
@@ -677,6 +678,23 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
(uint)PermissionMask.Move;
|
||||
uint ownerPerms = item.CurrentPermissions;
|
||||
|
||||
// These will be applied to the root prim at next rez.
|
||||
// The legacy slam bit (bit 3) and folded permission (bits 0-2)
|
||||
// are preserved due to the above mangling
|
||||
ownerPerms &= nextPerms;
|
||||
|
||||
// Mask the base permissions. This is a conservative
|
||||
// approach altering only the three main perms
|
||||
basePerms &= nextPerms;
|
||||
|
||||
// Mask out the folded portion of the base mask.
|
||||
// While the owner mask carries the actual folded
|
||||
// permissions, the base mask carries the original
|
||||
// base mask, before masking with the folded perms.
|
||||
// We need this later for rezzing.
|
||||
basePerms &= ~(uint)PermissionMask.FoldedMask;
|
||||
basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
|
||||
|
||||
// If this is an object, root prim perms may be more
|
||||
// permissive than folded perms. Use folded perms as
|
||||
// a mask
|
||||
@@ -684,6 +702,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
// Create a safe mask for the current perms
|
||||
uint foldedPerms = (item.CurrentPermissions & 7) << 13;
|
||||
if ((item.CurrentPermissions & (uint)PermissionMask.FoldedExport) != 0)
|
||||
foldedPerms |= (uint)PermissionMask.Export;
|
||||
|
||||
foldedPerms |= permsMask;
|
||||
|
||||
bool isRootMod = (item.CurrentPermissions &
|
||||
@@ -691,6 +712,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
true : false;
|
||||
|
||||
// Mask the owner perms to the folded perms
|
||||
// Note that this is only to satisfy the viewer.
|
||||
// The effect of this will be reversed on rez.
|
||||
ownerPerms &= foldedPerms;
|
||||
basePerms &= foldedPerms;
|
||||
|
||||
@@ -705,15 +728,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
// These will be applied to the root prim at next rez.
|
||||
// The slam bit (bit 3) and folded permission (bits 0-2)
|
||||
// are preserved due to the above mangling
|
||||
ownerPerms &= nextPerms;
|
||||
|
||||
// Mask the base permissions. This is a conservative
|
||||
// approach altering only the three main perms
|
||||
basePerms &= nextPerms;
|
||||
|
||||
// Assign to the actual item. Make sure the slam bit is
|
||||
// set, if it wasn't set before.
|
||||
itemCopy.BasePermissions = basePerms;
|
||||
|
||||
Reference in New Issue
Block a user