diff options
author | Diva Canto | 2012-03-17 15:36:20 -0700 |
---|---|---|
committer | Diva Canto | 2012-03-17 15:36:20 -0700 |
commit | 7dfa0309c63263fb15dc9e3883f5717f28e21c0c (patch) | |
tree | 38255cfa7087ae5649d998285e7981f55be2d9af /OpenSim/Region/CoreModules/Framework | |
parent | BAD JUSTIN! (diff) | |
download | opensim-SC_OLD-7dfa0309c63263fb15dc9e3883f5717f28e21c0c.zip opensim-SC_OLD-7dfa0309c63263fb15dc9e3883f5717f28e21c0c.tar.gz opensim-SC_OLD-7dfa0309c63263fb15dc9e3883f5717f28e21c0c.tar.bz2 opensim-SC_OLD-7dfa0309c63263fb15dc9e3883f5717f28e21c0c.tar.xz |
More on HG access control. This commit splits the UserManagementModule into the Basic one and the HG one, so that we can do everything that needs to be done for HG ACLs to work without interfering with the vanilla opensim. For the moment, it finds foreign users who have left a trace in the region, e.g. an object. This makes it possible to ban/IM/etc these users using the regular avatar picker. TODO: contact the UAS directly given a name of the form First.Last @foo.com.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs | 119 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 102 |
2 files changed, 181 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs new file mode 100644 index 0000000..6543bf2 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | ||
34 | using OpenSim.Region.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors.Hypergrid; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.Packets; | ||
42 | using log4net; | ||
43 | using Nini.Config; | ||
44 | |||
45 | namespace OpenSim.Region.CoreModules.Framework.UserManagement | ||
46 | { | ||
47 | public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public new void Initialise(IConfigSource config) | ||
55 | { | ||
56 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", base.Name); | ||
57 | if (umanmod == Name) | ||
58 | { | ||
59 | m_Enabled = true; | ||
60 | RegisterConsoleCmds(); | ||
61 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public override string Name | ||
66 | { | ||
67 | get { return "HGUserManagementModule"; } | ||
68 | } | ||
69 | |||
70 | #endregion ISharedRegionModule | ||
71 | |||
72 | protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users) | ||
73 | { | ||
74 | string[] words = query.Split(new char[] { ' ' }); | ||
75 | |||
76 | for (int i = 0; i < words.Length; i++) | ||
77 | { | ||
78 | if (words[i].Length < 3) | ||
79 | { | ||
80 | if (i != words.Length - 1) | ||
81 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
82 | Array.Resize(ref words, words.Length - 1); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | if (words.Length == 0 || words.Length > 2) | ||
87 | return; | ||
88 | |||
89 | if (words.Length == 2) // First.Last @foo.com, maybe? | ||
90 | { | ||
91 | bool found = false; | ||
92 | foreach (UserData d in m_UserCache.Values) | ||
93 | { | ||
94 | if (d.LastName.StartsWith("@") && (d.FirstName.Equals(words[0]) || d.LastName.Equals(words[1]))) | ||
95 | { | ||
96 | users.Add(d); | ||
97 | found = true; | ||
98 | break; | ||
99 | } | ||
100 | } | ||
101 | if (!found) // This is it! Let's ask the other world | ||
102 | { | ||
103 | // TODO | ||
104 | //UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]); | ||
105 | //uasConn.GetUserInfo(...); | ||
106 | } | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | foreach (UserData d in m_UserCache.Values) | ||
111 | { | ||
112 | if (d.LastName.StartsWith("@") && (d.FirstName.StartsWith(query) || d.LastName.StartsWith(query))) | ||
113 | users.Add(d); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | } | ||
119 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 39e0661..23ef0fc 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -44,7 +44,7 @@ using Nini.Config; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.CoreModules.Framework.UserManagement | 45 | namespace OpenSim.Region.CoreModules.Framework.UserManagement |
46 | { | 46 | { |
47 | class UserData | 47 | public class UserData |
48 | { | 48 | { |
49 | public UUID Id { get; set; } | 49 | public UUID Id { get; set; } |
50 | public string FirstName { get; set; } | 50 | public string FirstName { get; set; } |
@@ -57,36 +57,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
57 | { | 57 | { |
58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | 59 | ||
60 | private List<Scene> m_Scenes = new List<Scene>(); | 60 | protected bool m_Enabled; |
61 | protected List<Scene> m_Scenes = new List<Scene>(); | ||
61 | 62 | ||
62 | // The cache | 63 | // The cache |
63 | Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); | 64 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); |
64 | 65 | ||
65 | #region ISharedRegionModule | 66 | #region ISharedRegionModule |
66 | 67 | ||
67 | public void Initialise(IConfigSource config) | 68 | public void Initialise(IConfigSource config) |
68 | { | 69 | { |
69 | //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); | 70 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name); |
70 | //if (m_Enabled) | 71 | if (umanmod == Name) |
71 | //{ | 72 | { |
72 | // IConfig libConfig = config.Configs["LibraryService"]; | 73 | m_Enabled = true; |
73 | // if (libConfig != null) | 74 | RegisterConsoleCmds(); |
74 | // { | 75 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); |
75 | // string dllName = libConfig.GetString("LocalServiceModule", string.Empty); | 76 | } |
76 | // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); | ||
77 | // if (dllName != string.Empty) | ||
78 | // { | ||
79 | // Object[] args = new Object[] { config }; | ||
80 | // m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args); | ||
81 | // } | ||
82 | // } | ||
83 | //} | ||
84 | MainConsole.Instance.Commands.AddCommand("Users", true, | ||
85 | "show names", | ||
86 | "show names", | ||
87 | "Show the bindings between user UUIDs and user names", | ||
88 | String.Empty, | ||
89 | HandleShowUsers); | ||
90 | } | 77 | } |
91 | 78 | ||
92 | public bool IsSharedModule | 79 | public bool IsSharedModule |
@@ -94,9 +81,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
94 | get { return true; } | 81 | get { return true; } |
95 | } | 82 | } |
96 | 83 | ||
97 | public string Name | 84 | public virtual string Name |
98 | { | 85 | { |
99 | get { return "UserManagement Module"; } | 86 | get { return "BasicUserManagementModule"; } |
100 | } | 87 | } |
101 | 88 | ||
102 | public Type ReplaceableInterface | 89 | public Type ReplaceableInterface |
@@ -106,17 +93,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
106 | 93 | ||
107 | public void AddRegion(Scene scene) | 94 | public void AddRegion(Scene scene) |
108 | { | 95 | { |
109 | m_Scenes.Add(scene); | 96 | if (m_Enabled) |
97 | { | ||
98 | m_Scenes.Add(scene); | ||
110 | 99 | ||
111 | scene.RegisterModuleInterface<IUserManagement>(this); | 100 | scene.RegisterModuleInterface<IUserManagement>(this); |
112 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); | 101 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); |
113 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | 102 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); |
103 | } | ||
114 | } | 104 | } |
115 | 105 | ||
116 | public void RemoveRegion(Scene scene) | 106 | public void RemoveRegion(Scene scene) |
117 | { | 107 | { |
118 | scene.UnregisterModuleInterface<IUserManagement>(this); | 108 | if (m_Enabled) |
119 | m_Scenes.Remove(scene); | 109 | { |
110 | scene.UnregisterModuleInterface<IUserManagement>(this); | ||
111 | m_Scenes.Remove(scene); | ||
112 | } | ||
120 | } | 113 | } |
121 | 114 | ||
122 | public void RegionLoaded(Scene s) | 115 | public void RegionLoaded(Scene s) |
@@ -183,16 +176,31 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
183 | { | 176 | { |
184 | //EventManager.TriggerAvatarPickerRequest(); | 177 | //EventManager.TriggerAvatarPickerRequest(); |
185 | 178 | ||
186 | List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); | 179 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); |
187 | 180 | ||
188 | if (accounts == null) | 181 | List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); |
189 | return; | 182 | |
183 | List<UserData> users = new List<UserData>(); | ||
184 | if (accs != null) | ||
185 | { | ||
186 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Found {0} users", accs.Count); | ||
187 | foreach (UserAccount acc in accs) | ||
188 | { | ||
189 | UserData ud = new UserData(); | ||
190 | ud.FirstName = acc.FirstName; | ||
191 | ud.LastName = acc.LastName; | ||
192 | ud.Id = acc.PrincipalID; | ||
193 | users.Add(ud); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | AddAdditionalUsers(avatarID, query, users); | ||
190 | 198 | ||
191 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); | 199 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); |
192 | // TODO: don't create new blocks if recycling an old packet | 200 | // TODO: don't create new blocks if recycling an old packet |
193 | 201 | ||
194 | AvatarPickerReplyPacket.DataBlock[] searchData = | 202 | AvatarPickerReplyPacket.DataBlock[] searchData = |
195 | new AvatarPickerReplyPacket.DataBlock[accounts.Count]; | 203 | new AvatarPickerReplyPacket.DataBlock[users.Count]; |
196 | AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); | 204 | AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); |
197 | 205 | ||
198 | agentData.AgentID = avatarID; | 206 | agentData.AgentID = avatarID; |
@@ -201,16 +209,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
201 | //byte[] bytes = new byte[AvatarResponses.Count*32]; | 209 | //byte[] bytes = new byte[AvatarResponses.Count*32]; |
202 | 210 | ||
203 | int i = 0; | 211 | int i = 0; |
204 | foreach (UserAccount item in accounts) | 212 | foreach (UserData item in users) |
205 | { | 213 | { |
206 | UUID translatedIDtem = item.PrincipalID; | 214 | UUID translatedIDtem = item.Id; |
207 | searchData[i] = new AvatarPickerReplyPacket.DataBlock(); | 215 | searchData[i] = new AvatarPickerReplyPacket.DataBlock(); |
208 | searchData[i].AvatarID = translatedIDtem; | 216 | searchData[i].AvatarID = translatedIDtem; |
209 | searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); | 217 | searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); |
210 | searchData[i].LastName = Utils.StringToBytes((string)item.LastName); | 218 | searchData[i].LastName = Utils.StringToBytes((string)item.LastName); |
211 | i++; | 219 | i++; |
212 | } | 220 | } |
213 | if (accounts.Count == 0) | 221 | if (users.Count == 0) |
214 | { | 222 | { |
215 | searchData = new AvatarPickerReplyPacket.DataBlock[0]; | 223 | searchData = new AvatarPickerReplyPacket.DataBlock[0]; |
216 | } | 224 | } |
@@ -232,6 +240,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
232 | client.SendAvatarPickerReply(agent_data, data_args); | 240 | client.SendAvatarPickerReply(agent_data, data_args); |
233 | } | 241 | } |
234 | 242 | ||
243 | protected virtual void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users) | ||
244 | { | ||
245 | } | ||
246 | |||
235 | #endregion Event Handlers | 247 | #endregion Event Handlers |
236 | 248 | ||
237 | private void CacheCreators(SceneObjectGroup sog) | 249 | private void CacheCreators(SceneObjectGroup sog) |
@@ -487,13 +499,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
487 | 499 | ||
488 | #endregion IUserManagement | 500 | #endregion IUserManagement |
489 | 501 | ||
502 | protected void RegisterConsoleCmds() | ||
503 | { | ||
504 | MainConsole.Instance.Commands.AddCommand("Users", true, | ||
505 | "show names", | ||
506 | "show names", | ||
507 | "Show the bindings between user UUIDs and user names", | ||
508 | String.Empty, | ||
509 | HandleShowUsers); | ||
510 | } | ||
511 | |||
490 | private void HandleShowUsers(string module, string[] cmd) | 512 | private void HandleShowUsers(string module, string[] cmd) |
491 | { | 513 | { |
492 | lock (m_UserCache) | 514 | lock (m_UserCache) |
493 | { | 515 | { |
494 | if (m_UserCache.Count == 0) | 516 | if (m_UserCache.Count == 0) |
495 | { | 517 | { |
496 | MainConsole.Instance.Output("No users not found"); | 518 | MainConsole.Instance.Output("No users found"); |
497 | return; | 519 | return; |
498 | } | 520 | } |
499 | 521 | ||