a few more changes on permissions

httptests
UbitUmarov 2017-01-21 14:22:32 +00:00
parent 7a1d9e213e
commit c14ec1a9bd
1 changed files with 49 additions and 53 deletions

View File

@ -69,10 +69,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
} }
#region Constants #region Constants
// These are here for testing. They will be taken out
private uint PERM_LOCKED = (uint)524288; // same as move
/// <value> /// <value>
/// Different user set names that come in from the configuration file. /// Different user set names that come in from the configuration file.
/// </value> /// </value>
@ -866,7 +862,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return 0; return 0;
UUID objectOwner = group.OwnerID; UUID objectOwner = group.OwnerID;
bool locked = denyOnLocked && ((root.OwnerMask & PERM_LOCKED) == 0); bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
if (IsAdministrator(currentUser)) if (IsAdministrator(currentUser))
{ {
@ -920,7 +916,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
UUID spID = sp.UUID; UUID spID = sp.UUID;
UUID objectOwner = group.OwnerID; UUID objectOwner = group.OwnerID;
bool locked = denyOnLocked && ((root.OwnerMask & PERM_LOCKED) == 0); bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
if (sp.IsGod) if (sp.IsGod)
{ {
@ -960,12 +956,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return group.EffectiveEveryOnePerms & lockmask; return group.EffectiveEveryOnePerms & lockmask;
} }
private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti, bool notEveryone) private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti)
{ {
UUID tiOwnerID = ti.OwnerID; UUID tiOwnerID = ti.OwnerID;
if(tiOwnerID == userID) if(tiOwnerID == userID)
return ti.CurrentPermissions; return ti.CurrentPermissions;
if(IsAdministrator(userID))
return (uint)PermissionMask.AllEffective;
// ?? // ??
if (IsFriendWithPerms(userID, tiOwnerID)) if (IsFriendWithPerms(userID, tiOwnerID))
return ti.CurrentPermissions; return ti.CurrentPermissions;
@ -981,17 +979,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
return ti.CurrentPermissions; return ti.CurrentPermissions;
} }
uint p = ti.GroupPermissions; return ti.GroupPermissions;
if(!notEveryone)
p |= ti.EveryonePermissions;
return p;
} }
} }
if(notEveryone) return 0;
return 0;
return ti.EveryonePermissions;
} }
private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone) private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone)
@ -1104,19 +1096,24 @@ namespace OpenSim.Region.CoreModules.World.Permissions
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
if (parcel.LandData.OwnerID != user) // Only the owner can deed!
return false;
if(parcel.LandData.GroupID == UUID.Zero) if(parcel.LandData.GroupID == UUID.Zero)
return false; return false;
ScenePresence sp = scene.GetScenePresence(user); if (IsAdministrator(user))
IClientAPI client = sp.ControllingClient; return true;
if (parcel.LandData.OwnerID != user) // Only the owner can deed!
return false;
ScenePresence sp = scene.GetScenePresence(user);
if(sp == null)
return false;
IClientAPI client = sp.ControllingClient;
if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
return false; return false;
return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); return true;
} }
private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID) private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
@ -1383,13 +1380,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (IsAdministrator(user)) if (IsAdministrator(user))
return true; return true;
if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
return true;
if (ownerCommand) if (ownerCommand)
return false; return m_scene.RegionInfo.EstateSettings.IsEstateOwner(user);
return GenericEstatePermission(user); return IsEstateManager(user);
} }
private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp) private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
@ -1764,7 +1758,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <returns></returns> /// <returns></returns>
private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) private bool CanViewScript(UUID script, UUID objectID, UUID userID, Scene scene)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
@ -1772,7 +1766,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (objectID == UUID.Zero) // User inventory if (objectID == UUID.Zero) // User inventory
{ {
IInventoryService invService = m_scene.InventoryService; IInventoryService invService = m_scene.InventoryService;
InventoryItemBase assetRequestItem = invService.GetItem(user, script); InventoryItemBase assetRequestItem = invService.GetItem(userID, script);
if (assetRequestItem == null && LibraryRootFolder != null) // Library item if (assetRequestItem == null && LibraryRootFolder != null) // Library item
{ {
assetRequestItem = LibraryRootFolder.FindItem(script); assetRequestItem = LibraryRootFolder.FindItem(script);
@ -1792,12 +1786,16 @@ namespace OpenSim.Region.CoreModules.World.Permissions
// readable only if it's really full perms // readable only if it's really full perms
// //
if ((assetRequestItem.CurrentPermissions & if ((assetRequestItem.CurrentPermissions &
/*
((uint)PermissionMask.Modify | ((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy | (uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer)) != (uint)PermissionMask.Transfer)) !=
((uint)PermissionMask.Modify | ((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy | (uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer)) (uint)PermissionMask.Transfer))
*/
(uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
(uint)(PermissionMask.Modify | PermissionMask.Copy))
return false; return false;
} }
else // Prim inventory else // Prim inventory
@ -1810,7 +1808,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (sog == null) if (sog == null)
return false; return false;
uint perms = GetObjectPermissions(user, sog, true); uint perms = GetObjectPermissions(userID, sog, true);
if((perms & (uint)PermissionMask.Modify) == 0) if((perms & (uint)PermissionMask.Modify) == 0)
return false; return false;
@ -1820,23 +1818,21 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (ti == null) // legacy may not have type if (ti == null) // legacy may not have type
return false; return false;
if (ti.OwnerID != user) uint itperms = GetObjectItemPermissions(userID, ti);
{
if (ti.GroupID == UUID.Zero)
return false;
if (!IsGroupMember(ti.GroupID, user, 0))
return false;
}
// Require full perms // Require full perms
if ((ti.CurrentPermissions &
((uint)PermissionMask.Modify | if ((itperms &
/*
((uint)(PermissionMask.Modify |
(uint)PermissionMask.Copy | (uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer)) != (uint)PermissionMask.Transfer)) !=
((uint)PermissionMask.Modify | ((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy | (uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer)) (uint)PermissionMask.Transfer))
*/
(uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
(uint)(PermissionMask.Modify | PermissionMask.Copy))
return false; return false;
} }
@ -1851,7 +1847,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <returns></returns> /// <returns></returns>
private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) private bool CanViewNotecard(UUID notecard, UUID objectID, UUID userID, Scene scene)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
@ -1859,7 +1855,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (objectID == UUID.Zero) // User inventory if (objectID == UUID.Zero) // User inventory
{ {
IInventoryService invService = m_scene.InventoryService; IInventoryService invService = m_scene.InventoryService;
InventoryItemBase assetRequestItem = invService.GetItem(user, notecard); InventoryItemBase assetRequestItem = invService.GetItem(userID, notecard);
if (assetRequestItem == null && LibraryRootFolder != null) // Library item if (assetRequestItem == null && LibraryRootFolder != null) // Library item
{ {
assetRequestItem = LibraryRootFolder.FindItem(notecard); assetRequestItem = LibraryRootFolder.FindItem(notecard);
@ -1885,7 +1881,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (sog == null) if (sog == null)
return false; return false;
uint perms = GetObjectPermissions(user, sog, true); uint perms = GetObjectPermissions(userID, sog, true);
if((perms & (uint)PermissionMask.Modify) == 0) if((perms & (uint)PermissionMask.Modify) == 0)
return false; return false;
@ -1895,18 +1891,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (ti == null) if (ti == null)
return false; return false;
if (ti.OwnerID != user) uint itperms = GetObjectItemPermissions(userID, ti);
{
if (ti.GroupID == UUID.Zero)
return false;
if (!IsGroupMember(ti.GroupID, user, 0))
return false;
}
// Notecards are always readable unless no copy // Notecards are always readable unless no copy
// //
if ((ti.CurrentPermissions & if ((itperms &
(uint)PermissionMask.Copy) != (uint)PermissionMask.Copy) !=
(uint)PermissionMask.Copy) (uint)PermissionMask.Copy)
return false; return false;
@ -1976,7 +1965,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if(ti == null) if(ti == null)
return false; return false;
//TODO item perm ? uint itperms = GetObjectItemPermissions(userID, ti);
if((itperms & (uint)PermissionMask.Copy) == 0)
return false;
if(sog.OwnerID != userID && (itperms & (uint)PermissionMask.Transfer) == 0)
return false;
return true; return true;
} }