diff options
author | UbitUmarov | 2017-01-22 03:23:50 +0000 |
---|---|---|
committer | UbitUmarov | 2017-01-22 03:23:50 +0000 |
commit | 50e318c401f69b7b3946b0a630d455bf7fe4118c (patch) | |
tree | fcdf94348e955ee39325a97ff05bb067a0d5ecdd /OpenSim/Region/CoreModules | |
parent | a few more changes on permissions (diff) | |
download | opensim-SC_OLD-50e318c401f69b7b3946b0a630d455bf7fe4118c.zip opensim-SC_OLD-50e318c401f69b7b3946b0a630d455bf7fe4118c.tar.gz opensim-SC_OLD-50e318c401f69b7b3946b0a630d455bf7fe4118c.tar.bz2 opensim-SC_OLD-50e318c401f69b7b3946b0a630d455bf7fe4118c.tar.xz |
work around group sharing and owned permitions issues, fix a non copy objects delete issue
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 206 |
1 files changed, 160 insertions, 46 deletions
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 890d07a..e16022d 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -267,6 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
267 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; | 267 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; |
268 | m_scene.Permissions.OnIsEstateManager += IsEstateManager; | 268 | m_scene.Permissions.OnIsEstateManager += IsEstateManager; |
269 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; | 269 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; |
270 | m_scene.Permissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs; | ||
270 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; | 271 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; |
271 | m_scene.Permissions.OnEditObjectByIDs += CanEditObjectByIDs; | 272 | m_scene.Permissions.OnEditObjectByIDs += CanEditObjectByIDs; |
272 | m_scene.Permissions.OnEditObject += CanEditObject; | 273 | m_scene.Permissions.OnEditObject += CanEditObject; |
@@ -674,6 +675,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
674 | PrimFlags.ObjectAnyOwner // Tells client that someone owns the object | 675 | PrimFlags.ObjectAnyOwner // Tells client that someone owns the object |
675 | ); | 676 | ); |
676 | 677 | ||
678 | const uint SHAREDMASK = (uint)( | ||
679 | PermissionMask.Move | | ||
680 | PermissionMask.Modify | | ||
681 | PermissionMask.Copy | ||
682 | ); | ||
683 | |||
677 | public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms) | 684 | public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms) |
678 | { | 685 | { |
679 | if(sp == null || task == null || curEffectivePerms == 0) | 686 | if(sp == null || task == null || curEffectivePerms == 0) |
@@ -749,20 +756,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
749 | ulong powers = 0; | 756 | ulong powers = 0; |
750 | if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers)) | 757 | if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers)) |
751 | { | 758 | { |
752 | if(groupdOwned) | 759 | // shared as priority over group roles |
760 | bool notShared = (grp.EffectiveGroupPerms & SHAREDMASK) == 0; | ||
761 | if(groupdOwned && notShared) | ||
753 | { | 762 | { |
754 | // object is owned by group, check role powers | 763 | // object is owned by group, check role powers |
755 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | 764 | if((powers & (ulong)GroupPowers.ObjectManipulate) == 0) |
756 | { | ||
757 | returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked); | ||
758 | returnMask |= | ||
759 | (uint)PrimFlags.ObjectGroupOwned | | ||
760 | (uint)PrimFlags.ObjectAnyOwner; | ||
761 | if((returnMask & (uint)PrimFlags.ObjectModify) != 0) | ||
762 | returnMask |= (uint)PrimFlags.ObjectOwnerModify; | ||
763 | return returnMask; | ||
764 | } | ||
765 | else | ||
766 | { | 765 | { |
767 | // group sharing or everyone | 766 | // group sharing or everyone |
768 | returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked); | 767 | returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked); |
@@ -771,12 +770,30 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
771 | (uint)PrimFlags.ObjectAnyOwner; | 770 | (uint)PrimFlags.ObjectAnyOwner; |
772 | return returnMask; | 771 | return returnMask; |
773 | } | 772 | } |
773 | |||
774 | // we may have copy without transfer | ||
775 | uint grpEffectiveOwnerPerms = grp.EffectiveOwnerPerms; | ||
776 | if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0) | ||
777 | grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy; | ||
778 | returnMask = ApplyObjectModifyMasks(grpEffectiveOwnerPerms, objflags, unlocked); | ||
779 | returnMask |= | ||
780 | (uint)PrimFlags.ObjectGroupOwned | | ||
781 | (uint)PrimFlags.ObjectAnyOwner; | ||
782 | if((returnMask & (uint)PrimFlags.ObjectModify) != 0) | ||
783 | returnMask |= (uint)PrimFlags.ObjectOwnerModify; | ||
784 | return returnMask; | ||
774 | } | 785 | } |
775 | else | 786 | else |
776 | { | 787 | { |
777 | // group sharing or everyone | 788 | // group sharing or everyone |
778 | returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked); | 789 | returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked); |
779 | if (taskOwnerID != UUID.Zero) | 790 | if(groupdOwned) |
791 | { | ||
792 | returnMask |= | ||
793 | (uint)PrimFlags.ObjectGroupOwned | | ||
794 | (uint)PrimFlags.ObjectAnyOwner; | ||
795 | } | ||
796 | else if (taskOwnerID != UUID.Zero) | ||
780 | returnMask |= (uint)PrimFlags.ObjectAnyOwner; | 797 | returnMask |= (uint)PrimFlags.ObjectAnyOwner; |
781 | return returnMask; | 798 | return returnMask; |
782 | } | 799 | } |
@@ -886,18 +903,21 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
886 | return group.EffectiveOwnerPerms & lockmask; | 903 | return group.EffectiveOwnerPerms & lockmask; |
887 | 904 | ||
888 | UUID sogGroupID = group.GroupID; | 905 | UUID sogGroupID = group.GroupID; |
889 | if (sogGroupID != UUID.Zero) | 906 | ulong powers = 0; |
907 | if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, currentUser, ref powers)) | ||
890 | { | 908 | { |
891 | ulong powers = 0; | 909 | bool Shared = (group.EffectiveGroupPerms & SHAREDMASK) != 0; |
892 | if(GroupMemberPowers(sogGroupID, currentUser, ref powers)) | 910 | |
893 | { | 911 | if(Shared || sogGroupID != objectOwner) |
894 | if(sogGroupID == objectOwner) | ||
895 | { | ||
896 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
897 | return group.EffectiveOwnerPerms & lockmask; | ||
898 | } | ||
899 | return group.EffectiveGroupOrEveryOnePerms & lockmask; | 912 | return group.EffectiveGroupOrEveryOnePerms & lockmask; |
900 | } | 913 | |
914 | if((powers & (ulong)GroupPowers.ObjectManipulate) == 0) | ||
915 | return group.EffectiveGroupOrEveryOnePerms & lockmask; | ||
916 | |||
917 | uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask; | ||
918 | if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0) | ||
919 | grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy; | ||
920 | return grpEffectiveOwnerPerms; | ||
901 | } | 921 | } |
902 | 922 | ||
903 | return group.EffectiveEveryOnePerms & lockmask; | 923 | return group.EffectiveEveryOnePerms & lockmask; |
@@ -939,18 +959,21 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
939 | return group.EffectiveOwnerPerms & lockmask; | 959 | return group.EffectiveOwnerPerms & lockmask; |
940 | 960 | ||
941 | UUID sogGroupID = group.GroupID; | 961 | UUID sogGroupID = group.GroupID; |
942 | if (sogGroupID != UUID.Zero) | 962 | ulong powers = 0; |
963 | if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, sp, ref powers)) | ||
943 | { | 964 | { |
944 | ulong powers = 0; | 965 | bool Shared = (group.EffectiveGroupPerms & SHAREDMASK) != 0; |
945 | if(GroupMemberPowers(sogGroupID, sp, ref powers)) | 966 | |
946 | { | 967 | if(Shared || sogGroupID != objectOwner) |
947 | if(sogGroupID == objectOwner) | ||
948 | { | ||
949 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
950 | return group.EffectiveOwnerPerms & lockmask; | ||
951 | } | ||
952 | return group.EffectiveGroupOrEveryOnePerms & lockmask; | 968 | return group.EffectiveGroupOrEveryOnePerms & lockmask; |
953 | } | 969 | |
970 | if((powers & (ulong)GroupPowers.ObjectManipulate) == 0) | ||
971 | return group.EffectiveGroupOrEveryOnePerms & lockmask; | ||
972 | |||
973 | uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask; | ||
974 | if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0) | ||
975 | grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy; | ||
976 | return grpEffectiveOwnerPerms; | ||
954 | } | 977 | } |
955 | 978 | ||
956 | return group.EffectiveEveryOnePerms & lockmask; | 979 | return group.EffectiveEveryOnePerms & lockmask; |
@@ -1167,15 +1190,59 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1167 | if((perms & (uint)PermissionMask.Copy) == 0) | 1190 | if((perms & (uint)PermissionMask.Copy) == 0) |
1168 | return false; | 1191 | return false; |
1169 | 1192 | ||
1170 | if(sog.OwnerID != sp.UUID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0) | 1193 | if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0) |
1171 | return false; | 1194 | return false; |
1172 | 1195 | ||
1173 | //If they can rez, they can duplicate | 1196 | //If they can rez, they can duplicate |
1174 | return CanRezObject(0, sp.UUID, sog.AbsolutePosition, scene); | 1197 | return CanRezObject(0, sp.UUID, sog.AbsolutePosition, scene); |
1175 | } | 1198 | } |
1176 | 1199 | ||
1177 | private bool CanDeleteObject(UUID objectID, UUID userID, Scene scene) | 1200 | private bool CanDeleteObject(SceneObjectGroup sog, ScenePresence sp) |
1201 | { | ||
1202 | // ignoring locked. viewers should warn and ask for confirmation | ||
1203 | |||
1204 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | ||
1205 | if (m_bypassPermissions) return m_bypassPermissionsValue; | ||
1206 | |||
1207 | if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted) | ||
1208 | return false; | ||
1209 | |||
1210 | if(sog.IsAttachment) | ||
1211 | return false; | ||
1212 | |||
1213 | UUID sogOwnerID = sog.OwnerID; | ||
1214 | UUID spID = sp.UUID; | ||
1215 | |||
1216 | if(sogOwnerID == spID) | ||
1217 | return true; | ||
1218 | |||
1219 | if (sp.IsGod) | ||
1220 | return true; | ||
1221 | |||
1222 | if (IsFriendWithPerms(sog.UUID, sogOwnerID)) | ||
1223 | return true; | ||
1224 | |||
1225 | UUID sogGroupID = sog.GroupID; | ||
1226 | if (sogGroupID != UUID.Zero) | ||
1227 | { | ||
1228 | ulong powers = 0; | ||
1229 | if(GroupMemberPowers(sogGroupID, sp, ref powers)) | ||
1230 | { | ||
1231 | if(sogGroupID == sogOwnerID) | ||
1232 | { | ||
1233 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
1234 | return true; | ||
1235 | } | ||
1236 | return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0; | ||
1237 | } | ||
1238 | } | ||
1239 | return false; | ||
1240 | } | ||
1241 | |||
1242 | private bool CanDeleteObjectByIDs(UUID objectID, UUID userID, Scene scene) | ||
1178 | { | 1243 | { |
1244 | // ignoring locked. viewers should warn and ask for confirmation | ||
1245 | |||
1179 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 1246 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
1180 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 1247 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
1181 | 1248 | ||
@@ -1183,11 +1250,35 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1183 | if (sog == null) | 1250 | if (sog == null) |
1184 | return false; | 1251 | return false; |
1185 | 1252 | ||
1186 | // ignoring locked. viewers should warn and ask for confirmation | 1253 | if(sog.IsAttachment) |
1187 | uint perms = GetObjectPermissions(userID, sog, false); | ||
1188 | if((perms & (uint)PermissionMask.Modify) == 0) | ||
1189 | return false; | 1254 | return false; |
1190 | return true; | 1255 | |
1256 | UUID sogOwnerID = sog.OwnerID; | ||
1257 | |||
1258 | if(sogOwnerID == userID) | ||
1259 | return true; | ||
1260 | |||
1261 | if (IsAdministrator(userID)) | ||
1262 | return true; | ||
1263 | |||
1264 | if (IsFriendWithPerms(objectID, sogOwnerID)) | ||
1265 | return true; | ||
1266 | |||
1267 | UUID sogGroupID = sog.GroupID; | ||
1268 | if (sogGroupID != UUID.Zero) | ||
1269 | { | ||
1270 | ulong powers = 0; | ||
1271 | if(GroupMemberPowers(sogGroupID, userID, ref powers)) | ||
1272 | { | ||
1273 | if(sogGroupID == sogOwnerID) | ||
1274 | { | ||
1275 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
1276 | return true; | ||
1277 | } | ||
1278 | return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0; | ||
1279 | } | ||
1280 | } | ||
1281 | return false; | ||
1191 | } | 1282 | } |
1192 | 1283 | ||
1193 | private bool CanEditObjectByIDs(UUID objectID, UUID userID, Scene scene) | 1284 | private bool CanEditObjectByIDs(UUID objectID, UUID userID, Scene scene) |
@@ -1667,6 +1758,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1667 | 1758 | ||
1668 | private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) | 1759 | private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) |
1669 | { | 1760 | { |
1761 | // ignore locked, viewers shell ask for confirmation | ||
1670 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 1762 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
1671 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 1763 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
1672 | 1764 | ||
@@ -1677,14 +1769,36 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1677 | if(sog.IsAttachment) | 1769 | if(sog.IsAttachment) |
1678 | return false; | 1770 | return false; |
1679 | 1771 | ||
1680 | // ignore locked, viewers shell ask for confirmation | 1772 | UUID sogOwnerID = sog.OwnerID; |
1681 | uint perms = GetObjectPermissions(sp, sog, false); | 1773 | UUID spID = sp.UUID; |
1682 | if((perms & (uint)PermissionMask.Modify) == 0) | 1774 | |
1775 | if(sogOwnerID == spID) | ||
1776 | return true; | ||
1777 | |||
1778 | if (sp.IsGod) | ||
1779 | return true; | ||
1780 | |||
1781 | if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0) | ||
1683 | return false; | 1782 | return false; |
1783 | |||
1784 | if (IsFriendWithPerms(sog.UUID, sogOwnerID)) | ||
1785 | return true; | ||
1684 | 1786 | ||
1685 | if (sog.OwnerID != sp.UUID && ((perms & (uint)PermissionMask.Transfer) == 0)) | 1787 | UUID sogGroupID = sog.GroupID; |
1686 | return false; | 1788 | if (sogGroupID != UUID.Zero) |
1687 | return true; | 1789 | { |
1790 | ulong powers = 0; | ||
1791 | if(GroupMemberPowers(sogGroupID, sp, ref powers)) | ||
1792 | { | ||
1793 | if(sogGroupID == sogOwnerID) | ||
1794 | { | ||
1795 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
1796 | return true; | ||
1797 | } | ||
1798 | return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0; | ||
1799 | } | ||
1800 | } | ||
1801 | return false; | ||
1688 | } | 1802 | } |
1689 | 1803 | ||
1690 | private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp) | 1804 | private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp) |
@@ -1703,7 +1817,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1703 | if((perms & (uint)PermissionMask.Copy) == 0) | 1817 | if((perms & (uint)PermissionMask.Copy) == 0) |
1704 | return false; | 1818 | return false; |
1705 | 1819 | ||
1706 | if(sog.OwnerID != sp.UUID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0) | 1820 | if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0) |
1707 | return false; | 1821 | return false; |
1708 | return true; | 1822 | return true; |
1709 | } | 1823 | } |