diff options
3 files changed, 45 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index cac8479..3ec1bda 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -53,6 +53,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
53 | bool IsNPC(UUID agentID, Scene scene); | 53 | bool IsNPC(UUID agentID, Scene scene); |
54 | 54 | ||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Check if the caller has permission to manipulate the given NPC. | ||
57 | /// </summary> | ||
58 | /// <param name="npcID"></param> | ||
59 | /// <param name="callerID"></param> | ||
60 | /// <returns>true if they do, false if they don't or if there's no NPC with the given ID.</returns> | ||
61 | bool CheckPermissions(UUID npcID, UUID callerID); | ||
62 | |||
63 | /// <summary> | ||
56 | /// Set the appearance for an NPC. | 64 | /// Set the appearance for an NPC. |
57 | /// </summary> | 65 | /// </summary> |
58 | /// <param name="agentID"></param> | 66 | /// <param name="agentID"></param> |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index e874417..8f9b513 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | public void PostInitialise() | ||
60 | { | ||
61 | } | ||
62 | |||
63 | public void Close() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public string Name | ||
68 | { | ||
69 | get { return "NPCModule"; } | ||
70 | } | ||
71 | |||
72 | public bool IsSharedModule | ||
73 | { | ||
74 | get { return true; } | ||
75 | } | ||
76 | |||
59 | public bool IsNPC(UUID agentId, Scene scene) | 77 | public bool IsNPC(UUID agentId, Scene scene) |
60 | { | 78 | { |
61 | // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect | 79 | // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect |
@@ -255,7 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
255 | NPCAvatar av; | 273 | NPCAvatar av; |
256 | if (m_avatars.TryGetValue(agentID, out av)) | 274 | if (m_avatars.TryGetValue(agentID, out av)) |
257 | { | 275 | { |
258 | if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID) | 276 | if (!CheckPermissions(av, callerID)); |
259 | return false; | 277 | return false; |
260 | 278 | ||
261 | scene.RemoveClient(agentID, false); | 279 | scene.RemoveClient(agentID, false); |
@@ -268,22 +286,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
268 | return false; | 286 | return false; |
269 | } | 287 | } |
270 | 288 | ||
271 | public void PostInitialise() | 289 | public bool CheckPermissions(UUID npcID, UUID callerID) |
272 | { | ||
273 | } | ||
274 | |||
275 | public void Close() | ||
276 | { | ||
277 | } | ||
278 | |||
279 | public string Name | ||
280 | { | 290 | { |
281 | get { return "NPCModule"; } | 291 | lock (m_avatars) |
292 | { | ||
293 | NPCAvatar av; | ||
294 | if (m_avatars.TryGetValue(npcID, out av)) | ||
295 | return CheckPermissions(av, callerID); | ||
296 | else | ||
297 | return false; | ||
298 | } | ||
282 | } | 299 | } |
283 | 300 | ||
284 | public bool IsSharedModule | 301 | /// <summary> |
302 | /// Check if the caller has permission to manipulate the given NPC. | ||
303 | /// </summary> | ||
304 | /// <param name="av"></param> | ||
305 | /// <param name="callerID"></param> | ||
306 | /// <returns>true if they do, false if they don't.</returns> | ||
307 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | ||
285 | { | 308 | { |
286 | get { return true; } | 309 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; |
287 | } | 310 | } |
288 | } | 311 | } |
289 | } | 312 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e2a045b..1d7a210 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2152,11 +2152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2152 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2152 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2153 | return new LSL_Key(UUID.Zero.ToString()); | 2153 | return new LSL_Key(UUID.Zero.ToString()); |
2154 | 2154 | ||
2155 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | 2155 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2156 | return new LSL_Key(UUID.Zero.ToString()); | ||
2157 | |||
2158 | UUID ownerID = npcModule.GetOwner(npcId); | ||
2159 | if (ownerID != UUID.Zero && ownerID != m_host.OwnerID) | ||
2160 | return new LSL_Key(UUID.Zero.ToString()); | 2156 | return new LSL_Key(UUID.Zero.ToString()); |
2161 | 2157 | ||
2162 | return SaveAppearanceToNotecard(npcId, notecard); | 2158 | return SaveAppearanceToNotecard(npcId, notecard); |