aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authoronefang2020-09-11 00:41:12 +1000
committeronefang2020-09-11 00:41:12 +1000
commitb95b03b409578da87f1dbaf809001e88e4e4fd56 (patch)
tree1db95cf20313408ef581377ae8e508d6d01cea00 /OpenSim/Region
parentAdd DefaultRegionAccess in [AuthorizationService] section. (diff)
downloadopensim-SC-b95b03b409578da87f1dbaf809001e88e4e4fd56.zip
opensim-SC-b95b03b409578da87f1dbaf809001e88e4e4fd56.tar.gz
opensim-SC-b95b03b409578da87f1dbaf809001e88e4e4fd56.tar.bz2
opensim-SC-b95b03b409578da87f1dbaf809001e88e4e4fd56.tar.xz
Automatically add members to certain groups, and HGers from specific grids to certain other groups.
It doesn't let them know, though the last group added will be their active group. This replaces a PHP script I used to use, that got broken by a PHP update. It also didn't let people know, no one complained. This is better. Another attempt at sorting out the auto group chicken and egg problems. Are you a local? Asking for a friend. Hypergridders have their full name in firstname, and their grid in lastname. Sometimes. Code filled with gotos may be spaghetti code, but object oriented code can be like chopped spaghetti that's hidden all over the kitchen. At least with gotos you can follow them.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs11
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs7
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs6
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs131
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs7
6 files changed, 150 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
index 2e06bc8..91e0ebc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
@@ -88,8 +88,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
88 } 88 }
89 89
90 public bool IsAuthorizedForRegion( 90 public bool IsAuthorizedForRegion(
91 string user, string firstName, string lastName, string regionID, out string message) 91 string user, string firstName, string lastName, string regionID, out string message, out bool isLocal)
92 { 92 {
93 UUID userID = new UUID(user);
94 isLocal = m_UserManagement.IsLocalGridUser(userID);
95
93 // This should not happen 96 // This should not happen
94 if (m_Scene.RegionInfo.RegionID.ToString() != regionID) 97 if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
95 { 98 {
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
105 return true; 108 return true;
106 } 109 }
107 110
108 UUID userID = new UUID(user); 111//// UUID userID = new UUID(user);
109 112
110 if ((m_accessValue & AccessFlags.DisallowForeigners) != 0) 113 if ((m_accessValue & AccessFlags.DisallowForeigners) != 0)
111 { 114 {
112 if (!m_UserManagement.IsLocalGridUser(userID)) 115 if (!isLocal)
113 { 116 {
114 message = "No foreign users allowed in this region"; 117 message = "No foreign users allowed in this region";
115 return false; 118 return false;
@@ -130,4 +133,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
130 } 133 }
131 134
132 } 135 }
133} \ No newline at end of file 136}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
index 0be0676..59ffc1d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
@@ -114,13 +114,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
114 } 114 }
115 115
116 public bool IsAuthorizedForRegion( 116 public bool IsAuthorizedForRegion(
117 string userID, string firstName, string lastName, string regionID, out string message) 117 string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal)
118 { 118 {
119 message = ""; 119 message = "";
120 isLocal = false;
120 if (!m_Enabled) 121 if (!m_Enabled)
121 return true; 122 return true;
122 123
123 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); 124 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message, out isLocal);
124 } 125 }
125 } 126 }
126} \ No newline at end of file 127}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index f312b0d..f06180a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -120,7 +120,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
120 } 120 }
121 121
122 public bool IsAuthorizedForRegion( 122 public bool IsAuthorizedForRegion(
123 string userID, string firstName, string lastName, string regionID, out string message) 123 string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal)
124 { 124 {
125 m_log.InfoFormat( 125 m_log.InfoFormat(
126 "[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); 126 "[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID);
@@ -141,6 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
141 } 141 }
142 } 142 }
143 143
144 isLocal = false;
144 if (scene != null) 145 if (scene != null)
145 { 146 {
146 string mail = String.Empty; 147 string mail = String.Empty;
@@ -153,6 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
153 mail = account.Email; 154 mail = account.Email;
154 firstName = account.FirstName; 155 firstName = account.FirstName;
155 lastName = account.LastName; 156 lastName = account.LastName;
157 isLocal = true;
156 } 158 }
157 159
158 isAuthorized 160 isAuthorized
@@ -169,4 +171,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
169 return isAuthorized; 171 return isAuthorized;
170 } 172 }
171 } 173 }
172} \ No newline at end of file 174}
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
index 0d1f4f4..c7e29bd 100644
--- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
@@ -92,6 +92,7 @@ namespace OpenSim.Region.Framework.Interfaces
92 GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog); 92 GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog);
93 void SendAgentGroupDataUpdate(IClientAPI remoteClient); 93 void SendAgentGroupDataUpdate(IClientAPI remoteClient);
94 void JoinGroupRequest(IClientAPI remoteClient, UUID GroupID); 94 void JoinGroupRequest(IClientAPI remoteClient, UUID GroupID);
95 void JoinGroup(string agentID, UUID GroupID);
95 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID); 96 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID);
96 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID); 97 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID);
97 void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID GroupID, UUID EjecteeID); 98 void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID GroupID, UUID EjecteeID);
@@ -101,4 +102,4 @@ namespace OpenSim.Region.Framework.Interfaces
101 102
102 List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query); 103 List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query);
103 } 104 }
104} \ No newline at end of file 105}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5f1497a..eee288a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -338,6 +338,9 @@ namespace OpenSim.Region.Framework.Scenes
338 protected ICapabilitiesModule m_capsModule; 338 protected ICapabilitiesModule m_capsModule;
339 protected IGroupsModule m_groupsModule; 339 protected IGroupsModule m_groupsModule;
340 340
341 // The lists of groups to automatically add to logging in users.
342 private Dictionary<string, string[]> m_AutoGroups;
343
341 private Dictionary<string, string> m_extraSettings; 344 private Dictionary<string, string> m_extraSettings;
342 345
343 /// <summary> 346 /// <summary>
@@ -1156,6 +1159,50 @@ namespace OpenSim.Region.Framework.Scenes
1156 1159
1157 #endregion Interest Management 1160 #endregion Interest Management
1158 1161
1162 #region Group
1163
1164 IConfig groupsConfig = m_config.Configs["Groups"];
1165 m_AutoGroups = new Dictionary<string, string[]>();
1166 if (groupsConfig != null)
1167 {
1168 string groups = groupsConfig.GetString("AddDefaultGroup", string.Empty);
1169 if (groups.Length > 0)
1170 {
1171 try
1172 {
1173 m_AutoGroups.Add("local", groups.Split('|'));
1174 }
1175 catch (ArgumentException)
1176 {
1177 m_log.Warn("[SCENE]: Duplicated AddDefaultGroup option.");
1178 }
1179 }
1180 string[] keys = groupsConfig.GetKeys();
1181 if (0 < keys.Length)
1182 {
1183 foreach (string k in keys)
1184 {
1185 if (k.StartsWith("AddHGDefaultGroup_"))
1186 {
1187 groups = groupsConfig.GetString(k, string.Empty);
1188 if (groups.Length > 0)
1189 {
1190 try
1191 {
1192 m_AutoGroups.Add(k.Substring(18), groups.Split('|'));
1193 }
1194 catch (ArgumentException)
1195 {
1196 m_log.WarnFormat("[SCENE]: Duplicated {0} option.", k);
1197 }
1198 }
1199 }
1200 }
1201 }
1202 }
1203
1204 #endregion Group
1205
1159 StatsReporter = new SimStatsReporter(this); 1206 StatsReporter = new SimStatsReporter(this);
1160 1207
1161 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1208 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
@@ -4333,6 +4380,7 @@ namespace OpenSim.Region.Framework.Scenes
4333 protected virtual bool AuthorizeUser(AgentCircuitData agent, bool bypassAccessControl, out string reason) 4380 protected virtual bool AuthorizeUser(AgentCircuitData agent, bool bypassAccessControl, out string reason)
4334 { 4381 {
4335 reason = String.Empty; 4382 reason = String.Empty;
4383 bool isLocal = false;
4336 4384
4337 if (!m_strictAccessControl) 4385 if (!m_strictAccessControl)
4338 return true; 4386 return true;
@@ -4342,7 +4390,7 @@ namespace OpenSim.Region.Framework.Scenes
4342 if (AuthorizationService != null) 4390 if (AuthorizationService != null)
4343 { 4391 {
4344 if (!AuthorizationService.IsAuthorizedForRegion( 4392 if (!AuthorizationService.IsAuthorizedForRegion(
4345 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) 4393 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason, out isLocal))
4346 { 4394 {
4347 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}", 4395 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}",
4348 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason); 4396 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
@@ -4375,6 +4423,79 @@ namespace OpenSim.Region.Framework.Scenes
4375 return false; 4423 return false;
4376 } 4424 }
4377 4425
4426 List<UUID> agentGroups = new List<UUID>();
4427 GroupMembershipData[] GroupMembership = null;
4428 if(m_groupsModule != null)
4429 GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID);
4430
4431 if (null != GroupMembership)
4432 {
4433 for(int i = 0;i < GroupMembership.Length;i++)
4434 agentGroups.Add(GroupMembership[i].GroupID);
4435 // We get called twice, the first time the name is set to a single space.
4436 // The first time is from QueryAccess(), the second from NewUserConnection()
4437// if (" " != agent.Name)
4438 {
4439 string grid = "";
4440 if (isLocal)
4441 {
4442 grid = "local";
4443 m_log.InfoFormat("[CONNECTION BEGIN]: LOCAL agent {0} {1} {2} {3}, checking auto groups.", agent.firstname, agent.lastname, agent.Name, agent.AgentID);
4444 }
4445 else
4446 {
4447 // agent.AgentID could look like this - @grid.com:8002 01234567-89ab-cdef-0123-456789abcdef
4448 // Or agent.lastname could.
4449 string a = agent.AgentID.ToString();
4450 if ("@" == a.Substring(0, 1))
4451 {
4452 grid = a.Split(':')[0].Substring(1);
4453 m_log.InfoFormat("[CONNECTION BEGIN]: HYPERGRID agent {0} from grid {1}, checking auto groups.", agent.AgentID, grid);
4454 }
4455 else
4456 {
4457 a = agent.lastname;
4458 if (String.Empty != a)
4459 {
4460 if ("@" == a.Substring(0, 1))
4461 {
4462 grid = a.Split(':')[0].Substring(1);
4463 m_log.InfoFormat("[CONNECTION BEGIN]: HYPERGRID agent {0} from grid {1}, checking auto groups.", agent.firstname, grid);
4464 }
4465 }
4466 }
4467 }
4468 string[] groupIDs = null;
4469 try
4470 {
4471 groupIDs = m_AutoGroups[grid];
4472 }
4473 catch (KeyNotFoundException)
4474 {
4475 // Do nothing.
4476 }
4477 if (null != groupIDs)
4478 {
4479 foreach(string name in groupIDs)
4480 {
4481 GroupRecord g = m_groupsModule.GetGroupRecord(name);
4482 if (null != g)
4483 {
4484 UUID group = g.GroupID;
4485 if(!agentGroups.Contains(group))
4486 {
4487 m_groupsModule.JoinGroup(agent.AgentID.ToString(), group);
4488 agentGroups.Add(group);
4489 m_log.InfoFormat("[CONNECTION BEGIN]: Automatically added {0} to group {1}.", agent.AgentID, name);
4490 }
4491 }
4492 else
4493 m_log.ErrorFormat("[CONNECTION BEGIN]: Bogus group {0}, not adding {1}.", name, agent.AgentID);
4494 }
4495 }
4496 }
4497 }
4498
4378 // public access 4499 // public access
4379 if (RegionInfo.EstateSettings.PublicAccess) 4500 if (RegionInfo.EstateSettings.PublicAccess)
4380 return true; 4501 return true;
@@ -4401,8 +4522,8 @@ namespace OpenSim.Region.Framework.Scenes
4401 if(estateGroups.Length == 0) 4522 if(estateGroups.Length == 0)
4402 goto Label_GroupsDone; 4523 goto Label_GroupsDone;
4403 4524
4404 List<UUID> agentGroups = new List<UUID>(); 4525//// List<UUID> agentGroups = new List<UUID>();
4405 GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID); 4526//// GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID);
4406 4527
4407 if(GroupMembership == null) 4528 if(GroupMembership == null)
4408 { 4529 {
@@ -4413,8 +4534,8 @@ namespace OpenSim.Region.Framework.Scenes
4413 if(GroupMembership.Length == 0) 4534 if(GroupMembership.Length == 0)
4414 goto Label_GroupsDone; 4535 goto Label_GroupsDone;
4415 4536
4416 for(int i = 0;i < GroupMembership.Length;i++) 4537//// for(int i = 0;i < GroupMembership.Length;i++)
4417 agentGroups.Add(GroupMembership[i].GroupID); 4538//// agentGroups.Add(GroupMembership[i].GroupID);
4418 4539
4419 foreach(UUID group in estateGroups) 4540 foreach(UUID group in estateGroups)
4420 { 4541 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 1d65d8b..4b24a56 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -1113,6 +1113,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1113 SendAgentGroupDataUpdate(remoteClient, true); 1113 SendAgentGroupDataUpdate(remoteClient, true);
1114 } 1114 }
1115 1115
1116 public void JoinGroup(string agentID, UUID groupID)
1117 {
1118 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
1119 UUID u = new UUID(agentID);
1120 m_groupData.AddAgentToGroup(u, u, groupID, UUID.Zero);
1121 }
1122
1116 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 1123 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
1117 { 1124 {
1118 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1125 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);