diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/General/PolicyManager/ACL.cs | 514 | ||||
-rw-r--r-- | OpenSim/Region/Communications/Local/LocalLoginService.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/ModuleLoader.cs | 428 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Environment/PermissionManager.cs | 654 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 20 |
6 files changed, 815 insertions, 815 deletions
diff --git a/OpenSim/Framework/General/PolicyManager/ACL.cs b/OpenSim/Framework/General/PolicyManager/ACL.cs index 8dffe7b..b6f2966 100644 --- a/OpenSim/Framework/General/PolicyManager/ACL.cs +++ b/OpenSim/Framework/General/PolicyManager/ACL.cs | |||
@@ -1,257 +1,257 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Framework.PolicyManager | 32 | namespace OpenSim.Framework.PolicyManager |
33 | { | 33 | { |
34 | // ACL Class | 34 | // ACL Class |
35 | // Modelled after the structure of the Zend ACL Framework Library | 35 | // Modelled after the structure of the Zend ACL Framework Library |
36 | // with one key difference - the tree will search for all matching | 36 | // with one key difference - the tree will search for all matching |
37 | // permissions rather than just the first. Deny permissions will | 37 | // permissions rather than just the first. Deny permissions will |
38 | // override all others. | 38 | // override all others. |
39 | 39 | ||
40 | 40 | ||
41 | #region ACL Core Class | 41 | #region ACL Core Class |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Access Control List Engine | 43 | /// Access Control List Engine |
44 | /// </summary> | 44 | /// </summary> |
45 | public class ACL | 45 | public class ACL |
46 | { | 46 | { |
47 | Dictionary<string, Role> Roles = new Dictionary<string, Role>(); | 47 | Dictionary<string, Role> Roles = new Dictionary<string, Role>(); |
48 | Dictionary<string, Resource> Resources = new Dictionary<string, Resource>(); | 48 | Dictionary<string, Resource> Resources = new Dictionary<string, Resource>(); |
49 | 49 | ||
50 | public ACL AddRole(Role role) | 50 | public ACL AddRole(Role role) |
51 | { | 51 | { |
52 | if (Roles.ContainsKey(role.Name)) | 52 | if (Roles.ContainsKey(role.Name)) |
53 | throw new AlreadyContainsRoleException(role); | 53 | throw new AlreadyContainsRoleException(role); |
54 | 54 | ||
55 | Roles.Add(role.Name, role); | 55 | Roles.Add(role.Name, role); |
56 | 56 | ||
57 | return this; | 57 | return this; |
58 | } | 58 | } |
59 | 59 | ||
60 | public ACL AddResource(Resource resource) | 60 | public ACL AddResource(Resource resource) |
61 | { | 61 | { |
62 | Resources.Add(resource.Name, resource); | 62 | Resources.Add(resource.Name, resource); |
63 | 63 | ||
64 | return this; | 64 | return this; |
65 | } | 65 | } |
66 | 66 | ||
67 | public Permission HasPermission(string role, string resource) | 67 | public Permission HasPermission(string role, string resource) |
68 | { | 68 | { |
69 | if (!Roles.ContainsKey(role)) | 69 | if (!Roles.ContainsKey(role)) |
70 | throw new KeyNotFoundException(); | 70 | throw new KeyNotFoundException(); |
71 | 71 | ||
72 | if (!Resources.ContainsKey(resource)) | 72 | if (!Resources.ContainsKey(resource)) |
73 | throw new KeyNotFoundException(); | 73 | throw new KeyNotFoundException(); |
74 | 74 | ||
75 | return Roles[role].RequestPermission(resource); | 75 | return Roles[role].RequestPermission(resource); |
76 | } | 76 | } |
77 | 77 | ||
78 | public ACL GrantPermission(string role, string resource) | 78 | public ACL GrantPermission(string role, string resource) |
79 | { | 79 | { |
80 | if (!Roles.ContainsKey(role)) | 80 | if (!Roles.ContainsKey(role)) |
81 | throw new KeyNotFoundException(); | 81 | throw new KeyNotFoundException(); |
82 | 82 | ||
83 | if (!Resources.ContainsKey(resource)) | 83 | if (!Resources.ContainsKey(resource)) |
84 | throw new KeyNotFoundException(); | 84 | throw new KeyNotFoundException(); |
85 | 85 | ||
86 | Roles[role].GivePermission(resource, Permission.Allow); | 86 | Roles[role].GivePermission(resource, Permission.Allow); |
87 | 87 | ||
88 | return this; | 88 | return this; |
89 | } | 89 | } |
90 | 90 | ||
91 | public ACL DenyPermission(string role, string resource) | 91 | public ACL DenyPermission(string role, string resource) |
92 | { | 92 | { |
93 | if (!Roles.ContainsKey(role)) | 93 | if (!Roles.ContainsKey(role)) |
94 | throw new KeyNotFoundException(); | 94 | throw new KeyNotFoundException(); |
95 | 95 | ||
96 | if (!Resources.ContainsKey(resource)) | 96 | if (!Resources.ContainsKey(resource)) |
97 | throw new KeyNotFoundException(); | 97 | throw new KeyNotFoundException(); |
98 | 98 | ||
99 | Roles[role].GivePermission(resource, Permission.Deny); | 99 | Roles[role].GivePermission(resource, Permission.Deny); |
100 | 100 | ||
101 | return this; | 101 | return this; |
102 | } | 102 | } |
103 | 103 | ||
104 | public ACL ResetPermission(string role, string resource) | 104 | public ACL ResetPermission(string role, string resource) |
105 | { | 105 | { |
106 | if (!Roles.ContainsKey(role)) | 106 | if (!Roles.ContainsKey(role)) |
107 | throw new KeyNotFoundException(); | 107 | throw new KeyNotFoundException(); |
108 | 108 | ||
109 | if (!Resources.ContainsKey(resource)) | 109 | if (!Resources.ContainsKey(resource)) |
110 | throw new KeyNotFoundException(); | 110 | throw new KeyNotFoundException(); |
111 | 111 | ||
112 | Roles[role].GivePermission(resource, Permission.None); | 112 | Roles[role].GivePermission(resource, Permission.None); |
113 | 113 | ||
114 | return this; | 114 | return this; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | #endregion | 117 | #endregion |
118 | 118 | ||
119 | #region Exceptions | 119 | #region Exceptions |
120 | /// <summary> | 120 | /// <summary> |
121 | /// Thrown when an ACL attempts to add a duplicate role. | 121 | /// Thrown when an ACL attempts to add a duplicate role. |
122 | /// </summary> | 122 | /// </summary> |
123 | public class AlreadyContainsRoleException : Exception | 123 | public class AlreadyContainsRoleException : Exception |
124 | { | 124 | { |
125 | protected Role m_role; | 125 | protected Role m_role; |
126 | 126 | ||
127 | public Role ErrorRole | 127 | public Role ErrorRole |
128 | { | 128 | { |
129 | get { return m_role; } | 129 | get { return m_role; } |
130 | } | 130 | } |
131 | 131 | ||
132 | public AlreadyContainsRoleException(Role role) | 132 | public AlreadyContainsRoleException(Role role) |
133 | { | 133 | { |
134 | m_role = role; | 134 | m_role = role; |
135 | } | 135 | } |
136 | 136 | ||
137 | public override string ToString() | 137 | public override string ToString() |
138 | { | 138 | { |
139 | return "This ACL already contains a role called '" + m_role.Name + "'."; | 139 | return "This ACL already contains a role called '" + m_role.Name + "'."; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | #endregion | 142 | #endregion |
143 | 143 | ||
144 | #region Roles and Resources | 144 | #region Roles and Resources |
145 | 145 | ||
146 | /// <summary> | 146 | /// <summary> |
147 | /// Does this Role have permission to access a specified Resource? | 147 | /// Does this Role have permission to access a specified Resource? |
148 | /// </summary> | 148 | /// </summary> |
149 | public enum Permission { Deny, None, Allow }; | 149 | public enum Permission { Deny, None, Allow }; |
150 | 150 | ||
151 | /// <summary> | 151 | /// <summary> |
152 | /// A role class, for use with Users or Groups | 152 | /// A role class, for use with Users or Groups |
153 | /// </summary> | 153 | /// </summary> |
154 | public class Role | 154 | public class Role |
155 | { | 155 | { |
156 | private string m_name; | 156 | private string m_name; |
157 | private Role[] m_parents; | 157 | private Role[] m_parents; |
158 | private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>(); | 158 | private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>(); |
159 | 159 | ||
160 | public string Name | 160 | public string Name |
161 | { | 161 | { |
162 | get { return m_name; } | 162 | get { return m_name; } |
163 | } | 163 | } |
164 | 164 | ||
165 | public Permission RequestPermission(string resource) | 165 | public Permission RequestPermission(string resource) |
166 | { | 166 | { |
167 | return RequestPermission(resource, Permission.None); | 167 | return RequestPermission(resource, Permission.None); |
168 | } | 168 | } |
169 | 169 | ||
170 | public Permission RequestPermission(string resource, Permission current) | 170 | public Permission RequestPermission(string resource, Permission current) |
171 | { | 171 | { |
172 | // Deny permissions always override any others | 172 | // Deny permissions always override any others |
173 | if (current == Permission.Deny) | 173 | if (current == Permission.Deny) |
174 | return current; | 174 | return current; |
175 | 175 | ||
176 | Permission temp = Permission.None; | 176 | Permission temp = Permission.None; |
177 | 177 | ||
178 | // Pickup non-None permissions | 178 | // Pickup non-None permissions |
179 | if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None) | 179 | if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None) |
180 | temp = m_resources[resource]; | 180 | temp = m_resources[resource]; |
181 | 181 | ||
182 | if (m_parents != null) | 182 | if (m_parents != null) |
183 | { | 183 | { |
184 | foreach (Role parent in m_parents) | 184 | foreach (Role parent in m_parents) |
185 | { | 185 | { |
186 | temp = parent.RequestPermission(resource, temp); | 186 | temp = parent.RequestPermission(resource, temp); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | return temp; | 190 | return temp; |
191 | } | 191 | } |
192 | 192 | ||
193 | public void GivePermission(string resource, Permission perm) | 193 | public void GivePermission(string resource, Permission perm) |
194 | { | 194 | { |
195 | m_resources[resource] = perm; | 195 | m_resources[resource] = perm; |
196 | } | 196 | } |
197 | 197 | ||
198 | public Role(string name) | 198 | public Role(string name) |
199 | { | 199 | { |
200 | m_name = name; | 200 | m_name = name; |
201 | m_parents = null; | 201 | m_parents = null; |
202 | } | 202 | } |
203 | 203 | ||
204 | public Role(string name, Role[] parents) | 204 | public Role(string name, Role[] parents) |
205 | { | 205 | { |
206 | m_name = name; | 206 | m_name = name; |
207 | m_parents = parents; | 207 | m_parents = parents; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | public class Resource | 211 | public class Resource |
212 | { | 212 | { |
213 | private string m_name; | 213 | private string m_name; |
214 | 214 | ||
215 | public string Name | 215 | public string Name |
216 | { | 216 | { |
217 | get { return m_name; } | 217 | get { return m_name; } |
218 | } | 218 | } |
219 | 219 | ||
220 | public Resource(string name) | 220 | public Resource(string name) |
221 | { | 221 | { |
222 | m_name = name; | 222 | m_name = name; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | #endregion | 226 | #endregion |
227 | 227 | ||
228 | #region Tests | 228 | #region Tests |
229 | 229 | ||
230 | class ACLTester | 230 | class ACLTester |
231 | { | 231 | { |
232 | public ACLTester() | 232 | public ACLTester() |
233 | { | 233 | { |
234 | ACL acl = new ACL(); | 234 | ACL acl = new ACL(); |
235 | 235 | ||
236 | Role Guests = new Role("Guests"); | 236 | Role Guests = new Role("Guests"); |
237 | acl.AddRole(Guests); | 237 | acl.AddRole(Guests); |
238 | 238 | ||
239 | Role[] parents = new Role[0]; | 239 | Role[] parents = new Role[0]; |
240 | parents[0] = Guests; | 240 | parents[0] = Guests; |
241 | 241 | ||
242 | Role JoeGuest = new Role("JoeGuest", parents); | 242 | Role JoeGuest = new Role("JoeGuest", parents); |
243 | acl.AddRole(JoeGuest); | 243 | acl.AddRole(JoeGuest); |
244 | 244 | ||
245 | Resource CanBuild = new Resource("CanBuild"); | 245 | Resource CanBuild = new Resource("CanBuild"); |
246 | acl.AddResource(CanBuild); | 246 | acl.AddResource(CanBuild); |
247 | 247 | ||
248 | 248 | ||
249 | acl.GrantPermission("Guests", "CanBuild"); | 249 | acl.GrantPermission("Guests", "CanBuild"); |
250 | 250 | ||
251 | acl.HasPermission("JoeGuest", "CanBuild"); | 251 | acl.HasPermission("JoeGuest", "CanBuild"); |
252 | 252 | ||
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | #endregion | 256 | #endregion |
257 | } | 257 | } |
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 37461c0..486a166 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs | |||
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Communications.Local | |||
137 | _login.Agent = response.AgentID; | 137 | _login.Agent = response.AgentID; |
138 | _login.Session = response.SessionID; | 138 | _login.Session = response.SessionID; |
139 | _login.SecureSession = response.SecureSessionID; | 139 | _login.SecureSession = response.SecureSessionID; |
140 | _login.CircuitCode = (uint)response.CircuitCode; | 140 | _login.CircuitCode = (uint)response.CircuitCode; |
141 | _login.StartPos = new LLVector3(128, 128, 70); | 141 | _login.StartPos = new LLVector3(128, 128, 70); |
142 | _login.CapsPath = capsPath; | 142 | _login.CapsPath = capsPath; |
143 | 143 | ||
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 4c66d2e..c579c1d 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs | |||
@@ -1,214 +1,214 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Modules; | 35 | using OpenSim.Region.Environment.Modules; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | 38 | ||
39 | namespace OpenSim.Region.Environment | 39 | namespace OpenSim.Region.Environment |
40 | { | 40 | { |
41 | public class ModuleLoader | 41 | public class ModuleLoader |
42 | { | 42 | { |
43 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | 43 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); |
44 | 44 | ||
45 | public List<IRegionModule> LoadedModules = new List<IRegionModule>(); | 45 | public List<IRegionModule> LoadedModules = new List<IRegionModule>(); |
46 | public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); | 46 | public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); |
47 | private readonly LogBase m_log; | 47 | private readonly LogBase m_log; |
48 | private IConfigSource m_config; | 48 | private IConfigSource m_config; |
49 | 49 | ||
50 | public ModuleLoader(LogBase log, IConfigSource config) | 50 | public ModuleLoader(LogBase log, IConfigSource config) |
51 | { | 51 | { |
52 | m_log = log; | 52 | m_log = log; |
53 | m_config = config; | 53 | m_config = config; |
54 | } | 54 | } |
55 | 55 | ||
56 | public void PickupModules(Scene scene, string moduleDir) | 56 | public void PickupModules(Scene scene, string moduleDir) |
57 | { | 57 | { |
58 | DirectoryInfo dir = new DirectoryInfo(moduleDir); | 58 | DirectoryInfo dir = new DirectoryInfo(moduleDir); |
59 | 59 | ||
60 | foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) | 60 | foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) |
61 | { | 61 | { |
62 | LoadRegionModules(fileInfo.FullName, scene); | 62 | LoadRegionModules(fileInfo.FullName, scene); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | public void LoadDefaultSharedModules() | 66 | public void LoadDefaultSharedModules() |
67 | { | 67 | { |
68 | DynamicTextureModule dynamicModule = new DynamicTextureModule(); | 68 | DynamicTextureModule dynamicModule = new DynamicTextureModule(); |
69 | LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); | 69 | LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); |
70 | ChatModule chat = new ChatModule(); | 70 | ChatModule chat = new ChatModule(); |
71 | LoadedSharedModules.Add(chat.Name, chat); | 71 | LoadedSharedModules.Add(chat.Name, chat); |
72 | InstantMessageModule imMod = new InstantMessageModule(); | 72 | InstantMessageModule imMod = new InstantMessageModule(); |
73 | LoadedSharedModules.Add(imMod.Name, imMod); | 73 | LoadedSharedModules.Add(imMod.Name, imMod); |
74 | LoadImageURLModule loadMod = new LoadImageURLModule(); | 74 | LoadImageURLModule loadMod = new LoadImageURLModule(); |
75 | LoadedSharedModules.Add(loadMod.Name, loadMod); | 75 | LoadedSharedModules.Add(loadMod.Name, loadMod); |
76 | } | 76 | } |
77 | 77 | ||
78 | public void InitialiseSharedModules(Scene scene) | 78 | public void InitialiseSharedModules(Scene scene) |
79 | { | 79 | { |
80 | foreach (IRegionModule module in LoadedSharedModules.Values) | 80 | foreach (IRegionModule module in LoadedSharedModules.Values) |
81 | { | 81 | { |
82 | module.Initialise(scene, m_config); | 82 | module.Initialise(scene, m_config); |
83 | scene.AddModule(module.Name, module); //should be doing this? | 83 | scene.AddModule(module.Name, module); //should be doing this? |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | public void InitializeModule(IRegionModule module, Scene scene) | 87 | public void InitializeModule(IRegionModule module, Scene scene) |
88 | { | 88 | { |
89 | module.Initialise(scene, m_config); | 89 | module.Initialise(scene, m_config); |
90 | scene.AddModule(module.Name, module); | 90 | scene.AddModule(module.Name, module); |
91 | LoadedModules.Add(module); | 91 | LoadedModules.Add(module); |
92 | } | 92 | } |
93 | 93 | ||
94 | /// <summary> | 94 | /// <summary> |
95 | /// Loads/initialises a Module instance that can be used by mutliple Regions | 95 | /// Loads/initialises a Module instance that can be used by mutliple Regions |
96 | /// </summary> | 96 | /// </summary> |
97 | /// <param name="dllName"></param> | 97 | /// <param name="dllName"></param> |
98 | /// <param name="moduleName"></param> | 98 | /// <param name="moduleName"></param> |
99 | /// <param name="scene"></param> | 99 | /// <param name="scene"></param> |
100 | public void LoadSharedModule(string dllName, string moduleName) | 100 | public void LoadSharedModule(string dllName, string moduleName) |
101 | { | 101 | { |
102 | IRegionModule module = LoadModule(dllName, moduleName); | 102 | IRegionModule module = LoadModule(dllName, moduleName); |
103 | if (module != null) | 103 | if (module != null) |
104 | { | 104 | { |
105 | LoadedSharedModules.Add(module.Name, module); | 105 | LoadedSharedModules.Add(module.Name, module); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | public void LoadRegionModules(string dllName, Scene scene) | 109 | public void LoadRegionModules(string dllName, Scene scene) |
110 | { | 110 | { |
111 | IRegionModule[] modules = LoadModules(dllName); | 111 | IRegionModule[] modules = LoadModules(dllName); |
112 | 112 | ||
113 | if (modules.Length > 0) | 113 | if (modules.Length > 0) |
114 | { | 114 | { |
115 | m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); | 115 | m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); |
116 | foreach (IRegionModule module in modules) | 116 | foreach (IRegionModule module in modules) |
117 | { | 117 | { |
118 | if (!module.IsSharedModule) | 118 | if (!module.IsSharedModule) |
119 | { | 119 | { |
120 | m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); | 120 | m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); |
121 | InitializeModule(module, scene); | 121 | InitializeModule(module, scene); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) | 127 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) |
128 | { | 128 | { |
129 | IRegionModule module = LoadModule(dllName, moduleName); | 129 | IRegionModule module = LoadModule(dllName, moduleName); |
130 | if (module != null) | 130 | if (module != null) |
131 | { | 131 | { |
132 | InitializeModule(module, scene); | 132 | InitializeModule(module, scene); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | /// <summary> | 136 | /// <summary> |
137 | /// Loads a external Module (if not already loaded) and creates a new instance of it. | 137 | /// Loads a external Module (if not already loaded) and creates a new instance of it. |
138 | /// </summary> | 138 | /// </summary> |
139 | /// <param name="dllName"></param> | 139 | /// <param name="dllName"></param> |
140 | /// <param name="moduleName"></param> | 140 | /// <param name="moduleName"></param> |
141 | /// <param name="scene"></param> | 141 | /// <param name="scene"></param> |
142 | public IRegionModule LoadModule(string dllName, string moduleName) | 142 | public IRegionModule LoadModule(string dllName, string moduleName) |
143 | { | 143 | { |
144 | IRegionModule[] modules = LoadModules(dllName); | 144 | IRegionModule[] modules = LoadModules(dllName); |
145 | 145 | ||
146 | foreach (IRegionModule module in modules) | 146 | foreach (IRegionModule module in modules) |
147 | { | 147 | { |
148 | if ((module != null) && (module.Name == moduleName)) | 148 | if ((module != null) && (module.Name == moduleName)) |
149 | { | 149 | { |
150 | return module; | 150 | return module; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | return null; | 154 | return null; |
155 | } | 155 | } |
156 | 156 | ||
157 | public IRegionModule[] LoadModules(string dllName) | 157 | public IRegionModule[] LoadModules(string dllName) |
158 | { | 158 | { |
159 | List<IRegionModule> modules = new List<IRegionModule>(); | 159 | List<IRegionModule> modules = new List<IRegionModule>(); |
160 | 160 | ||
161 | Assembly pluginAssembly; | 161 | Assembly pluginAssembly; |
162 | if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) | 162 | if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) |
163 | { | 163 | { |
164 | try | 164 | try |
165 | { | 165 | { |
166 | pluginAssembly = Assembly.LoadFrom(dllName); | 166 | pluginAssembly = Assembly.LoadFrom(dllName); |
167 | LoadedAssemblys.Add(dllName, pluginAssembly); | 167 | LoadedAssemblys.Add(dllName, pluginAssembly); |
168 | } | 168 | } |
169 | catch( BadImageFormatException e ) | 169 | catch( BadImageFormatException e ) |
170 | { | 170 | { |
171 | m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); | 171 | m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | if (pluginAssembly != null) | 176 | if (pluginAssembly != null) |
177 | { | 177 | { |
178 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 178 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
179 | { | 179 | { |
180 | if (pluginType.IsPublic) | 180 | if (pluginType.IsPublic) |
181 | { | 181 | { |
182 | if (!pluginType.IsAbstract) | 182 | if (!pluginType.IsAbstract) |
183 | { | 183 | { |
184 | if( pluginType.GetInterface("IRegionModule") != null ) | 184 | if( pluginType.GetInterface("IRegionModule") != null ) |
185 | { | 185 | { |
186 | modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); | 186 | modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | return modules.ToArray(); | 193 | return modules.ToArray(); |
194 | } | 194 | } |
195 | 195 | ||
196 | public void PostInitialise() | 196 | public void PostInitialise() |
197 | { | 197 | { |
198 | foreach (IRegionModule module in LoadedSharedModules.Values) | 198 | foreach (IRegionModule module in LoadedSharedModules.Values) |
199 | { | 199 | { |
200 | module.PostInitialise(); | 200 | module.PostInitialise(); |
201 | } | 201 | } |
202 | 202 | ||
203 | foreach (IRegionModule module in LoadedModules) | 203 | foreach (IRegionModule module in LoadedModules) |
204 | { | 204 | { |
205 | module.PostInitialise(); | 205 | module.PostInitialise(); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | public void ClearCache() | 209 | public void ClearCache() |
210 | { | 210 | { |
211 | LoadedAssemblys.Clear(); | 211 | LoadedAssemblys.Clear(); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 58b9d7b..4c1c36f 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -345,12 +345,12 @@ namespace OpenSim.Region.Environment.Modules | |||
345 | foreach (Scene m_scene in m_scenes) | 345 | foreach (Scene m_scene in m_scenes) |
346 | { | 346 | { |
347 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 347 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
348 | { | 348 | { |
349 | if (!avatar.IsChildAgent) | 349 | if (!avatar.IsChildAgent) |
350 | { | 350 | { |
351 | avatar.ControllingClient.SendChatMessage( | 351 | avatar.ControllingClient.SendChatMessage( |
352 | Helpers.StringToField(mess), 255, pos, "IRC:", | 352 | Helpers.StringToField(mess), 255, pos, "IRC:", |
353 | LLUUID.Zero); | 353 | LLUUID.Zero); |
354 | } | 354 | } |
355 | }); | 355 | }); |
356 | } | 356 | } |
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index c40012d..ab2ad8d 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs | |||
@@ -1,328 +1,328 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using OpenSim.Region.Environment.LandManagement; | 30 | using OpenSim.Region.Environment.LandManagement; |
31 | using OpenSim.Region.Environment.Scenes; | 31 | using OpenSim.Region.Environment.Scenes; |
32 | using OpenSim.Framework.PolicyManager; | 32 | using OpenSim.Framework.PolicyManager; |
33 | 33 | ||
34 | namespace OpenSim.Region.Environment | 34 | namespace OpenSim.Region.Environment |
35 | { | 35 | { |
36 | public class PermissionManager | 36 | public class PermissionManager |
37 | { | 37 | { |
38 | protected Scene m_scene; | 38 | protected Scene m_scene; |
39 | 39 | ||
40 | // Bypasses the permissions engine (always returns OK) | 40 | // Bypasses the permissions engine (always returns OK) |
41 | // disable in any production environment | 41 | // disable in any production environment |
42 | // TODO: Change this to false when permissions are a desired default | 42 | // TODO: Change this to false when permissions are a desired default |
43 | // TODO: Move to configuration option. | 43 | // TODO: Move to configuration option. |
44 | private bool m_bypassPermissions = true; | 44 | private bool m_bypassPermissions = true; |
45 | 45 | ||
46 | public bool BypassPermissions | 46 | public bool BypassPermissions |
47 | { | 47 | { |
48 | get { return m_bypassPermissions; } | 48 | get { return m_bypassPermissions; } |
49 | set { m_bypassPermissions = value; } | 49 | set { m_bypassPermissions = value; } |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | public PermissionManager(Scene scene) | 53 | public PermissionManager(Scene scene) |
54 | { | 54 | { |
55 | m_scene = scene; | 55 | m_scene = scene; |
56 | } | 56 | } |
57 | 57 | ||
58 | protected virtual void SendPermissionError(LLUUID user, string reason) | 58 | protected virtual void SendPermissionError(LLUUID user, string reason) |
59 | { | 59 | { |
60 | m_scene.EventManager.TriggerPermissionError(user, reason); | 60 | m_scene.EventManager.TriggerPermissionError(user, reason); |
61 | } | 61 | } |
62 | 62 | ||
63 | protected virtual bool IsAdministrator(LLUUID user) | 63 | protected virtual bool IsAdministrator(LLUUID user) |
64 | { | 64 | { |
65 | if (m_bypassPermissions) | 65 | if (m_bypassPermissions) |
66 | { | 66 | { |
67 | return true; | 67 | return true; |
68 | } | 68 | } |
69 | 69 | ||
70 | return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; | 70 | return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; |
71 | } | 71 | } |
72 | 72 | ||
73 | protected virtual bool IsEstateManager(LLUUID user) | 73 | protected virtual bool IsEstateManager(LLUUID user) |
74 | { | 74 | { |
75 | if (m_bypassPermissions) | 75 | if (m_bypassPermissions) |
76 | { | 76 | { |
77 | return true; | 77 | return true; |
78 | } | 78 | } |
79 | 79 | ||
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | protected virtual bool IsGridUser(LLUUID user) | 83 | protected virtual bool IsGridUser(LLUUID user) |
84 | { | 84 | { |
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | 87 | ||
88 | protected virtual bool IsGuest(LLUUID user) | 88 | protected virtual bool IsGuest(LLUUID user) |
89 | { | 89 | { |
90 | return false; | 90 | return false; |
91 | } | 91 | } |
92 | 92 | ||
93 | public virtual bool CanRezObject(LLUUID user, LLVector3 position) | 93 | public virtual bool CanRezObject(LLUUID user, LLVector3 position) |
94 | { | 94 | { |
95 | bool permission = false; | 95 | bool permission = false; |
96 | 96 | ||
97 | string reason = "Insufficient permission"; | 97 | string reason = "Insufficient permission"; |
98 | 98 | ||
99 | if (IsAdministrator(user)) | 99 | if (IsAdministrator(user)) |
100 | { | 100 | { |
101 | permission = true; | 101 | permission = true; |
102 | } | 102 | } |
103 | else | 103 | else |
104 | { | 104 | { |
105 | reason = "Not an administrator"; | 105 | reason = "Not an administrator"; |
106 | } | 106 | } |
107 | 107 | ||
108 | if (GenericParcelPermission(user, position)) | 108 | if (GenericParcelPermission(user, position)) |
109 | { | 109 | { |
110 | permission = true; | 110 | permission = true; |
111 | } | 111 | } |
112 | else | 112 | else |
113 | { | 113 | { |
114 | reason = "Not the parcel owner"; | 114 | reason = "Not the parcel owner"; |
115 | } | 115 | } |
116 | 116 | ||
117 | if (!permission) | 117 | if (!permission) |
118 | SendPermissionError(user, reason); | 118 | SendPermissionError(user, reason); |
119 | 119 | ||
120 | return permission; | 120 | return permission; |
121 | } | 121 | } |
122 | 122 | ||
123 | #region Object Permissions | 123 | #region Object Permissions |
124 | 124 | ||
125 | protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) | 125 | protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) |
126 | { | 126 | { |
127 | // Default: deny | 127 | // Default: deny |
128 | bool permission = false; | 128 | bool permission = false; |
129 | 129 | ||
130 | if (!m_scene.Entities.ContainsKey(objId)) | 130 | if (!m_scene.Entities.ContainsKey(objId)) |
131 | { | 131 | { |
132 | return false; | 132 | return false; |
133 | } | 133 | } |
134 | 134 | ||
135 | // If it's not an object, we cant edit it. | 135 | // If it's not an object, we cant edit it. |
136 | if (!(m_scene.Entities[objId] is SceneObjectGroup)) | 136 | if (!(m_scene.Entities[objId] is SceneObjectGroup)) |
137 | { | 137 | { |
138 | return false; | 138 | return false; |
139 | } | 139 | } |
140 | 140 | ||
141 | SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objId]; | 141 | SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objId]; |
142 | LLUUID taskOwner = null; | 142 | LLUUID taskOwner = null; |
143 | 143 | ||
144 | // Object owners should be able to edit their own content | 144 | // Object owners should be able to edit their own content |
145 | if (user == taskOwner) | 145 | if (user == taskOwner) |
146 | permission = true; | 146 | permission = true; |
147 | 147 | ||
148 | // Users should be able to edit what is over their land. | 148 | // Users should be able to edit what is over their land. |
149 | if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == | 149 | if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == |
150 | user) | 150 | user) |
151 | permission = true; | 151 | permission = true; |
152 | 152 | ||
153 | // Estate users should be able to edit anything in the sim | 153 | // Estate users should be able to edit anything in the sim |
154 | if (IsEstateManager(user)) | 154 | if (IsEstateManager(user)) |
155 | permission = true; | 155 | permission = true; |
156 | 156 | ||
157 | // Admin objects should not be editable by the above | 157 | // Admin objects should not be editable by the above |
158 | if (IsAdministrator(taskOwner)) | 158 | if (IsAdministrator(taskOwner)) |
159 | permission = false; | 159 | permission = false; |
160 | 160 | ||
161 | // Admin should be able to edit anything in the sim (including admin objects) | 161 | // Admin should be able to edit anything in the sim (including admin objects) |
162 | if (IsAdministrator(user)) | 162 | if (IsAdministrator(user)) |
163 | permission = true; | 163 | permission = true; |
164 | 164 | ||
165 | return permission; | 165 | return permission; |
166 | } | 166 | } |
167 | 167 | ||
168 | /// <summary> | 168 | /// <summary> |
169 | /// Permissions check - can user delete an object? | 169 | /// Permissions check - can user delete an object? |
170 | /// </summary> | 170 | /// </summary> |
171 | /// <param name="user">User attempting the delete</param> | 171 | /// <param name="user">User attempting the delete</param> |
172 | /// <param name="obj">Target object</param> | 172 | /// <param name="obj">Target object</param> |
173 | /// <returns>Has permission?</returns> | 173 | /// <returns>Has permission?</returns> |
174 | public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) | 174 | public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) |
175 | { | 175 | { |
176 | return GenericObjectPermission(user, obj); | 176 | return GenericObjectPermission(user, obj); |
177 | } | 177 | } |
178 | 178 | ||
179 | public virtual bool CanEditObject(LLUUID user, LLUUID obj) | 179 | public virtual bool CanEditObject(LLUUID user, LLUUID obj) |
180 | { | 180 | { |
181 | return GenericObjectPermission(user, obj); | 181 | return GenericObjectPermission(user, obj); |
182 | } | 182 | } |
183 | 183 | ||
184 | public virtual bool CanReturnObject(LLUUID user, LLUUID obj) | 184 | public virtual bool CanReturnObject(LLUUID user, LLUUID obj) |
185 | { | 185 | { |
186 | return GenericObjectPermission(user, obj); | 186 | return GenericObjectPermission(user, obj); |
187 | } | 187 | } |
188 | 188 | ||
189 | #endregion | 189 | #endregion |
190 | 190 | ||
191 | #region Communication Permissions | 191 | #region Communication Permissions |
192 | 192 | ||
193 | public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) | 193 | public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) |
194 | { | 194 | { |
195 | bool permission = false; | 195 | bool permission = false; |
196 | string reason = "Only registered users may communicate with another account."; | 196 | string reason = "Only registered users may communicate with another account."; |
197 | 197 | ||
198 | if (IsGridUser(user)) | 198 | if (IsGridUser(user)) |
199 | permission = true; | 199 | permission = true; |
200 | 200 | ||
201 | if (!IsGridUser(user)) | 201 | if (!IsGridUser(user)) |
202 | { | 202 | { |
203 | permission = false; | 203 | permission = false; |
204 | reason = "The person that you are messaging is not a registered user."; | 204 | reason = "The person that you are messaging is not a registered user."; |
205 | } | 205 | } |
206 | if (IsAdministrator(user)) | 206 | if (IsAdministrator(user)) |
207 | permission = true; | 207 | permission = true; |
208 | 208 | ||
209 | if (IsEstateManager(user)) | 209 | if (IsEstateManager(user)) |
210 | permission = true; | 210 | permission = true; |
211 | 211 | ||
212 | if (!permission) | 212 | if (!permission) |
213 | SendPermissionError(user, reason); | 213 | SendPermissionError(user, reason); |
214 | 214 | ||
215 | return permission; | 215 | return permission; |
216 | } | 216 | } |
217 | 217 | ||
218 | public virtual bool CanInstantMessage(LLUUID user, LLUUID target) | 218 | public virtual bool CanInstantMessage(LLUUID user, LLUUID target) |
219 | { | 219 | { |
220 | return GenericCommunicationPermission(user, target); | 220 | return GenericCommunicationPermission(user, target); |
221 | } | 221 | } |
222 | 222 | ||
223 | public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) | 223 | public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) |
224 | { | 224 | { |
225 | return GenericCommunicationPermission(user, target); | 225 | return GenericCommunicationPermission(user, target); |
226 | } | 226 | } |
227 | 227 | ||
228 | #endregion | 228 | #endregion |
229 | 229 | ||
230 | public virtual bool CanEditScript(LLUUID user, LLUUID script) | 230 | public virtual bool CanEditScript(LLUUID user, LLUUID script) |
231 | { | 231 | { |
232 | return IsAdministrator(user); | 232 | return IsAdministrator(user); |
233 | } | 233 | } |
234 | 234 | ||
235 | public virtual bool CanRunScript(LLUUID user, LLUUID script) | 235 | public virtual bool CanRunScript(LLUUID user, LLUUID script) |
236 | { | 236 | { |
237 | return IsAdministrator(user); | 237 | return IsAdministrator(user); |
238 | } | 238 | } |
239 | 239 | ||
240 | public virtual bool CanTerraform(LLUUID user, LLVector3 position) | 240 | public virtual bool CanTerraform(LLUUID user, LLVector3 position) |
241 | { | 241 | { |
242 | bool permission = false; | 242 | bool permission = false; |
243 | 243 | ||
244 | // Estate override | 244 | // Estate override |
245 | if (GenericEstatePermission(user)) | 245 | if (GenericEstatePermission(user)) |
246 | permission = true; | 246 | permission = true; |
247 | 247 | ||
248 | // Land owner can terraform too | 248 | // Land owner can terraform too |
249 | if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) | 249 | if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) |
250 | permission = true; | 250 | permission = true; |
251 | 251 | ||
252 | if (!permission) | 252 | if (!permission) |
253 | SendPermissionError(user, "Not authorized to terraform at this location."); | 253 | SendPermissionError(user, "Not authorized to terraform at this location."); |
254 | 254 | ||
255 | return permission; | 255 | return permission; |
256 | } | 256 | } |
257 | 257 | ||
258 | #region Estate Permissions | 258 | #region Estate Permissions |
259 | 259 | ||
260 | protected virtual bool GenericEstatePermission(LLUUID user) | 260 | protected virtual bool GenericEstatePermission(LLUUID user) |
261 | { | 261 | { |
262 | // Default: deny | 262 | // Default: deny |
263 | bool permission = false; | 263 | bool permission = false; |
264 | 264 | ||
265 | // Estate admins should be able to use estate tools | 265 | // Estate admins should be able to use estate tools |
266 | if (IsEstateManager(user)) | 266 | if (IsEstateManager(user)) |
267 | permission = true; | 267 | permission = true; |
268 | 268 | ||
269 | // Administrators always have permission | 269 | // Administrators always have permission |
270 | if (IsAdministrator(user)) | 270 | if (IsAdministrator(user)) |
271 | permission = true; | 271 | permission = true; |
272 | 272 | ||
273 | return permission; | 273 | return permission; |
274 | } | 274 | } |
275 | 275 | ||
276 | public virtual bool CanEditEstateTerrain(LLUUID user) | 276 | public virtual bool CanEditEstateTerrain(LLUUID user) |
277 | { | 277 | { |
278 | return GenericEstatePermission(user); | 278 | return GenericEstatePermission(user); |
279 | } | 279 | } |
280 | 280 | ||
281 | #endregion | 281 | #endregion |
282 | 282 | ||
283 | #region Parcel Permissions | 283 | #region Parcel Permissions |
284 | 284 | ||
285 | protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) | 285 | protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) |
286 | { | 286 | { |
287 | bool permission = false; | 287 | bool permission = false; |
288 | 288 | ||
289 | if (parcel.landData.ownerID == user) | 289 | if (parcel.landData.ownerID == user) |
290 | permission = true; | 290 | permission = true; |
291 | 291 | ||
292 | if (parcel.landData.isGroupOwned) | 292 | if (parcel.landData.isGroupOwned) |
293 | { | 293 | { |
294 | // TODO: Need to do some extra checks here. Requires group code. | 294 | // TODO: Need to do some extra checks here. Requires group code. |
295 | } | 295 | } |
296 | 296 | ||
297 | if (IsEstateManager(user)) | 297 | if (IsEstateManager(user)) |
298 | permission = true; | 298 | permission = true; |
299 | 299 | ||
300 | if (IsAdministrator(user)) | 300 | if (IsAdministrator(user)) |
301 | permission = true; | 301 | permission = true; |
302 | 302 | ||
303 | return permission; | 303 | return permission; |
304 | } | 304 | } |
305 | 305 | ||
306 | protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) | 306 | protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) |
307 | { | 307 | { |
308 | return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); | 308 | return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); |
309 | } | 309 | } |
310 | 310 | ||
311 | public virtual bool CanEditParcel(LLUUID user, Land parcel) | 311 | public virtual bool CanEditParcel(LLUUID user, Land parcel) |
312 | { | 312 | { |
313 | return GenericParcelPermission(user, parcel); | 313 | return GenericParcelPermission(user, parcel); |
314 | } | 314 | } |
315 | 315 | ||
316 | public virtual bool CanSellParcel(LLUUID user, Land parcel) | 316 | public virtual bool CanSellParcel(LLUUID user, Land parcel) |
317 | { | 317 | { |
318 | return GenericParcelPermission(user, parcel); | 318 | return GenericParcelPermission(user, parcel); |
319 | } | 319 | } |
320 | 320 | ||
321 | public virtual bool CanAbandonParcel(LLUUID user, Land parcel) | 321 | public virtual bool CanAbandonParcel(LLUUID user, Land parcel) |
322 | { | 322 | { |
323 | return GenericParcelPermission(user, parcel); | 323 | return GenericParcelPermission(user, parcel); |
324 | } | 324 | } |
325 | 325 | ||
326 | #endregion | 326 | #endregion |
327 | } | 327 | } |
328 | } | 328 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index d2718df..3fe9479 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs | |||
@@ -85,16 +85,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
85 | public void LoadCurrentSceneFromXml(string filename) | 85 | public void LoadCurrentSceneFromXml(string filename) |
86 | { | 86 | { |
87 | CurrentOrFirstScene.LoadPrimsFromXml(filename); | 87 | CurrentOrFirstScene.LoadPrimsFromXml(filename); |
88 | } | 88 | } |
89 | 89 | ||
90 | public void SaveCurrentSceneToXml2(string filename) | 90 | public void SaveCurrentSceneToXml2(string filename) |
91 | { | 91 | { |
92 | CurrentOrFirstScene.SavePrimsToXml2(filename); | 92 | CurrentOrFirstScene.SavePrimsToXml2(filename); |
93 | } | 93 | } |
94 | 94 | ||
95 | public void LoadCurrentSceneFromXml2(string filename) | 95 | public void LoadCurrentSceneFromXml2(string filename) |
96 | { | 96 | { |
97 | CurrentOrFirstScene.LoadPrimsFromXml2(filename); | 97 | CurrentOrFirstScene.LoadPrimsFromXml2(filename); |
98 | } | 98 | } |
99 | 99 | ||
100 | public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) | 100 | public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) |