aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2011-01-27 02:29:10 +0100
committerMelanie2011-01-27 02:29:10 +0100
commit3321f9d745ea782667b664365f23be75a2b047f5 (patch)
treeccb46a08ca26868049d269ecd68eac5bd94867da /OpenSim
parentMake bans work for teleport. Now teleport will complete block if the user (diff)
parentMostly revert the last commit with the aim of searching for a better solution (diff)
downloadopensim-SC-3321f9d745ea782667b664365f23be75a2b047f5.zip
opensim-SC-3321f9d745ea782667b664365f23be75a2b047f5.tar.gz
opensim-SC-3321f9d745ea782667b664365f23be75a2b047f5.tar.bz2
opensim-SC-3321f9d745ea782667b664365f23be75a2b047f5.tar.xz
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/EstateSettings.cs23
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs6
-rw-r--r--OpenSim/Framework/Util.cs26
-rw-r--r--OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs42
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs4
7 files changed, 93 insertions, 19 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
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index c023a6f..5c5cb70 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -88,7 +88,8 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
88 88
89 public void AddCapsHandler(UUID agentId) 89 public void AddCapsHandler(UUID agentId)
90 { 90 {
91 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 91 int flags = m_scene.GetUserFlags(agentId);
92 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
92 return; 93 return;
93 94
94 String capsObjectPath = GetCapsPath(agentId); 95 String capsObjectPath = GetCapsPath(agentId);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fc4110b..6a5f84a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2443,7 +2443,8 @@ namespace OpenSim.Region.Framework.Scenes
2443 // If the user is banned, we won't let any of their objects 2443 // If the user is banned, we won't let any of their objects
2444 // enter. Period. 2444 // enter. Period.
2445 // 2445 //
2446 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2446 int flags = GetUserFlags(sceneObject.OwnerID);
2447 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2447 { 2448 {
2448 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2449 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2449 "banned avatar"); 2450 "banned avatar");
@@ -2547,6 +2548,22 @@ namespace OpenSim.Region.Framework.Scenes
2547 return 2; // StateSource.PrimCrossing 2548 return 2; // StateSource.PrimCrossing
2548 } 2549 }
2549 2550
2551 public int GetUserFlags(UUID user)
2552 {
2553 //Unfortunately the SP approach means that the value is cached until region is restarted
2554 /*
2555 ScenePresence sp;
2556 if (TryGetScenePresence(user, out sp))
2557 {
2558 return sp.UserFlags;
2559 }
2560 else
2561 {
2562 */
2563 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2564 return uac.UserFlags;
2565 //}
2566 }
2550 #endregion 2567 #endregion
2551 2568
2552 #region Add/Remove Avatar Methods 2569 #region Add/Remove Avatar Methods
@@ -3626,10 +3643,26 @@ namespace OpenSim.Region.Framework.Scenes
3626 3643
3627 if (m_regInfo.EstateSettings != null) 3644 if (m_regInfo.EstateSettings != null)
3628 { 3645 {
3629 if (m_regInfo.EstateSettings.IsBanned(agentID)) 3646 int flags = GetUserFlags(agent.AgentID);
3647 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3630 { 3648 {
3631 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the banlist", 3649 //Add some more info to help users
3650 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3651 {
3652 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3632 agentID, RegionInfo.RegionName); 3653 agentID, RegionInfo.RegionName);
3654 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3655 return false;
3656 }
3657 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3658 {
3659 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3660 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3661 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3662 return false;
3663 }
3664 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3665 agent.AgentID, RegionInfo.RegionName);
3633 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3666 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3634 RegionInfo.RegionName); 3667 RegionInfo.RegionName);
3635 return false; 3668 return false;
@@ -3788,7 +3821,8 @@ namespace OpenSim.Region.Framework.Scenes
3788 3821
3789 // We have to wait until the viewer contacts this region after receiving EAC. 3822 // We have to wait until the viewer contacts this region after receiving EAC.
3790 // That calls AddNewClient, which finally creates the ScenePresence 3823 // That calls AddNewClient, which finally creates the ScenePresence
3791 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID)) 3824 int flags = GetUserFlags(cAgentData.AgentID);
3825 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3792 { 3826 {
3793 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); 3827 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3794 return false; 3828 return false;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6a3983f..c4ae0f0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -113,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes
113 { 113 {
114 get { return m_attachments; } 114 get { return m_attachments; }
115 } 115 }
116
116 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); 117 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
117 118
118 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); 119 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
@@ -136,6 +137,12 @@ namespace OpenSim.Region.Framework.Scenes
136 private bool m_updateflag; 137 private bool m_updateflag;
137 private byte m_movementflag; 138 private byte m_movementflag;
138 private Vector3? m_forceToApply; 139 private Vector3? m_forceToApply;
140 private int m_userFlags;
141 public int UserFlags
142 {
143 get { return m_userFlags; }
144 }
145
139 private uint m_requestedSitTargetID; 146 private uint m_requestedSitTargetID;
140 private UUID m_requestedSitTargetUUID; 147 private UUID m_requestedSitTargetUUID;
141 public bool SitGround = false; 148 public bool SitGround = false;
@@ -763,6 +770,7 @@ namespace OpenSim.Region.Framework.Scenes
763 m_localId = m_scene.AllocateLocalId(); 770 m_localId = m_scene.AllocateLocalId();
764 771
765 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); 772 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
773 m_userFlags = account.UserFlags;
766 774
767 if (account != null) 775 if (account != null)
768 m_userLevel = account.UserLevel; 776 m_userLevel = account.UserLevel;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dffc0bd..f5b7f5f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6938,13 +6938,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6938 public LSL_String llMD5String(string src, int nonce) 6938 public LSL_String llMD5String(string src, int nonce)
6939 { 6939 {
6940 m_host.AddScriptLPS(1); 6940 m_host.AddScriptLPS(1);
6941 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); 6941 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8);
6942 } 6942 }
6943 6943
6944 public LSL_String llSHA1String(string src) 6944 public LSL_String llSHA1String(string src)
6945 { 6945 {
6946 m_host.AddScriptLPS(1); 6946 m_host.AddScriptLPS(1);
6947 return Util.SHA1Hash(src).ToLower(); 6947 return Util.SHA1Hash(src, Encoding.UTF8).ToLower();
6948 } 6948 }
6949 6949
6950 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6950 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)