diff options
author | Justin Clark-Casey (justincc) | 2010-07-14 23:26:24 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-14 23:26:24 +0100 |
commit | c3ee451325893df8f102c52f05f791289b7c61f6 (patch) | |
tree | 86c2dcb64701126ac02a6661fb40ab1e17007076 /OpenSim/Region | |
parent | implement code to deregister users on DeregisterCaps (diff) | |
download | opensim-SC-c3ee451325893df8f102c52f05f791289b7c61f6.zip opensim-SC-c3ee451325893df8f102c52f05f791289b7c61f6.tar.gz opensim-SC-c3ee451325893df8f102c52f05f791289b7c61f6.tar.bz2 opensim-SC-c3ee451325893df8f102c52f05f791289b7c61f6.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')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 71 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 30 |
2 files changed, 91 insertions, 10 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 |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 3a690af..7f6f851 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
178 | 178 | ||
179 | string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); | 179 | string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); |
180 | 180 | ||
181 | List<string> modules=new List<string>(permissionModules.Split(',')); | 181 | List<string> modules = new List<string>(permissionModules.Split(',')); |
182 | 182 | ||
183 | if (!modules.Contains("DefaultPermissionsModule")) | 183 | if (!modules.Contains("DefaultPermissionsModule")) |
184 | return; | 184 | return; |
@@ -399,6 +399,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
399 | m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work"); | 399 | m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work"); |
400 | 400 | ||
401 | m_moapModule = m_scene.RequestModuleInterface<IMoapModule>(); | 401 | m_moapModule = m_scene.RequestModuleInterface<IMoapModule>(); |
402 | |||
403 | // This log line will be commented out when no longer required for debugging | ||
404 | if (m_moapModule == null) | ||
405 | m_log.Warn("[PERMISSIONS]: Media on a prim module not found, media on a prim permissions will not work"); | ||
402 | } | 406 | } |
403 | 407 | ||
404 | public void Close() | 408 | public void Close() |
@@ -1901,7 +1905,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1901 | } | 1905 | } |
1902 | 1906 | ||
1903 | private bool CanControlPrimMedia(UUID agentID, UUID primID, int face) | 1907 | private bool CanControlPrimMedia(UUID agentID, UUID primID, int face) |
1904 | { | 1908 | { |
1909 | // m_log.DebugFormat( | ||
1910 | // "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}", | ||
1911 | // agentID, primID, face); | ||
1912 | |||
1905 | if (null == m_moapModule) | 1913 | if (null == m_moapModule) |
1906 | return false; | 1914 | return false; |
1907 | 1915 | ||
@@ -1909,17 +1917,25 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1909 | if (null == part) | 1917 | if (null == part) |
1910 | return false; | 1918 | return false; |
1911 | 1919 | ||
1912 | MediaEntry me = m_moapModule.GetMediaEntry(part, face); | 1920 | MediaEntry me = m_moapModule.GetMediaEntry(part, face); |
1913 | 1921 | ||
1914 | // If there is no existing media entry then it can be controlled (in this context, created). | 1922 | // If there is no existing media entry then it can be controlled (in this context, created). |
1915 | if (null == me) | 1923 | if (null == me) |
1916 | return true; | 1924 | return true; |
1917 | 1925 | ||
1926 | m_log.DebugFormat( | ||
1927 | "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", | ||
1928 | agentID, primID, face, me.ControlPermissions); | ||
1929 | |||
1918 | return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); | 1930 | return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); |
1919 | } | 1931 | } |
1920 | 1932 | ||
1921 | private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) | 1933 | private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) |
1922 | { | 1934 | { |
1935 | // m_log.DebugFormat( | ||
1936 | // "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}", | ||
1937 | // agentID, primID, face); | ||
1938 | |||
1923 | if (null == m_moapModule) | 1939 | if (null == m_moapModule) |
1924 | return false; | 1940 | return false; |
1925 | 1941 | ||
@@ -1933,13 +1949,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1933 | if (null == me) | 1949 | if (null == me) |
1934 | return true; | 1950 | return true; |
1935 | 1951 | ||
1952 | m_log.DebugFormat( | ||
1953 | "[PERMISSIONS]: Checking CanInteractWithPrimMedia for {0} on {1} face {2} with interact permissions {3}", | ||
1954 | agentID, primID, face, me.InteractPermissions); | ||
1955 | |||
1936 | return GenericPrimMediaPermission(part, agentID, me.InteractPermissions); | 1956 | return GenericPrimMediaPermission(part, agentID, me.InteractPermissions); |
1937 | } | 1957 | } |
1938 | 1958 | ||
1939 | private bool GenericPrimMediaPermission(SceneObjectPart part, UUID agentID, MediaPermission perms) | 1959 | private bool GenericPrimMediaPermission(SceneObjectPart part, UUID agentID, MediaPermission perms) |
1940 | { | 1960 | { |
1941 | if (IsAdministrator(agentID)) | 1961 | // if (IsAdministrator(agentID)) |
1942 | return true; | 1962 | // return true; |
1943 | 1963 | ||
1944 | if ((perms & MediaPermission.Anyone) == MediaPermission.Anyone) | 1964 | if ((perms & MediaPermission.Anyone) == MediaPermission.Anyone) |
1945 | return true; | 1965 | return true; |