aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-23 03:36:16 +0000
committerMelanie Thielker2008-09-23 03:36:16 +0000
commit70d264ee6cfae6cfe90d38460c4087b9956dab6c (patch)
tree2261f8969fb30b7d88bf2cb72fe5ec0ba435bcef /OpenSim/Region
parent* Update in OGP draft 3 protocol spec with regards to seed region requests ru... (diff)
downloadopensim-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')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs66
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs2
5 files changed, 90 insertions, 13 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 6915b3a..62d6efe 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4835,7 +4835,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4835 case PacketType.TransferRequest: 4835 case PacketType.TransferRequest:
4836 //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 4836 //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
4837 TransferRequestPacket transfer = (TransferRequestPacket)Pack; 4837 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
4838System.Console.WriteLine("Transfer request, source {0}", transfer.TransferInfo.SourceType);
4839 // Validate inventory transfers 4838 // Validate inventory transfers
4840 // Has to be done here, because AssetCache can't do it 4839 // Has to be done here, because AssetCache can't do it
4841 // 4840 //
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;
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index 26e5ec2..af29dc8 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
56 public IConfigSource ConfigSource; 56 public IConfigSource ConfigSource;
57 public IConfig ScriptConfigSource; 57 public IConfig ScriptConfigSource;
58 public abstract string ScriptEngineName { get; } 58 public abstract string ScriptEngineName { get; }
59 private bool m_enabled = true; 59 private bool m_enabled = false;
60 private bool m_hookUpToServer = false; 60 private bool m_hookUpToServer = false;
61 61
62 /// <summary> 62 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 9219c13..a6416c6 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
67 private int m_SleepTime; 67 private int m_SleepTime;
68 private int m_SaveTime; 68 private int m_SaveTime;
69 private ThreadPriority m_Prio; 69 private ThreadPriority m_Prio;
70 private bool m_Enabled = true; 70 private bool m_Enabled = false;
71 71
72// disable warning: need to keep a reference to XEngine.EventManager 72// disable warning: need to keep a reference to XEngine.EventManager
73// alive to avoid it being garbage collected 73// alive to avoid it being garbage collected