diff options
author | Teravus Ovares (Dan Olivares) | 2009-08-18 11:09:43 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-18 11:09:43 -0400 |
commit | 311b51a1843f43daa7796a46961b65fe702e1b85 (patch) | |
tree | 756554b330c8bdd970f319c3af0327efb9017673 /OpenSim/Region/OptionalModules/Scripting/Minimodule | |
parent | * Some Physics Scene Changes to prepare for larger regions (diff) | |
parent | Fixes mantis #4020 (http://opensimulator.org/mantis/view.php?id=4020) (diff) | |
download | opensim-SC_OLD-311b51a1843f43daa7796a46961b65fe702e1b85.zip opensim-SC_OLD-311b51a1843f43daa7796a46961b65fe702e1b85.tar.gz opensim-SC_OLD-311b51a1843f43daa7796a46961b65fe702e1b85.tar.bz2 opensim-SC_OLD-311b51a1843f43daa7796a46961b65fe702e1b85.tar.xz |
*remove conflicts
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule')
12 files changed, 424 insertions, 68 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs new file mode 100644 index 0000000..533d176 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | ||
29 | { | ||
30 | public interface ISecurityCredential | ||
31 | { | ||
32 | ISocialEntity owner { get; } | ||
33 | bool CanEditObject(IObject target); | ||
34 | bool CanEditTerrain(int x, int y); | ||
35 | } | ||
36 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 849e3ca..03c1e95 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs | |||
@@ -32,19 +32,6 @@ using OpenMetaverse; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 33 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
34 | { | 34 | { |
35 | public interface IAvatarAttachment | ||
36 | { | ||
37 | //// <value> | ||
38 | /// Describes where on the avatar the attachment is located | ||
39 | /// </value> | ||
40 | int Location { get ; } | ||
41 | |||
42 | //// <value> | ||
43 | /// Accessor to the rez'ed asset, representing the attachment | ||
44 | /// </value> | ||
45 | IObject Asset { get; } | ||
46 | } | ||
47 | |||
48 | public interface IAvatar : IEntity | 35 | public interface IAvatar : IEntity |
49 | { | 36 | { |
50 | //// <value> | 37 | //// <value> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs new file mode 100644 index 0000000..1993948 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | ||
29 | { | ||
30 | public interface IAvatarAttachment | ||
31 | { | ||
32 | //// <value> | ||
33 | /// Describes where on the avatar the attachment is located | ||
34 | /// </value> | ||
35 | int Location { get ; } | ||
36 | |||
37 | //// <value> | ||
38 | /// Accessor to the rez'ed asset, representing the attachment | ||
39 | /// </value> | ||
40 | IObject Asset { get; } | ||
41 | } | ||
42 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 6415250..19f7210 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs | |||
@@ -212,6 +212,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
212 | bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) | 212 | bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) |
213 | double Bloom { get; set; } // SetPrimParms(GLOW) | 213 | double Bloom { get; set; } // SetPrimParms(GLOW) |
214 | bool Shiny { get; set; } // SetPrimParms(SHINY) | 214 | bool Shiny { get; set; } // SetPrimParms(SHINY) |
215 | bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] | 215 | bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECATE IN FAVOUR OF UUID?] |
216 | } | 216 | } |
217 | } | 217 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 5ed9af3..bf523dd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -27,9 +27,14 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.CodeDom.Compiler; | 29 | using System.CodeDom.Compiler; |
30 | using System.Collections; | ||
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Diagnostics; | ||
31 | using System.IO; | 33 | using System.IO; |
32 | using System.Reflection; | 34 | using System.Reflection; |
35 | using System.Security; | ||
36 | using System.Security.Permissions; | ||
37 | using System.Security.Policy; | ||
33 | using System.Text; | 38 | using System.Text; |
34 | using log4net; | 39 | using log4net; |
35 | using Microsoft.CSharp; | 40 | using Microsoft.CSharp; |
@@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
54 | 59 | ||
55 | private readonly MicroScheduler m_microthreads = new MicroScheduler(); | 60 | private readonly MicroScheduler m_microthreads = new MicroScheduler(); |
56 | 61 | ||
62 | |||
63 | private IConfig m_config; | ||
64 | |||
57 | public void RegisterExtension<T>(T instance) | 65 | public void RegisterExtension<T>(T instance) |
58 | { | 66 | { |
59 | m_extensions[typeof (T)] = instance; | 67 | m_extensions[typeof (T)] = instance; |
@@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
63 | { | 71 | { |
64 | if (source.Configs["MRM"] != null) | 72 | if (source.Configs["MRM"] != null) |
65 | { | 73 | { |
74 | m_config = source.Configs["MRM"]; | ||
75 | |||
66 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) | 76 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) |
67 | { | 77 | { |
68 | m_log.Info("[MRM] Enabling MRM Module"); | 78 | m_log.Info("[MRM] Enabling MRM Module"); |
@@ -112,25 +122,128 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
112 | return script; | 122 | return script; |
113 | } | 123 | } |
114 | 124 | ||
125 | /// <summary> | ||
126 | /// Create an AppDomain that contains policy restricting code to execute | ||
127 | /// with only the permissions granted by a named permission set | ||
128 | /// </summary> | ||
129 | /// <param name="permissionSetName">name of the permission set to restrict to</param> | ||
130 | /// <param name="appDomainName">'friendly' name of the appdomain to be created</param> | ||
131 | /// <exception cref="ArgumentNullException"> | ||
132 | /// if <paramref name="permissionSetName"/> is null | ||
133 | /// </exception> | ||
134 | /// <exception cref="ArgumentOutOfRangeException"> | ||
135 | /// if <paramref name="permissionSetName"/> is empty | ||
136 | /// </exception> | ||
137 | /// <returns>AppDomain with a restricted security policy</returns> | ||
138 | /// <remarks>Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx | ||
139 | /// Valid permissionSetName values are: | ||
140 | /// * FullTrust | ||
141 | /// * SkipVerification | ||
142 | /// * Execution | ||
143 | /// * Nothing | ||
144 | /// * LocalIntranet | ||
145 | /// * Internet | ||
146 | /// * Everything | ||
147 | /// </remarks> | ||
148 | public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName) | ||
149 | { | ||
150 | if (permissionSetName == null) | ||
151 | throw new ArgumentNullException("permissionSetName"); | ||
152 | if (permissionSetName.Length == 0) | ||
153 | throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName, | ||
154 | "Cannot have an empty permission set name"); | ||
155 | |||
156 | // Default to all code getting nothing | ||
157 | PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None)); | ||
158 | UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy); | ||
159 | |||
160 | bool foundName = false; | ||
161 | PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted); | ||
162 | |||
163 | // iterate over each policy level | ||
164 | IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy(); | ||
165 | while (levelEnumerator.MoveNext()) | ||
166 | { | ||
167 | PolicyLevel level = levelEnumerator.Current as PolicyLevel; | ||
168 | |||
169 | // if this level has defined a named permission set with the | ||
170 | // given name, then intersect it with what we've retrieved | ||
171 | // from all the previous levels | ||
172 | if (level != null) | ||
173 | { | ||
174 | PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName); | ||
175 | if (levelSet != null) | ||
176 | { | ||
177 | foundName = true; | ||
178 | if (setIntersection != null) | ||
179 | setIntersection = setIntersection.Intersect(levelSet); | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | |||
184 | // Intersect() can return null for an empty set, so convert that | ||
185 | // to an empty set object. Also return an empty set if we didn't find | ||
186 | // the named permission set we were looking for | ||
187 | if (setIntersection == null || !foundName) | ||
188 | setIntersection = new PermissionSet(PermissionState.None); | ||
189 | else | ||
190 | setIntersection = new NamedPermissionSet(permissionSetName, setIntersection); | ||
191 | |||
192 | // if no named permission sets were found, return an empty set, | ||
193 | // otherwise return the set that was found | ||
194 | PolicyStatement permissions = new PolicyStatement(setIntersection); | ||
195 | policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions)); | ||
196 | |||
197 | // create an AppDomain policy level for the policy tree | ||
198 | PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel(); | ||
199 | appDomainLevel.RootCodeGroup = policyRoot; | ||
200 | |||
201 | // create an AppDomain where this policy will be in effect | ||
202 | string domainName = appDomainName; | ||
203 | AppDomain restrictedDomain = AppDomain.CreateDomain(domainName); | ||
204 | restrictedDomain.SetAppDomainPolicy(appDomainLevel); | ||
205 | |||
206 | return restrictedDomain; | ||
207 | } | ||
208 | |||
209 | |||
115 | void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) | 210 | void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) |
116 | { | 211 | { |
117 | if (script.StartsWith("//MRM:C#")) | 212 | if (script.StartsWith("//MRM:C#")) |
118 | { | 213 | { |
119 | if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID | 214 | if (m_config.GetBoolean("OwnerOnly", true)) |
120 | || | 215 | if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID |
121 | m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) | 216 | || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) |
122 | return; | 217 | return; |
123 | 218 | ||
124 | script = ConvertMRMKeywords(script); | 219 | script = ConvertMRMKeywords(script); |
125 | 220 | ||
126 | try | 221 | try |
127 | { | 222 | { |
128 | m_log.Info("[MRM] Found C# MRM"); | 223 | AppDomain target; |
224 | if (m_config.GetBoolean("Sandboxed", true)) | ||
225 | { | ||
226 | m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + | ||
227 | m_config.GetString("SandboxLevel", "Internet") + "-level security."); | ||
228 | |||
229 | string domainName = UUID.Random().ToString(); | ||
230 | target = CreateRestrictedDomain(m_config.GetString("SandboxLevel", "Internet"), | ||
231 | domainName); | ||
232 | } | ||
233 | else | ||
234 | { | ||
235 | m_log.Info("[MRM] Found C# MRM - Starting in current AppDomain"); | ||
236 | m_log.Warn( | ||
237 | "[MRM] Security Risk: AppDomain is run in current context. Use only in trusted environments."); | ||
238 | target = AppDomain.CurrentDomain; | ||
239 | } | ||
129 | 240 | ||
130 | MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( | 241 | m_log.Info("[MRM] Unwrapping into target AppDomain"); |
242 | MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap( | ||
131 | CompileFromDotNetText(script, itemID.ToString()), | 243 | CompileFromDotNetText(script, itemID.ToString()), |
132 | "OpenSim.MiniModule"); | 244 | "OpenSim.MiniModule"); |
133 | 245 | ||
246 | m_log.Info("[MRM] Initialising MRM Globals"); | ||
134 | InitializeMRM(mmb, localID, itemID); | 247 | InitializeMRM(mmb, localID, itemID); |
135 | 248 | ||
136 | m_scripts[itemID] = mmb; | 249 | m_scripts[itemID] = mmb; |
@@ -166,8 +279,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
166 | 279 | ||
167 | public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) | 280 | public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) |
168 | { | 281 | { |
169 | world = new World(m_scene); | 282 | // UUID should be changed to object owner. |
170 | host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), m_microthreads); | 283 | UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
284 | SEUser securityUser = new SEUser(owner, "Name Unassigned"); | ||
285 | SecurityCredential creds = new SecurityCredential(securityUser, m_scene); | ||
286 | |||
287 | world = new World(m_scene, creds); | ||
288 | host = new Host(new SOPObject(m_scene, localID, creds), m_scene, new ExtensionHandler(m_extensions), | ||
289 | m_microthreads); | ||
171 | } | 290 | } |
172 | 291 | ||
173 | public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) | 292 | public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 4638ad0..6ba5ccf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs | |||
@@ -40,10 +40,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
40 | { | 40 | { |
41 | private readonly Scene m_scene; | 41 | private readonly Scene m_scene; |
42 | private readonly IEnumerator<EntityBase> m_sogEnum; | 42 | private readonly IEnumerator<EntityBase> m_sogEnum; |
43 | private readonly ISecurityCredential m_security; | ||
43 | 44 | ||
44 | public IObjEnum(Scene scene) | 45 | public IObjEnum(Scene scene, ISecurityCredential security) |
45 | { | 46 | { |
46 | m_scene = scene; | 47 | m_scene = scene; |
48 | m_security = security; | ||
47 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); | 49 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); |
48 | } | 50 | } |
49 | 51 | ||
@@ -66,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
66 | { | 68 | { |
67 | get | 69 | get |
68 | { | 70 | { |
69 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId); | 71 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId, m_security); |
70 | } | 72 | } |
71 | } | 73 | } |
72 | 74 | ||
@@ -79,17 +81,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
79 | public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor | 81 | public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor |
80 | { | 82 | { |
81 | private readonly Scene m_scene; | 83 | private readonly Scene m_scene; |
84 | private readonly ISecurityCredential m_security; | ||
82 | 85 | ||
83 | public ObjectAccessor(Scene scene) | 86 | public ObjectAccessor(Scene scene, ISecurityCredential security) |
84 | { | 87 | { |
85 | m_scene = scene; | 88 | m_scene = scene; |
89 | m_security = security; | ||
86 | } | 90 | } |
87 | 91 | ||
88 | public IObject this[int index] | 92 | public IObject this[int index] |
89 | { | 93 | { |
90 | get | 94 | get |
91 | { | 95 | { |
92 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); | 96 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId, m_security); |
93 | } | 97 | } |
94 | } | 98 | } |
95 | 99 | ||
@@ -97,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
97 | { | 101 | { |
98 | get | 102 | get |
99 | { | 103 | { |
100 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 104 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); |
101 | } | 105 | } |
102 | } | 106 | } |
103 | 107 | ||
@@ -105,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
105 | { | 109 | { |
106 | get | 110 | get |
107 | { | 111 | { |
108 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 112 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); |
109 | } | 113 | } |
110 | } | 114 | } |
111 | 115 | ||
@@ -117,20 +121,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
117 | public IObject Create(Vector3 position, Quaternion rotation) | 121 | public IObject Create(Vector3 position, Quaternion rotation) |
118 | { | 122 | { |
119 | 123 | ||
120 | SceneObjectGroup sog = m_scene.AddNewPrim(m_scene.RegionInfo.MasterAvatarAssignedUUID, | 124 | SceneObjectGroup sog = m_scene.AddNewPrim(m_security.owner.GlobalID, |
121 | UUID.Zero, | 125 | UUID.Zero, |
122 | position, | 126 | position, |
123 | rotation, | 127 | rotation, |
124 | PrimitiveBaseShape.CreateBox()); | 128 | PrimitiveBaseShape.CreateBox()); |
125 | 129 | ||
126 | IObject ret = new SOPObject(m_scene, sog.LocalId); | 130 | IObject ret = new SOPObject(m_scene, sog.LocalId, m_security); |
127 | 131 | ||
128 | return ret; | 132 | return ret; |
129 | } | 133 | } |
130 | 134 | ||
131 | public IEnumerator<IObject> GetEnumerator() | 135 | public IEnumerator<IObject> GetEnumerator() |
132 | { | 136 | { |
133 | return new IObjEnum(m_scene); | 137 | return new IObjEnum(m_scene, m_security); |
134 | } | 138 | } |
135 | 139 | ||
136 | IEnumerator IEnumerable.GetEnumerator() | 140 | IEnumerator IEnumerable.GetEnumerator() |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index bc26389..292e345 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Security; | ||
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
@@ -42,13 +43,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
42 | { | 43 | { |
43 | private readonly Scene m_rootScene; | 44 | private readonly Scene m_rootScene; |
44 | private readonly uint m_localID; | 45 | private readonly uint m_localID; |
46 | private readonly ISecurityCredential m_security; | ||
45 | 47 | ||
48 | [Obsolete("Replace with 'credential' constructor [security]")] | ||
46 | public SOPObject(Scene rootScene, uint localID) | 49 | public SOPObject(Scene rootScene, uint localID) |
47 | { | 50 | { |
48 | m_rootScene = rootScene; | 51 | m_rootScene = rootScene; |
49 | m_localID = localID; | 52 | m_localID = localID; |
50 | } | 53 | } |
51 | 54 | ||
55 | public SOPObject(Scene rootScene, uint localID, ISecurityCredential credential) | ||
56 | { | ||
57 | m_rootScene = rootScene; | ||
58 | m_localID = localID; | ||
59 | m_security = credential; | ||
60 | } | ||
61 | |||
52 | /// <summary> | 62 | /// <summary> |
53 | /// This needs to run very, very quickly. | 63 | /// This needs to run very, very quickly. |
54 | /// It is utilized in nearly every property and method. | 64 | /// It is utilized in nearly every property and method. |
@@ -59,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
59 | return m_rootScene.GetSceneObjectPart(m_localID); | 69 | return m_rootScene.GetSceneObjectPart(m_localID); |
60 | } | 70 | } |
61 | 71 | ||
72 | private bool CanEdit() | ||
73 | { | ||
74 | if (!m_security.CanEditObject(this)) | ||
75 | { | ||
76 | throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); | ||
77 | } | ||
78 | return true; | ||
79 | } | ||
80 | |||
62 | #region OnTouch | 81 | #region OnTouch |
63 | 82 | ||
64 | private event OnTouchDelegate _OnTouch; | 83 | private event OnTouchDelegate _OnTouch; |
@@ -68,14 +87,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
68 | { | 87 | { |
69 | add | 88 | add |
70 | { | 89 | { |
71 | if (!_OnTouchActive) | 90 | if (CanEdit()) |
72 | { | 91 | { |
73 | GetSOP().Flags |= PrimFlags.Touch; | 92 | if (!_OnTouchActive) |
74 | _OnTouchActive = true; | 93 | { |
75 | m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; | 94 | GetSOP().Flags |= PrimFlags.Touch; |
95 | _OnTouchActive = true; | ||
96 | m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; | ||
97 | } | ||
98 | |||
99 | _OnTouch += value; | ||
76 | } | 100 | } |
77 | |||
78 | _OnTouch += value; | ||
79 | } | 101 | } |
80 | remove | 102 | remove |
81 | { | 103 | { |
@@ -95,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
95 | if (_OnTouchActive && m_localID == localID) | 117 | if (_OnTouchActive && m_localID == localID) |
96 | { | 118 | { |
97 | TouchEventArgs e = new TouchEventArgs(); | 119 | TouchEventArgs e = new TouchEventArgs(); |
98 | e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); | 120 | e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId, m_security); |
99 | e.TouchBiNormal = surfaceArgs.Binormal; | 121 | e.TouchBiNormal = surfaceArgs.Binormal; |
100 | e.TouchMaterialIndex = surfaceArgs.FaceIndex; | 122 | e.TouchMaterialIndex = surfaceArgs.FaceIndex; |
101 | e.TouchNormal = surfaceArgs.Normal; | 123 | e.TouchNormal = surfaceArgs.Normal; |
@@ -130,13 +152,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
130 | public string Name | 152 | public string Name |
131 | { | 153 | { |
132 | get { return GetSOP().Name; } | 154 | get { return GetSOP().Name; } |
133 | set { GetSOP().Name = value; } | 155 | set |
156 | { | ||
157 | if (CanEdit()) | ||
158 | GetSOP().Name = value; | ||
159 | } | ||
134 | } | 160 | } |
135 | 161 | ||
136 | public string Description | 162 | public string Description |
137 | { | 163 | { |
138 | get { return GetSOP().Description; } | 164 | get { return GetSOP().Description; } |
139 | set { GetSOP().Description = value; } | 165 | set |
166 | { | ||
167 | if (CanEdit()) | ||
168 | GetSOP().Description = value; | ||
169 | } | ||
140 | } | 170 | } |
141 | 171 | ||
142 | public IObject[] Children | 172 | public IObject[] Children |
@@ -151,7 +181,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
151 | int i = 0; | 181 | int i = 0; |
152 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) | 182 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) |
153 | { | 183 | { |
154 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); | 184 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); |
155 | } | 185 | } |
156 | 186 | ||
157 | return rets; | 187 | return rets; |
@@ -160,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
160 | 190 | ||
161 | public IObject Root | 191 | public IObject Root |
162 | { | 192 | { |
163 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } | 193 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); } |
164 | } | 194 | } |
165 | 195 | ||
166 | public IObjectMaterial[] Materials | 196 | public IObjectMaterial[] Materials |
@@ -182,7 +212,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
182 | public Vector3 Scale | 212 | public Vector3 Scale |
183 | { | 213 | { |
184 | get { return GetSOP().Scale; } | 214 | get { return GetSOP().Scale; } |
185 | set { GetSOP().Scale = value; } | 215 | set |
216 | { | ||
217 | if (CanEdit()) | ||
218 | GetSOP().Scale = value; | ||
219 | } | ||
186 | } | 220 | } |
187 | 221 | ||
188 | public Quaternion WorldRotation | 222 | public Quaternion WorldRotation |
@@ -202,15 +236,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
202 | get { return GetSOP().AbsolutePosition; } | 236 | get { return GetSOP().AbsolutePosition; } |
203 | set | 237 | set |
204 | { | 238 | { |
205 | SceneObjectPart pos = GetSOP(); | 239 | if (CanEdit()) |
206 | pos.UpdateOffSet(value - pos.AbsolutePosition); | 240 | { |
241 | SceneObjectPart pos = GetSOP(); | ||
242 | pos.UpdateOffSet(value - pos.AbsolutePosition); | ||
243 | } | ||
207 | } | 244 | } |
208 | } | 245 | } |
209 | 246 | ||
210 | public Vector3 OffsetPosition | 247 | public Vector3 OffsetPosition |
211 | { | 248 | { |
212 | get { return GetSOP().OffsetPosition; } | 249 | get { return GetSOP().OffsetPosition; } |
213 | set { GetSOP().OffsetPosition = value; } | 250 | set |
251 | { | ||
252 | if (CanEdit()) | ||
253 | { | ||
254 | GetSOP().OffsetPosition = value; | ||
255 | } | ||
256 | } | ||
214 | } | 257 | } |
215 | 258 | ||
216 | public Vector3 SitTarget | 259 | public Vector3 SitTarget |
@@ -310,8 +353,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
310 | 353 | ||
311 | public void Say(string msg) | 354 | public void Say(string msg) |
312 | { | 355 | { |
313 | SceneObjectPart sop = GetSOP(); | 356 | if (!CanEdit()) |
357 | return; | ||
314 | 358 | ||
359 | SceneObjectPart sop = GetSOP(); | ||
315 | m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); | 360 | m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); |
316 | } | 361 | } |
317 | 362 | ||
@@ -503,6 +548,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
503 | } | 548 | } |
504 | set | 549 | set |
505 | { | 550 | { |
551 | if (!CanEdit()) | ||
552 | return; | ||
553 | |||
506 | GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); | 554 | GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); |
507 | } | 555 | } |
508 | } | 556 | } |
@@ -516,6 +564,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
516 | } | 564 | } |
517 | set | 565 | set |
518 | { | 566 | { |
567 | if (!CanEdit()) | ||
568 | return; | ||
569 | |||
519 | GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | 570 | GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); |
520 | } | 571 | } |
521 | } | 572 | } |
@@ -529,6 +580,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
529 | } | 580 | } |
530 | set | 581 | set |
531 | { | 582 | { |
583 | if (!CanEdit()) | ||
584 | return; | ||
585 | |||
532 | GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); | 586 | GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); |
533 | } | 587 | } |
534 | } | 588 | } |
@@ -551,27 +605,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
551 | } | 605 | } |
552 | set | 606 | set |
553 | { | 607 | { |
608 | if (!CanEdit()) | ||
609 | return; | ||
610 | |||
554 | GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); | 611 | GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); |
555 | } | 612 | } |
556 | } | 613 | } |
557 | 614 | ||
558 | public bool FloatOnWater | 615 | public bool FloatOnWater |
559 | { | 616 | { |
560 | set { GetSOP().PhysActor.FloatOnWater = value; } | 617 | set |
618 | { | ||
619 | if (!CanEdit()) | ||
620 | return; | ||
621 | GetSOP().PhysActor.FloatOnWater = value; | ||
622 | } | ||
561 | } | 623 | } |
562 | 624 | ||
563 | public void AddForce(Vector3 force, bool pushforce) | 625 | public void AddForce(Vector3 force, bool pushforce) |
564 | { | 626 | { |
627 | if (!CanEdit()) | ||
628 | return; | ||
629 | |||
565 | GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); | 630 | GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); |
566 | } | 631 | } |
567 | 632 | ||
568 | public void AddAngularForce(Vector3 force, bool pushforce) | 633 | public void AddAngularForce(Vector3 force, bool pushforce) |
569 | { | 634 | { |
635 | if (!CanEdit()) | ||
636 | return; | ||
637 | |||
570 | GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); | 638 | GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); |
571 | } | 639 | } |
572 | 640 | ||
573 | public void SetMomentum(Vector3 momentum) | 641 | public void SetMomentum(Vector3 momentum) |
574 | { | 642 | { |
643 | if (!CanEdit()) | ||
644 | return; | ||
645 | |||
575 | GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); | 646 | GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); |
576 | } | 647 | } |
577 | 648 | ||
@@ -586,6 +657,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
586 | get { return m_sculptMap; } | 657 | get { return m_sculptMap; } |
587 | set | 658 | set |
588 | { | 659 | { |
660 | if (!CanEdit()) | ||
661 | return; | ||
662 | |||
589 | m_sculptMap = value; | 663 | m_sculptMap = value; |
590 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); | 664 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); |
591 | } | 665 | } |
@@ -598,6 +672,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
598 | get { return m_sculptType; } | 672 | get { return m_sculptType; } |
599 | set | 673 | set |
600 | { | 674 | { |
675 | if (!CanEdit()) | ||
676 | return; | ||
677 | |||
601 | m_sculptType = value; | 678 | m_sculptType = value; |
602 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); | 679 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); |
603 | } | 680 | } |
@@ -654,6 +731,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
654 | 731 | ||
655 | public void Play(UUID asset, double volume) | 732 | public void Play(UUID asset, double volume) |
656 | { | 733 | { |
734 | if (!CanEdit()) | ||
735 | return; | ||
736 | |||
657 | GetSOP().SendSound(asset.ToString(), volume, true, 0); | 737 | GetSOP().SendSound(asset.ToString(), volume, true, 0); |
658 | } | 738 | } |
659 | 739 | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 68f2f52..0cba6af 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs | |||
@@ -91,24 +91,45 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
91 | public bool Bright | 91 | public bool Bright |
92 | { | 92 | { |
93 | get { return GetTexface().Fullbright; } | 93 | get { return GetTexface().Fullbright; } |
94 | set { throw new System.NotImplementedException(); } | 94 | set |
95 | { | ||
96 | Primitive.TextureEntry tex = m_parent.Shape.Textures; | ||
97 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); | ||
98 | texface.Fullbright = value; | ||
99 | tex.FaceTextures[m_face] = texface; | ||
100 | m_parent.UpdateTexture(tex); | ||
101 | } | ||
95 | } | 102 | } |
96 | 103 | ||
97 | public double Bloom | 104 | public double Bloom |
98 | { | 105 | { |
99 | get { return GetTexface().Glow; } | 106 | get { return GetTexface().Glow; } |
100 | set { throw new System.NotImplementedException(); } | 107 | set |
108 | { | ||
109 | Primitive.TextureEntry tex = m_parent.Shape.Textures; | ||
110 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); | ||
111 | texface.Glow = (float) value; | ||
112 | tex.FaceTextures[m_face] = texface; | ||
113 | m_parent.UpdateTexture(tex); | ||
114 | } | ||
101 | } | 115 | } |
102 | 116 | ||
103 | public bool Shiny | 117 | public bool Shiny |
104 | { | 118 | { |
105 | get { return GetTexface().Shiny != Shininess.None; } | 119 | get { return GetTexface().Shiny != Shininess.None; } |
106 | set { throw new System.NotImplementedException(); } | 120 | set |
121 | { | ||
122 | Primitive.TextureEntry tex = m_parent.Shape.Textures; | ||
123 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); | ||
124 | texface.Shiny = value ? Shininess.High : Shininess.None; | ||
125 | tex.FaceTextures[m_face] = texface; | ||
126 | m_parent.UpdateTexture(tex); | ||
127 | } | ||
107 | } | 128 | } |
108 | 129 | ||
109 | public bool BumpMap | 130 | public bool BumpMap |
110 | { | 131 | { |
111 | get { throw new System.NotImplementedException(); } | 132 | get { return GetTexface().Bump == Bumpiness.None; } |
112 | set { throw new System.NotImplementedException(); } | 133 | set { throw new System.NotImplementedException(); } |
113 | } | 134 | } |
114 | } | 135 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index ce2d339..4427426 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | |||
@@ -25,28 +25,26 @@ | |||
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; | ||
29 | using System.Reflection; | ||
30 | using System.Collections; | 28 | using System.Collections; |
31 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
32 | 30 | using System.Security; | |
33 | using OpenMetaverse; | 31 | using OpenMetaverse; |
34 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
36 | 34 | ||
37 | using log4net; | ||
38 | |||
39 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 35 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
40 | { | 36 | { |
41 | class SPAvatar : System.MarshalByRefObject, IAvatar | 37 | class SPAvatar : System.MarshalByRefObject, IAvatar |
42 | { | 38 | { |
43 | private readonly Scene m_rootScene; | 39 | private readonly Scene m_rootScene; |
44 | private readonly UUID m_ID; | 40 | private readonly UUID m_ID; |
41 | private readonly ISecurityCredential m_security; | ||
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 43 | ||
47 | public SPAvatar(Scene scene, UUID ID) | 44 | public SPAvatar(Scene scene, UUID ID, ISecurityCredential security) |
48 | { | 45 | { |
49 | m_rootScene = scene; | 46 | m_rootScene = scene; |
47 | m_security = security; | ||
50 | m_ID = ID; | 48 | m_ID = ID; |
51 | } | 49 | } |
52 | 50 | ||
@@ -58,7 +56,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
58 | public string Name | 56 | public string Name |
59 | { | 57 | { |
60 | get { return GetSP().Name; } | 58 | get { return GetSP().Name; } |
61 | set { throw new InvalidOperationException("Avatar Names are a read-only property."); } | 59 | set { throw new SecurityException("Avatar Names are a read-only property."); } |
62 | } | 60 | } |
63 | 61 | ||
64 | public UUID GlobalID | 62 | public UUID GlobalID |
@@ -84,7 +82,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
84 | foreach (DictionaryEntry element in internalAttachments) | 82 | foreach (DictionaryEntry element in internalAttachments) |
85 | { | 83 | { |
86 | Hashtable attachInfo = (Hashtable)element.Value; | 84 | Hashtable attachInfo = (Hashtable)element.Value; |
87 | attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); | 85 | attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key, |
86 | new UUID((string) attachInfo["item"]), | ||
87 | new UUID((string) attachInfo["asset"]), m_security)); | ||
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 9b684fe..570459a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs | |||
@@ -39,10 +39,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
39 | private readonly int m_location; | 39 | private readonly int m_location; |
40 | //private readonly UUID m_itemId; | 40 | //private readonly UUID m_itemId; |
41 | private readonly UUID m_assetId; | 41 | private readonly UUID m_assetId; |
42 | |||
43 | private readonly ISecurityCredential m_security; | ||
42 | 44 | ||
43 | public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) | 45 | public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId, ISecurityCredential security) |
44 | { | 46 | { |
45 | m_rootScene = rootScene; | 47 | m_rootScene = rootScene; |
48 | m_security = security; | ||
46 | //m_parent = self; | 49 | //m_parent = self; |
47 | m_location = location; | 50 | m_location = location; |
48 | //m_itemId = itemId; | 51 | //m_itemId = itemId; |
@@ -55,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
55 | { | 58 | { |
56 | get | 59 | get |
57 | { | 60 | { |
58 | return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); | 61 | return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId, m_security); |
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs new file mode 100644 index 0000000..bc7f6cb --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | |||
34 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | ||
35 | { | ||
36 | class SecurityCredential : ISecurityCredential | ||
37 | { | ||
38 | private readonly ISocialEntity m_owner; | ||
39 | private readonly Scene m_scene; | ||
40 | |||
41 | public SecurityCredential(ISocialEntity m_owner, Scene m_scene) | ||
42 | { | ||
43 | this.m_owner = m_owner; | ||
44 | this.m_scene = m_scene; | ||
45 | } | ||
46 | |||
47 | public ISocialEntity owner | ||
48 | { | ||
49 | get { return m_owner; } | ||
50 | } | ||
51 | |||
52 | public bool CanEditObject(IObject target) | ||
53 | { | ||
54 | return m_scene.Permissions.CanEditObject(target.GlobalID, m_owner.GlobalID); | ||
55 | } | ||
56 | |||
57 | public bool CanEditTerrain(int x, int y) | ||
58 | { | ||
59 | return m_scene.Permissions.CanTerraformLand(m_owner.GlobalID, new Vector3(x, y, 0)); | ||
60 | } | ||
61 | } | ||
62 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 1ec4a33..da5ea0d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | |||
@@ -37,15 +37,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
37 | public class World : System.MarshalByRefObject, IWorld, IWorldAudio | 37 | public class World : System.MarshalByRefObject, IWorld, IWorldAudio |
38 | { | 38 | { |
39 | private readonly Scene m_internalScene; | 39 | private readonly Scene m_internalScene; |
40 | private readonly ISecurityCredential m_security; | ||
40 | private readonly Heightmap m_heights; | 41 | private readonly Heightmap m_heights; |
41 | 42 | ||
42 | private readonly ObjectAccessor m_objs; | 43 | private readonly ObjectAccessor m_objs; |
43 | 44 | ||
44 | public World(Scene internalScene) | 45 | public World(Scene internalScene, ISecurityCredential securityCredential) |
45 | { | 46 | { |
47 | m_security = securityCredential; | ||
46 | m_internalScene = internalScene; | 48 | m_internalScene = internalScene; |
47 | m_heights = new Heightmap(m_internalScene); | 49 | m_heights = new Heightmap(m_internalScene); |
48 | m_objs = new ObjectAccessor(m_internalScene); | 50 | m_objs = new ObjectAccessor(m_internalScene, securityCredential); |
49 | } | 51 | } |
50 | 52 | ||
51 | #region Events | 53 | #region Events |
@@ -84,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
84 | if (_OnNewUser != null) | 86 | if (_OnNewUser != null) |
85 | { | 87 | { |
86 | NewUserEventArgs e = new NewUserEventArgs(); | 88 | NewUserEventArgs e = new NewUserEventArgs(); |
87 | e.Avatar = new SPAvatar(m_internalScene, presence.UUID); | 89 | e.Avatar = new SPAvatar(m_internalScene, presence.UUID, m_security); |
88 | _OnNewUser(this, e); | 90 | _OnNewUser(this, e); |
89 | } | 91 | } |
90 | } | 92 | } |
@@ -144,7 +146,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
144 | if (chat.Sender == null && chat.SenderObject != null) | 146 | if (chat.Sender == null && chat.SenderObject != null) |
145 | { | 147 | { |
146 | ChatEventArgs e = new ChatEventArgs(); | 148 | ChatEventArgs e = new ChatEventArgs(); |
147 | e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId); | 149 | e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security); |
148 | e.Text = chat.Message; | 150 | e.Text = chat.Message; |
149 | 151 | ||
150 | _OnChat(this, e); | 152 | _OnChat(this, e); |
@@ -154,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
154 | if (chat.Sender != null && chat.SenderObject == null) | 156 | if (chat.Sender != null && chat.SenderObject == null) |
155 | { | 157 | { |
156 | ChatEventArgs e = new ChatEventArgs(); | 158 | ChatEventArgs e = new ChatEventArgs(); |
157 | e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); | 159 | e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security); |
158 | e.Text = chat.Message; | 160 | e.Text = chat.Message; |
159 | 161 | ||
160 | _OnChat(this, e); | 162 | _OnChat(this, e); |
@@ -207,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
207 | for (int i = 0; i < ents.Count; i++) | 209 | for (int i = 0; i < ents.Count; i++) |
208 | { | 210 | { |
209 | EntityBase ent = ents[i]; | 211 | EntityBase ent = ents[i]; |
210 | rets[i] = new SPAvatar(m_internalScene, ent.UUID); | 212 | rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security); |
211 | } | 213 | } |
212 | 214 | ||
213 | return rets; | 215 | return rets; |