diff options
author | Melanie Thielker | 2008-09-23 03:36:16 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-23 03:36:16 +0000 |
commit | 70d264ee6cfae6cfe90d38460c4087b9956dab6c (patch) | |
tree | 2261f8969fb30b7d88bf2cb72fe5ec0ba435bcef /OpenSim/Region/Environment | |
parent | * Update in OGP draft 3 protocol spec with regards to seed region requests ru... (diff) | |
download | opensim-SC_OLD-70d264ee6cfae6cfe90d38460c4087b9956dab6c.zip opensim-SC_OLD-70d264ee6cfae6cfe90d38460c4087b9956dab6c.tar.gz opensim-SC_OLD-70d264ee6cfae6cfe90d38460c4087b9956dab6c.tar.bz2 opensim-SC_OLD-70d264ee6cfae6cfe90d38460c4087b9956dab6c.tar.xz |
Update the permissions system to handle scripts and notecards the way
it was meant to. No functional changes, just better code
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs | 66 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 32 |
2 files changed, 88 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index ff5ba18..fbdae85 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs | |||
@@ -631,7 +631,10 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions | |||
631 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 631 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
632 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 632 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
633 | 633 | ||
634 | return false; | 634 | // If you can view it, you can edit it |
635 | // There is no viewing a no mod script | ||
636 | // | ||
637 | return CanViewScript(script, objectID, user, scene); | ||
635 | } | 638 | } |
636 | 639 | ||
637 | private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) | 640 | private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) |
@@ -639,6 +642,67 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions | |||
639 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 642 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
640 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 643 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
641 | 644 | ||
645 | if (objectID == UUID.Zero) // User inventory | ||
646 | { | ||
647 | CachedUserInfo userInfo = | ||
648 | scene.CommsManager.UserProfileCacheService.GetUserDetails(user); | ||
649 | if (userInfo == null) | ||
650 | return false; | ||
651 | |||
652 | if (userInfo.RootFolder == null) | ||
653 | return false; | ||
654 | |||
655 | InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard); | ||
656 | if (assetRequestItem == null) // Library item | ||
657 | { | ||
658 | assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); | ||
659 | |||
660 | if (assetRequestItem != null) // Implicitly readable | ||
661 | return true; | ||
662 | } | ||
663 | |||
664 | // Notecards must be both mod and copy to be saveable | ||
665 | // This is because of they're not copy, you can't read | ||
666 | // them, and if they're not mod, well, then they're | ||
667 | // not mod. Duh. | ||
668 | // | ||
669 | if ((assetRequestItem.CurrentPermissions & | ||
670 | ((uint)PermissionMask.Modify | | ||
671 | (uint)PermissionMask.Copy)) != | ||
672 | ((uint)PermissionMask.Modify | | ||
673 | (uint)PermissionMask.Copy)) | ||
674 | return false; | ||
675 | } | ||
676 | else // Prim inventory | ||
677 | { | ||
678 | SceneObjectPart part = scene.GetSceneObjectPart(objectID); | ||
679 | |||
680 | if (part == null) | ||
681 | return false; | ||
682 | |||
683 | if (part.OwnerID != user) | ||
684 | return false; | ||
685 | |||
686 | if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) | ||
687 | return false; | ||
688 | |||
689 | TaskInventoryItem ti = part.GetInventoryItem(notecard); | ||
690 | |||
691 | if (ti == null) | ||
692 | return false; | ||
693 | |||
694 | if (ti.OwnerID != user) | ||
695 | return false; | ||
696 | |||
697 | // Require full perms | ||
698 | if ((ti.CurrentPermissions & | ||
699 | ((uint)PermissionMask.Modify | | ||
700 | (uint)PermissionMask.Copy)) != | ||
701 | ((uint)PermissionMask.Modify | | ||
702 | (uint)PermissionMask.Copy)) | ||
703 | return false; | ||
704 | } | ||
705 | |||
642 | return true; | 706 | return true; |
643 | } | 707 | } |
644 | 708 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index a1c5fe7..c1c1b6e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -171,6 +171,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
171 | 171 | ||
172 | if (item != null) | 172 | if (item != null) |
173 | { | 173 | { |
174 | if ((InventoryType) item.InvType == InventoryType.Notecard) | ||
175 | { | ||
176 | if (!ExternalChecks.ExternalChecksCanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) | ||
177 | { | ||
178 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); | ||
179 | return UUID.Zero; | ||
180 | } | ||
181 | } | ||
182 | else if ((InventoryType) item.InvType == InventoryType.LSL) | ||
183 | { | ||
184 | if (!ExternalChecks.ExternalChecksCanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) | ||
185 | { | ||
186 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | ||
187 | return UUID.Zero; | ||
188 | } | ||
189 | } | ||
190 | |||
174 | AssetBase asset = | 191 | AssetBase asset = |
175 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); | 192 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); |
176 | AssetCache.AddAsset(asset); | 193 | AssetCache.AddAsset(asset); |
@@ -179,15 +196,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
179 | userInfo.UpdateItem(item); | 196 | userInfo.UpdateItem(item); |
180 | 197 | ||
181 | // remoteClient.SendInventoryItemCreateUpdate(item); | 198 | // remoteClient.SendInventoryItemCreateUpdate(item); |
182 | if ((InventoryType) item.InvType == InventoryType.Notecard) | ||
183 | { | ||
184 | //do we want to know about updated note cards? | ||
185 | } | ||
186 | else if ((InventoryType) item.InvType == InventoryType.LSL) | ||
187 | { | ||
188 | // do we want to know about updated scripts | ||
189 | } | ||
190 | |||
191 | return (asset.FullID); | 199 | return (asset.FullID); |
192 | } | 200 | } |
193 | } | 201 | } |
@@ -228,6 +236,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
228 | public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId, | 236 | public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId, |
229 | UUID primId, bool isScriptRunning, byte[] data) | 237 | UUID primId, bool isScriptRunning, byte[] data) |
230 | { | 238 | { |
239 | if (!ExternalChecks.ExternalChecksCanEditScript(itemId, primId, remoteClient.AgentId)) | ||
240 | { | ||
241 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | ||
242 | return; | ||
243 | } | ||
244 | |||
231 | // Retrieve group | 245 | // Retrieve group |
232 | SceneObjectPart part = GetSceneObjectPart(primId); | 246 | SceneObjectPart part = GetSceneObjectPart(primId); |
233 | SceneObjectGroup group = part.ParentGroup; | 247 | SceneObjectGroup group = part.ParentGroup; |