diff options
author | Melanie Thielker | 2008-10-08 02:45:23 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-10-08 02:45:23 +0000 |
commit | c4d741180f0c69db90c8ccb2a06857656e7b1082 (patch) | |
tree | 6be3f8ebc4881178f2f4f8adb1c47884e3ac236e /OpenSim/Region | |
parent | Mantis#2352. Thank you kindly, Jonc for a patch that: (diff) | |
download | opensim-SC-c4d741180f0c69db90c8ccb2a06857656e7b1082.zip opensim-SC-c4d741180f0c69db90c8ccb2a06857656e7b1082.tar.gz opensim-SC-c4d741180f0c69db90c8ccb2a06857656e7b1082.tar.bz2 opensim-SC-c4d741180f0c69db90c8ccb2a06857656e7b1082.tar.xz |
Add some permissions checks and fixes
Diffstat (limited to '')
4 files changed, 72 insertions, 11 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index ea2fc04..a015c63 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs | |||
@@ -1591,9 +1591,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1591 | return; | 1591 | return; |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | doMoneyTransfer(remoteClient.AgentId, part.OwnerID, salePrice, 5000, "Object buy"); | 1594 | if (s.PerformObjectBuy(remoteClient, categoryID, localID, saleType)) |
1595 | 1595 | doMoneyTransfer(remoteClient.AgentId, part.OwnerID, salePrice, 5000, "Object buy"); | |
1596 | s.PerformObjectBuy(remoteClient, categoryID, localID, saleType); | ||
1597 | } | 1596 | } |
1598 | } | 1597 | } |
1599 | 1598 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 204ba39..eb21221 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -928,6 +928,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
928 | return null; | 928 | return null; |
929 | } | 929 | } |
930 | 930 | ||
931 | if ((destAgent != taskItem.OwnerID) && ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | ||
932 | { | ||
933 | return null; | ||
934 | } | ||
935 | |||
931 | InventoryItemBase agentItem = new InventoryItemBase(); | 936 | InventoryItemBase agentItem = new InventoryItemBase(); |
932 | 937 | ||
933 | agentItem.ID = UUID.Random(); | 938 | agentItem.ID = UUID.Random(); |
@@ -943,7 +948,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
943 | if ((destAgent != taskItem.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions()) | 948 | if ((destAgent != taskItem.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions()) |
944 | { | 949 | { |
945 | agentItem.BasePermissions = taskItem.NextPermissions; | 950 | agentItem.BasePermissions = taskItem.NextPermissions; |
946 | agentItem.CurrentPermissions = taskItem.NextPermissions; | 951 | agentItem.CurrentPermissions = taskItem.NextPermissions | 8; |
947 | agentItem.NextPermissions = taskItem.NextPermissions; | 952 | agentItem.NextPermissions = taskItem.NextPermissions; |
948 | agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; | 953 | agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; |
949 | } | 954 | } |
@@ -976,6 +981,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
976 | 981 | ||
977 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); | 982 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); |
978 | 983 | ||
984 | if (agentItem == null) | ||
985 | return; | ||
986 | |||
979 | agentItem.Folder = folderId; | 987 | agentItem.Folder = folderId; |
980 | AddInventoryItem(remoteClient, agentItem); | 988 | AddInventoryItem(remoteClient, agentItem); |
981 | } | 989 | } |
@@ -1045,6 +1053,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
1045 | avatarId); | 1053 | avatarId); |
1046 | } | 1054 | } |
1047 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); | 1055 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); |
1056 | |||
1057 | if (agentItem == null) | ||
1058 | return; | ||
1059 | |||
1048 | agentItem.Folder = folderId; | 1060 | agentItem.Folder = folderId; |
1049 | 1061 | ||
1050 | AddInventoryItem(avatarId, agentItem); | 1062 | AddInventoryItem(avatarId, agentItem); |
@@ -1082,6 +1094,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
1082 | return; | 1094 | return; |
1083 | } | 1095 | } |
1084 | 1096 | ||
1097 | // Can't transfer this | ||
1098 | // | ||
1099 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | ||
1100 | return; | ||
1101 | |||
1085 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1102 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1086 | { | 1103 | { |
1087 | // object cannot copy items to an object owned by a different owner | 1104 | // object cannot copy items to an object owned by a different owner |
@@ -1166,9 +1183,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
1166 | foreach (UUID itemID in items) | 1183 | foreach (UUID itemID in items) |
1167 | { | 1184 | { |
1168 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID); | 1185 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID); |
1169 | agentItem.Folder = newFolderID; | ||
1170 | 1186 | ||
1171 | AddInventoryItem(destID, agentItem); | 1187 | if (agentItem != null) |
1188 | { | ||
1189 | agentItem.Folder = newFolderID; | ||
1190 | |||
1191 | AddInventoryItem(destID, agentItem); | ||
1192 | } | ||
1172 | } | 1193 | } |
1173 | 1194 | ||
1174 | ScenePresence avatar; | 1195 | ScenePresence avatar; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index da6da1e..9328501 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -4089,22 +4089,30 @@ namespace OpenSim.Region.Environment.Scenes | |||
4089 | part.GetProperties(client); | 4089 | part.GetProperties(client); |
4090 | } | 4090 | } |
4091 | 4091 | ||
4092 | public void PerformObjectBuy(IClientAPI remoteClient, UUID categoryID, | 4092 | public bool PerformObjectBuy(IClientAPI remoteClient, UUID categoryID, |
4093 | uint localID, byte saleType) | 4093 | uint localID, byte saleType) |
4094 | { | 4094 | { |
4095 | SceneObjectPart part = GetSceneObjectPart(localID); | 4095 | SceneObjectPart part = GetSceneObjectPart(localID); |
4096 | 4096 | ||
4097 | if (part == null) | 4097 | if (part == null) |
4098 | return; | 4098 | return false; |
4099 | 4099 | ||
4100 | if (part.ParentGroup == null) | 4100 | if (part.ParentGroup == null) |
4101 | return; | 4101 | return false; |
4102 | 4102 | ||
4103 | SceneObjectGroup group = part.ParentGroup; | 4103 | SceneObjectGroup group = part.ParentGroup; |
4104 | 4104 | ||
4105 | switch (saleType) | 4105 | switch (saleType) |
4106 | { | 4106 | { |
4107 | case 1: // Sell as original (in-place sale) | 4107 | case 1: // Sell as original (in-place sale) |
4108 | uint effectivePerms=group.GetEffectivePermissions(); | ||
4109 | |||
4110 | if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) | ||
4111 | { | ||
4112 | remoteClient.SendAgentAlertMessage("This item doesn't appear to be for sale", false); | ||
4113 | return false; | ||
4114 | } | ||
4115 | |||
4108 | group.SetOwnerId(remoteClient.AgentId); | 4116 | group.SetOwnerId(remoteClient.AgentId); |
4109 | group.SetRootPartOwner(part, remoteClient.AgentId, | 4117 | group.SetRootPartOwner(part, remoteClient.AgentId, |
4110 | remoteClient.ActiveGroupId); | 4118 | remoteClient.ActiveGroupId); |
@@ -4138,6 +4146,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
4138 | 4146 | ||
4139 | if (userInfo != null) | 4147 | if (userInfo != null) |
4140 | { | 4148 | { |
4149 | uint perms=group.GetEffectivePermissions(); | ||
4150 | |||
4151 | if ((perms & (uint)PermissionMask.Transfer) == 0) | ||
4152 | { | ||
4153 | remoteClient.SendAgentAlertMessage("This item doesn't appear to be for sale", false); | ||
4154 | return false; | ||
4155 | } | ||
4156 | |||
4141 | AssetBase asset = CreateAsset( | 4157 | AssetBase asset = CreateAsset( |
4142 | group.GetPartName(localID), | 4158 | group.GetPartName(localID), |
4143 | group.GetPartDescription(localID), | 4159 | group.GetPartDescription(localID), |
@@ -4157,7 +4173,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
4157 | item.InvType = (int)InventoryType.Object; | 4173 | item.InvType = (int)InventoryType.Object; |
4158 | item.Folder = categoryID; | 4174 | item.Folder = categoryID; |
4159 | 4175 | ||
4160 | uint perms=group.GetEffectivePermissions(); | ||
4161 | uint nextPerms=(perms & 7) << 13; | 4176 | uint nextPerms=(perms & 7) << 13; |
4162 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | 4177 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) |
4163 | perms &= ~(uint)PermissionMask.Copy; | 4178 | perms &= ~(uint)PermissionMask.Copy; |
@@ -4177,16 +4192,42 @@ namespace OpenSim.Region.Environment.Scenes | |||
4177 | userInfo.AddItem(item); | 4192 | userInfo.AddItem(item); |
4178 | remoteClient.SendInventoryItemCreateUpdate(item); | 4193 | remoteClient.SendInventoryItemCreateUpdate(item); |
4179 | } | 4194 | } |
4195 | else | ||
4196 | { | ||
4197 | remoteClient.SendAgentAlertMessage("Cannot buy now. Your inventory is unavailable", false); | ||
4198 | return false; | ||
4199 | } | ||
4180 | break; | 4200 | break; |
4181 | 4201 | ||
4182 | case 3: // Sell contents | 4202 | case 3: // Sell contents |
4183 | List<UUID> invList = part.GetInventoryList(); | 4203 | List<UUID> invList = part.GetInventoryList(); |
4184 | 4204 | ||
4205 | bool okToSell = true; | ||
4206 | |||
4207 | foreach (UUID invID in invList) | ||
4208 | { | ||
4209 | TaskInventoryItem item = part.GetInventoryItem(invID); | ||
4210 | if ((item.CurrentPermissions & | ||
4211 | (uint)PermissionMask.Transfer) == 0) | ||
4212 | { | ||
4213 | okToSell = false; | ||
4214 | break; | ||
4215 | } | ||
4216 | } | ||
4217 | |||
4218 | if (!okToSell) | ||
4219 | { | ||
4220 | remoteClient.SendAgentAlertMessage("This item's inventory doesn't appear to be for sale", false); | ||
4221 | return false; | ||
4222 | } | ||
4223 | |||
4185 | if (invList.Count > 0) | 4224 | if (invList.Count > 0) |
4186 | MoveTaskInventoryItems(remoteClient.AgentId, part.Name, | 4225 | MoveTaskInventoryItems(remoteClient.AgentId, part.Name, |
4187 | part, invList); | 4226 | part, invList); |
4188 | break; | 4227 | break; |
4189 | } | 4228 | } |
4229 | |||
4230 | return true; | ||
4190 | } | 4231 | } |
4191 | 4232 | ||
4192 | public void CleanTempObjects() | 4233 | public void CleanTempObjects() |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 34e5305..d4346e4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -716,7 +716,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
716 | 716 | ||
717 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 717 | foreach (TaskInventoryItem item in m_taskInventory.Values) |
718 | { | 718 | { |
719 | if (item.InvType == 6) | 719 | if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0) |
720 | { | 720 | { |
721 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 721 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
722 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 722 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |