diff options
author | Adam Frisby | 2007-08-02 12:30:40 +0000 |
---|---|---|
committer | Adam Frisby | 2007-08-02 12:30:40 +0000 |
commit | ad03c0dc698ed65678f38ec461f0143bbd82ab2a (patch) | |
tree | d0df4ccfd0bc144077f9123cf87bd9ffa24aafe4 /OpenSim/Region/Environment | |
parent | * Fixed Issue#249 - Terrain reverting without baking crashes the simulator. (diff) | |
download | opensim-SC_OLD-ad03c0dc698ed65678f38ec461f0143bbd82ab2a.zip opensim-SC_OLD-ad03c0dc698ed65678f38ec461f0143bbd82ab2a.tar.gz opensim-SC_OLD-ad03c0dc698ed65678f38ec461f0143bbd82ab2a.tar.bz2 opensim-SC_OLD-ad03c0dc698ed65678f38ec461f0143bbd82ab2a.tar.xz |
* Added support for CreateLink to LSL Interpreted API
* Added new "PermissionManager" which handles access to protected resources for users. (ie editing other peoples objects, etc)
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/PermissionManager.cs | 108 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs | 4 |
2 files changed, 111 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs new file mode 100644 index 0000000..ec035f0 --- /dev/null +++ b/OpenSim/Region/Environment/PermissionManager.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using OpenSim.Framework; | ||
3 | using OpenSim.Framework.Types; | ||
4 | using OpenSim.Framework.Communications; | ||
5 | using OpenSim.Framework.Servers; | ||
6 | using OpenSim.Region.Capabilities; | ||
7 | using OpenSim.Region.Environment.Scenes; | ||
8 | using OpenSim.Region.Environment.LandManagement; | ||
9 | |||
10 | using libsecondlife; | ||
11 | |||
12 | namespace OpenSim.Region.Environment | ||
13 | { | ||
14 | public class PermissionManager | ||
15 | { | ||
16 | protected Scene m_scene; | ||
17 | |||
18 | public PermissionManager(Scene world) | ||
19 | { | ||
20 | m_scene = world; | ||
21 | } | ||
22 | |||
23 | private virtual bool IsAdministrator(LLUUID user) | ||
24 | { | ||
25 | return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; | ||
26 | } | ||
27 | |||
28 | private virtual bool IsEstateManager(LLUUID user) | ||
29 | { | ||
30 | return false; | ||
31 | } | ||
32 | |||
33 | public virtual bool CanRezObject(LLUUID user, LLVector3 position) | ||
34 | { | ||
35 | return true; | ||
36 | } | ||
37 | |||
38 | /// <summary> | ||
39 | /// Permissions check - can user delete an object? | ||
40 | /// </summary> | ||
41 | /// <param name="user">User attempting the delete</param> | ||
42 | /// <param name="obj">Target object</param> | ||
43 | /// <returns>Has permission?</returns> | ||
44 | public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) | ||
45 | { | ||
46 | // Default: deny | ||
47 | bool canDeRez = false; | ||
48 | |||
49 | // If it's not an object, we cant derez it. | ||
50 | if (!(m_scene.Entities[obj] is SceneObject)) | ||
51 | return false; | ||
52 | |||
53 | SceneObject task = (SceneObject)m_scene.Entities[obj]; | ||
54 | LLUUID taskOwner; // Since we dont have a 'owner' property on task yet | ||
55 | |||
56 | // Object owners should be able to delete their own content | ||
57 | if (user == taskOwner) | ||
58 | canDeRez = true; | ||
59 | |||
60 | // Users should be able to delete what is over their land. | ||
61 | if (m_scene.LandManager.getLandObject(task.Pos.X, task.Pos.Y).landData.ownerID == user) | ||
62 | canDeRez = true; | ||
63 | |||
64 | // Estate users should be able to delete anything in the sim | ||
65 | if (IsEstateManager(user)) | ||
66 | canDeRez = true; | ||
67 | |||
68 | // Admin objects should not be deletable by the above | ||
69 | if (IsAdministrator(taskOwner)) | ||
70 | canDeRez = false; | ||
71 | |||
72 | // Admin should be able to delete anything in the sim (including admin objects) | ||
73 | if (IsAdministrator(user)) | ||
74 | canDeRez = true; | ||
75 | |||
76 | return canDeRez; | ||
77 | } | ||
78 | |||
79 | public virtual bool CanEditObject(LLUUID user, LLUUID obj) | ||
80 | { | ||
81 | // Permissions for editing fall into the same category as deleting | ||
82 | // May need to add check for "no-mod" items. | ||
83 | return CanDeRezObject(user, obj); | ||
84 | } | ||
85 | |||
86 | public virtual bool CanEditScript(LLUUID user, LLUUID script) | ||
87 | { | ||
88 | return false; | ||
89 | } | ||
90 | |||
91 | public virtual bool CanRunScript(LLUUID user, LLUUID script) | ||
92 | { | ||
93 | return false; | ||
94 | } | ||
95 | |||
96 | public virtual bool CanReturnObject(LLUUID user, LLUUID obj) | ||
97 | { | ||
98 | // Same category as deleting, but eventually will need seperate check | ||
99 | // as sometimes it's better to allow returning only. | ||
100 | return CanDeRezObject(user, obj); | ||
101 | } | ||
102 | |||
103 | public virtual bool CanTerraform(LLUUID user, LLUUID position) | ||
104 | { | ||
105 | return false; | ||
106 | } | ||
107 | } | ||
108 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs index f52e9e2..284ae74 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs | |||
@@ -226,9 +226,11 @@ namespace OpenSim.Region.Scripting | |||
226 | return (float)Math.Cos(theta); | 226 | return (float)Math.Cos(theta); |
227 | } | 227 | } |
228 | 228 | ||
229 | [Obsolete("Unimplemented")] | ||
230 | public void osCreateLink(Key target, int parent) | 229 | public void osCreateLink(Key target, int parent) |
231 | { | 230 | { |
231 | if(World.Entities[target] is SceneObject) | ||
232 | Task.AddNewChildPrims((SceneObject)World.Entities[target]); | ||
233 | |||
232 | return; | 234 | return; |
233 | } | 235 | } |
234 | 236 | ||