diff options
author | Justin Clark-Casey (justincc) | 2010-07-14 23:26:24 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-26 23:34:21 +0100 |
commit | 049ccba8d3b71583f9f1aa7d13ca4a7f60501871 (patch) | |
tree | 1a1165bd9b6d38faf6b7a7b163f833fdac5ef477 /OpenSim/Region/CoreModules/World/Media/Moap | |
parent | implement code to deregister users on DeregisterCaps (diff) | |
download | opensim-SC_OLD-049ccba8d3b71583f9f1aa7d13ca4a7f60501871.zip opensim-SC_OLD-049ccba8d3b71583f9f1aa7d13ca4a7f60501871.tar.gz opensim-SC_OLD-049ccba8d3b71583f9f1aa7d13ca4a7f60501871.tar.bz2 opensim-SC_OLD-049ccba8d3b71583f9f1aa7d13ca4a7f60501871.tar.xz |
fix previous media interact serverside checking. perform very basic serverside url whitelist checks
at the moment, only checking for the exact name prefix is implemented
for some reason, whitelists are not persisting
this commit also fixes a very recent problem where setting any media texture parameters after the initial configuration would not work
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Media/Moap')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index ce4e921..3c546c4 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | |||
@@ -91,6 +91,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
91 | public void AddRegion(Scene scene) | 91 | public void AddRegion(Scene scene) |
92 | { | 92 | { |
93 | m_scene = scene; | 93 | m_scene = scene; |
94 | m_scene.RegisterModuleInterface<IMoapModule>(this); | ||
94 | } | 95 | } |
95 | 96 | ||
96 | public void RemoveRegion(Scene scene) {} | 97 | public void RemoveRegion(Scene scene) {} |
@@ -156,20 +157,28 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
156 | 157 | ||
157 | public MediaEntry GetMediaEntry(SceneObjectPart part, int face) | 158 | public MediaEntry GetMediaEntry(SceneObjectPart part, int face) |
158 | { | 159 | { |
160 | MediaEntry me = null; | ||
161 | |||
159 | CheckFaceParam(part, face); | 162 | CheckFaceParam(part, face); |
160 | 163 | ||
161 | List<MediaEntry> media = part.Shape.Media; | 164 | List<MediaEntry> media = part.Shape.Media; |
162 | 165 | ||
163 | if (null == media) | 166 | if (null == media) |
164 | { | 167 | { |
165 | return null; | 168 | me = null; |
166 | } | 169 | } |
167 | else | 170 | else |
168 | { | 171 | { |
172 | me = media[face]; | ||
173 | |||
169 | // TODO: Really need a proper copy constructor down in libopenmetaverse | 174 | // TODO: Really need a proper copy constructor down in libopenmetaverse |
170 | MediaEntry me = media[face]; | 175 | if (me != null) |
171 | return (null == me ? null : MediaEntry.FromOSD(me.GetOSD())); | 176 | me = MediaEntry.FromOSD(me.GetOSD()); |
172 | } | 177 | } |
178 | |||
179 | // m_log.DebugFormat("[MOAP]: GetMediaEntry for {0} face {1} found {2}", part.Name, face, me); | ||
180 | |||
181 | return me; | ||
173 | } | 182 | } |
174 | 183 | ||
175 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) | 184 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) |
@@ -295,6 +304,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
295 | 304 | ||
296 | if (null == media) | 305 | if (null == media) |
297 | { | 306 | { |
307 | m_log.DebugFormat("[MOAP]: Setting all new media list for {0}", part.Name); | ||
298 | part.Shape.Media = new List<MediaEntry>(omu.FaceMedia); | 308 | part.Shape.Media = new List<MediaEntry>(omu.FaceMedia); |
299 | } | 309 | } |
300 | else | 310 | else |
@@ -309,7 +319,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
309 | for (int i = 0; i < media.Count; i++) | 319 | for (int i = 0; i < media.Count; i++) |
310 | { | 320 | { |
311 | if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i)) | 321 | if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i)) |
322 | { | ||
312 | media[i] = omu.FaceMedia[i]; | 323 | media[i] = omu.FaceMedia[i]; |
324 | // m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name); | ||
325 | } | ||
313 | } | 326 | } |
314 | } | 327 | } |
315 | 328 | ||
@@ -362,10 +375,31 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
362 | return string.Empty; | 375 | return string.Empty; |
363 | 376 | ||
364 | m_log.DebugFormat( | 377 | m_log.DebugFormat( |
365 | "[MOAP]: Updating media entry for face {0} on prim {1} {2} to {3}", | 378 | "[MOAP]: Received request to update media entry for face {0} on prim {1} {2} to {3}", |
366 | omn.Face, part.Name, part.UUID, omn.URL); | 379 | omn.Face, part.Name, part.UUID, omn.URL); |
367 | 380 | ||
381 | // If media has never been set for this prim, then just return. | ||
382 | if (null == part.Shape.Media) | ||
383 | return string.Empty; | ||
384 | |||
368 | MediaEntry me = part.Shape.Media[omn.Face]; | 385 | MediaEntry me = part.Shape.Media[omn.Face]; |
386 | |||
387 | // Do the same if media has not been set up for a specific face | ||
388 | if (null == me) | ||
389 | return string.Empty; | ||
390 | |||
391 | if (me.EnableWhiteList) | ||
392 | { | ||
393 | if (!CheckUrlAgainstWhitelist(omn.URL, me.WhiteList)) | ||
394 | { | ||
395 | m_log.DebugFormat( | ||
396 | "[MOAP]: Blocking change of face {0} on prim {1} {2} to {3} since it's not on the enabled whitelist", | ||
397 | omn.Face, part.Name, part.UUID, omn.URL); | ||
398 | |||
399 | return string.Empty; | ||
400 | } | ||
401 | } | ||
402 | |||
369 | me.CurrentURL = omn.URL; | 403 | me.CurrentURL = omn.URL; |
370 | 404 | ||
371 | UpdateMediaUrl(part); | 405 | UpdateMediaUrl(part); |
@@ -413,5 +447,32 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
413 | 447 | ||
414 | m_log.DebugFormat("[MOAP]: Storing media url [{0}] in prim {1} {2}", part.MediaUrl, part.Name, part.UUID); | 448 | m_log.DebugFormat("[MOAP]: Storing media url [{0}] in prim {1} {2}", part.MediaUrl, part.Name, part.UUID); |
415 | } | 449 | } |
450 | |||
451 | /// <summary> | ||
452 | /// Check the given url against the given whitelist. | ||
453 | /// </summary> | ||
454 | /// <param name="url"></param> | ||
455 | /// <param name="whitelist"></param> | ||
456 | /// <returns>true if the url matches an entry on the whitelist, false otherwise</returns> | ||
457 | protected bool CheckUrlAgainstWhitelist(string url, string[] whitelist) | ||
458 | { | ||
459 | foreach (string rawWlUrl in whitelist) | ||
460 | { | ||
461 | string wlUrl = rawWlUrl; | ||
462 | |||
463 | if (!wlUrl.StartsWith("http://")) | ||
464 | wlUrl = "http://" + wlUrl; | ||
465 | |||
466 | m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl); | ||
467 | |||
468 | if (url.StartsWith(wlUrl)) | ||
469 | { | ||
470 | m_log.DebugFormat("[MOAP]: Whitelist url {0} matches requested url {1}", wlUrl, url); | ||
471 | return true; | ||
472 | } | ||
473 | } | ||
474 | |||
475 | return false; | ||
476 | } | ||
416 | } | 477 | } |
417 | } \ No newline at end of file | 478 | } \ No newline at end of file |