diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/EstateSettings.cs | 23 | ||||
-rw-r--r-- | OpenSim/Framework/Tests/MundaneFrameworkTests.cs | 6 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 26 |
3 files changed, 43 insertions, 12 deletions
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 2a495b0..f9c13f3 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -338,11 +338,30 @@ namespace OpenSim.Framework | |||
338 | return false; | 338 | return false; |
339 | } | 339 | } |
340 | 340 | ||
341 | public bool IsBanned(UUID avatarID) | 341 | public bool IsBanned(UUID avatarID, int userFlags) |
342 | { | 342 | { |
343 | foreach (EstateBan ban in l_EstateBans) | 343 | foreach (EstateBan ban in l_EstateBans) |
344 | if (ban.BannedUserID == avatarID) | 344 | if (ban.BannedUserID == avatarID) |
345 | return true; | 345 | return true; |
346 | |||
347 | if (!IsEstateManager(avatarID) && !HasAccess(avatarID)) | ||
348 | { | ||
349 | if (DenyMinors) | ||
350 | { | ||
351 | if ((userFlags & 32) == 0) | ||
352 | { | ||
353 | return true; | ||
354 | } | ||
355 | } | ||
356 | if (DenyAnonymous) | ||
357 | { | ||
358 | if ((userFlags & 4) == 0) | ||
359 | { | ||
360 | return true; | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | |||
346 | return false; | 365 | return false; |
347 | } | 366 | } |
348 | 367 | ||
@@ -350,7 +369,7 @@ namespace OpenSim.Framework | |||
350 | { | 369 | { |
351 | if (ban == null) | 370 | if (ban == null) |
352 | return; | 371 | return; |
353 | if (!IsBanned(ban.BannedUserID)) | 372 | if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans |
354 | l_EstateBans.Add(ban); | 373 | l_EstateBans.Add(ban); |
355 | } | 374 | } |
356 | 375 | ||
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index e7f8bfc..e131260 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -217,12 +217,12 @@ namespace OpenSim.Framework.Tests | |||
217 | BannedHostNameMask = string.Empty, | 217 | BannedHostNameMask = string.Empty, |
218 | BannedUserID = bannedUserId} | 218 | BannedUserID = bannedUserId} |
219 | ); | 219 | ); |
220 | Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not."); | 220 | Assert.IsTrue(es.IsBanned(bannedUserId, 32), "User Should be banned but is not."); |
221 | Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is."); | 221 | Assert.IsFalse(es.IsBanned(UUID.Zero, 32), "User Should not be banned but is."); |
222 | 222 | ||
223 | es.RemoveBan(bannedUserId); | 223 | es.RemoveBan(bannedUserId); |
224 | 224 | ||
225 | Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is."); | 225 | Assert.IsFalse(es.IsBanned(bannedUserId, 32), "User Should not be banned but is."); |
226 | 226 | ||
227 | es.AddEstateManager(UUID.Zero); | 227 | es.AddEstateManager(UUID.Zero); |
228 | 228 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index cef756c..96292ff 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -409,19 +409,25 @@ namespace OpenSim.Framework | |||
409 | /// </summary> | 409 | /// </summary> |
410 | /// <param name="data"></param> | 410 | /// <param name="data"></param> |
411 | /// <returns></returns> | 411 | /// <returns></returns> |
412 | |||
412 | public static string Md5Hash(string data) | 413 | public static string Md5Hash(string data) |
413 | { | 414 | { |
414 | byte[] dataMd5 = ComputeMD5Hash(data); | 415 | return Md5Hash(data, Encoding.Default); |
416 | } | ||
417 | |||
418 | public static string Md5Hash(string data, Encoding encoding) | ||
419 | { | ||
420 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
415 | StringBuilder sb = new StringBuilder(); | 421 | StringBuilder sb = new StringBuilder(); |
416 | for (int i = 0; i < dataMd5.Length; i++) | 422 | for (int i = 0; i < dataMd5.Length; i++) |
417 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 423 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
418 | return sb.ToString(); | 424 | return sb.ToString(); |
419 | } | 425 | } |
420 | 426 | ||
421 | private static byte[] ComputeMD5Hash(string data) | 427 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
422 | { | 428 | { |
423 | MD5 md5 = MD5.Create(); | 429 | MD5 md5 = MD5.Create(); |
424 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 430 | return md5.ComputeHash(encoding.GetBytes(data)); |
425 | } | 431 | } |
426 | 432 | ||
427 | /// <summary> | 433 | /// <summary> |
@@ -429,16 +435,22 @@ namespace OpenSim.Framework | |||
429 | /// </summary> | 435 | /// </summary> |
430 | /// <param name="data"></param> | 436 | /// <param name="data"></param> |
431 | /// <returns></returns> | 437 | /// <returns></returns> |
438 | |||
432 | public static string SHA1Hash(string data) | 439 | public static string SHA1Hash(string data) |
433 | { | 440 | { |
434 | byte[] hash = ComputeSHA1Hash(data); | 441 | return SHA1Hash(data, Encoding.Default); |
442 | } | ||
443 | |||
444 | public static string SHA1Hash(string data, Encoding encoding) | ||
445 | { | ||
446 | byte[] hash = ComputeSHA1Hash(data, encoding); | ||
435 | return BitConverter.ToString(hash).Replace("-", String.Empty); | 447 | return BitConverter.ToString(hash).Replace("-", String.Empty); |
436 | } | 448 | } |
437 | 449 | ||
438 | private static byte[] ComputeSHA1Hash(string src) | 450 | private static byte[] ComputeSHA1Hash(string src, Encoding encoding) |
439 | { | 451 | { |
440 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); | 452 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); |
441 | return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); | 453 | return SHA1.ComputeHash(encoding.GetBytes(src)); |
442 | } | 454 | } |
443 | 455 | ||
444 | public static int fast_distance2d(int x, int y) | 456 | public static int fast_distance2d(int x, int y) |
@@ -1161,7 +1173,7 @@ namespace OpenSim.Framework | |||
1161 | 1173 | ||
1162 | public static Guid GetHashGuid(string data, string salt) | 1174 | public static Guid GetHashGuid(string data, string salt) |
1163 | { | 1175 | { |
1164 | byte[] hash = ComputeMD5Hash(data + salt); | 1176 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1165 | 1177 | ||
1166 | //string s = BitConverter.ToString(hash); | 1178 | //string s = BitConverter.ToString(hash); |
1167 | 1179 | ||