diff options
author | Justin Clark-Casey (justincc) | 2010-04-05 20:42:20 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-05-26 20:59:25 +0100 |
commit | 66a833796c6eb6c7db75fa001370b3ee7689b9e7 (patch) | |
tree | 878f12fbf906e8f82e238e8490619472577bfeed /OpenSim/Region | |
parent | Partially implement share with group option for object inventory items (diff) | |
download | opensim-SC-66a833796c6eb6c7db75fa001370b3ee7689b9e7.zip opensim-SC-66a833796c6eb6c7db75fa001370b3ee7689b9e7.tar.gz opensim-SC-66a833796c6eb6c7db75fa001370b3ee7689b9e7.tar.bz2 opensim-SC-66a833796c6eb6c7db75fa001370b3ee7689b9e7.tar.xz |
check group membership and powers with the groups module rather than just the client's active group id
this resolves the earlier issue where notecards/scripts shared with group could only be edited if the user had that group active
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index b557186..db900df 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -145,7 +145,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
145 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); | 145 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); |
146 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); | 146 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); |
147 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); | 147 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); |
148 | private IFriendsModule m_friendsModule = null; | 148 | private IFriendsModule m_friendsModule; |
149 | private IGroupsModule m_groupsModule; | ||
149 | 150 | ||
150 | #endregion | 151 | #endregion |
151 | 152 | ||
@@ -370,9 +371,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
370 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 371 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
371 | 372 | ||
372 | if (m_friendsModule == null) | 373 | if (m_friendsModule == null) |
373 | m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); | 374 | m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work"); |
374 | else | 375 | |
375 | m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); | 376 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); |
377 | |||
378 | if (m_groupsModule == null) | ||
379 | m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work"); | ||
376 | } | 380 | } |
377 | 381 | ||
378 | public void Close() | 382 | public void Close() |
@@ -407,14 +411,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
407 | // with the powers requested (powers = 0 for no powers check) | 411 | // with the powers requested (powers = 0 for no powers check) |
408 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) | 412 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) |
409 | { | 413 | { |
410 | ScenePresence sp = m_scene.GetScenePresence(userID); | 414 | if (null == m_groupsModule) |
411 | if (sp != null) | 415 | return false; |
412 | { | 416 | |
413 | IClientAPI client = sp.ControllingClient; | 417 | GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); |
414 | 418 | ||
415 | return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && | 419 | if (gmd != null) |
416 | ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); | 420 | { |
421 | if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) | ||
422 | return true; | ||
417 | } | 423 | } |
424 | |||
418 | return false; | 425 | return false; |
419 | } | 426 | } |
420 | 427 | ||
@@ -705,8 +712,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
705 | permission = false; | 712 | permission = false; |
706 | } | 713 | } |
707 | 714 | ||
715 | // m_log.DebugFormat( | ||
716 | // "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", | ||
717 | // group.GroupID, | ||
718 | // m_scene.GetSceneObjectPart(objId).GroupMask, | ||
719 | // IsGroupMember(group.GroupID, currentUser, 0), | ||
720 | // currentUser); | ||
721 | |||
708 | // Group members should be able to edit group objects | 722 | // Group members should be able to edit group objects |
709 | if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0)) | 723 | if ((group.GroupID != UUID.Zero) |
724 | && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) | ||
725 | && IsGroupMember(group.GroupID, currentUser, 0)) | ||
710 | { | 726 | { |
711 | // Return immediately, so that the administrator can shares group objects | 727 | // Return immediately, so that the administrator can shares group objects |
712 | return true; | 728 | return true; |
@@ -941,7 +957,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
941 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 957 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
942 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 958 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
943 | 959 | ||
944 | |||
945 | return GenericObjectPermission(editorID, objectID, false); | 960 | return GenericObjectPermission(editorID, objectID, false); |
946 | } | 961 | } |
947 | 962 | ||