diff options
author | UbitUmarov | 2017-01-19 00:51:55 +0000 |
---|---|---|
committer | UbitUmarov | 2017-01-19 00:51:55 +0000 |
commit | 3b96cd8ff2e764682ccadf7f04885302b07f964b (patch) | |
tree | 91336de16ce82af3d24814133fb7909d9eed0433 /OpenSim/Region/CoreModules | |
parent | a few more changes on Permissions module (diff) | |
download | opensim-SC_OLD-3b96cd8ff2e764682ccadf7f04885302b07f964b.zip opensim-SC_OLD-3b96cd8ff2e764682ccadf7f04885302b07f964b.tar.gz opensim-SC_OLD-3b96cd8ff2e764682ccadf7f04885302b07f964b.tar.bz2 opensim-SC_OLD-3b96cd8ff2e764682ccadf7f04885302b07f964b.tar.xz |
add a GetItemPermissions() to be used use on object contents checks in Permissions module
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 99 |
1 files changed, 83 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index d70cf61..3264071 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -928,6 +928,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
928 | return group.EffectiveEveryOnePerms & lockmask; | 928 | return group.EffectiveEveryOnePerms & lockmask; |
929 | } | 929 | } |
930 | 930 | ||
931 | private uint GetItemPermissions(TaskInventoryItem ti, UUID userID, bool notEveryone) | ||
932 | { | ||
933 | UUID tiOwnerID = ti.OwnerID; | ||
934 | if(tiOwnerID == userID) | ||
935 | return ti.CurrentPermissions; | ||
936 | |||
937 | // ?? | ||
938 | if (IsFriendWithPerms(userID, tiOwnerID)) | ||
939 | return ti.CurrentPermissions; | ||
940 | |||
941 | UUID tiGroupID = ti.GroupID; | ||
942 | if(tiGroupID != UUID.Zero) | ||
943 | { | ||
944 | ulong powers = 0; | ||
945 | if(GroupMemberPowers(tiGroupID, userID, ref powers)) | ||
946 | { | ||
947 | if(tiGroupID == ti.OwnerID) | ||
948 | { | ||
949 | if((powers & (ulong)GroupPowers.ObjectManipulate) != 0) | ||
950 | return ti.CurrentPermissions; | ||
951 | } | ||
952 | uint p = ti.GroupPermissions; | ||
953 | if(!notEveryone) | ||
954 | p |= ti.EveryonePermissions; | ||
955 | return p; | ||
956 | } | ||
957 | } | ||
958 | |||
959 | if(notEveryone) | ||
960 | return 0; | ||
961 | |||
962 | return ti.EveryonePermissions; | ||
963 | } | ||
964 | |||
931 | /// <summary> | 965 | /// <summary> |
932 | /// General permissions checks for any operation involving an object. These supplement more specific checks | 966 | /// General permissions checks for any operation involving an object. These supplement more specific checks |
933 | /// implemented by callers. | 967 | /// implemented by callers. |
@@ -1796,7 +1830,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1796 | 1830 | ||
1797 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); | 1831 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); |
1798 | 1832 | ||
1799 | if (ti == null) | 1833 | // if (ti == null || ti.InvType != (int)InventoryType.LSL) |
1834 | if (ti == null) // legacy may not have type | ||
1800 | return false; | 1835 | return false; |
1801 | 1836 | ||
1802 | if (ti.OwnerID != user) | 1837 | if (ti.OwnerID != user) |
@@ -1870,6 +1905,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1870 | 1905 | ||
1871 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); | 1906 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); |
1872 | 1907 | ||
1908 | // if (ti == null || ti.InvType != (int)InventoryType.Notecard) | ||
1873 | if (ti == null) | 1909 | if (ti == null) |
1874 | return false; | 1910 | return false; |
1875 | 1911 | ||
@@ -1938,6 +1974,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1938 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 1974 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
1939 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 1975 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
1940 | 1976 | ||
1977 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | ||
1978 | if (part == null) | ||
1979 | return false; | ||
1980 | |||
1981 | SceneObjectGroup sog = part.ParentGroup; | ||
1982 | if (sog == null) | ||
1983 | return false; | ||
1984 | |||
1985 | uint perms = GetObjectPermissions(objectID, sog, true); | ||
1986 | if((perms & (uint)PermissionMask.Modify) == 0) | ||
1987 | return false; | ||
1988 | |||
1989 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); | ||
1990 | if(ti == null) | ||
1991 | return false; | ||
1992 | |||
1993 | //TODO item perm ? | ||
1941 | return true; | 1994 | return true; |
1942 | } | 1995 | } |
1943 | 1996 | ||
@@ -1946,6 +1999,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1946 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 1999 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
1947 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 2000 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
1948 | 2001 | ||
2002 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | ||
2003 | if (part == null) | ||
2004 | return false; | ||
2005 | |||
2006 | SceneObjectGroup sog = part.ParentGroup; | ||
2007 | if (sog == null) | ||
2008 | return false; | ||
2009 | |||
2010 | uint perms = GetObjectPermissions(objectID, sog, true); | ||
2011 | if((perms & (uint)PermissionMask.Modify) == 0) | ||
2012 | return false; | ||
2013 | |||
2014 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); | ||
2015 | if(ti == null) | ||
2016 | return false; | ||
2017 | |||
2018 | //TODO item perm ? | ||
1949 | return true; | 2019 | return true; |
1950 | } | 2020 | } |
1951 | 2021 | ||
@@ -1962,26 +2032,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1962 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 2032 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
1963 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 2033 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
1964 | 2034 | ||
1965 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | ||
1966 | ScenePresence p = m_scene.GetScenePresence(userID); | 2035 | ScenePresence p = m_scene.GetScenePresence(userID); |
1967 | 2036 | ||
1968 | if (part == null || p == null) | 2037 | if (p == null) |
2038 | return false; | ||
2039 | |||
2040 | SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID); | ||
2041 | if (sog == null) | ||
2042 | return false; | ||
2043 | |||
2044 | uint perms = GetObjectPermissions(userID, sog, true); | ||
2045 | if((perms & (uint)PermissionMask.Modify) == 0) | ||
1969 | return false; | 2046 | return false; |
1970 | 2047 | ||
1971 | if (!IsAdministrator(userID)) | 2048 | if ((int)InventoryType.LSL == invType) |
1972 | { | 2049 | { |
1973 | if (part.OwnerID != userID) | 2050 | if (m_allowedScriptCreators == UserSet.Administrators) |
1974 | { | 2051 | return false; |
1975 | // Group permissions | ||
1976 | if ((part.GroupID == UUID.Zero) || (p.ControllingClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0)) | ||
1977 | return false; | ||
1978 | } else { | ||
1979 | if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) | ||
1980 | return false; | ||
1981 | } | ||
1982 | if ((int)InventoryType.LSL == invType) | ||
1983 | if (m_allowedScriptCreators == UserSet.Administrators) | ||
1984 | return false; | ||
1985 | } | 2052 | } |
1986 | 2053 | ||
1987 | return true; | 2054 | return true; |