aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2012-03-18 20:44:56 +0000
committerMelanie2012-03-18 20:44:56 +0000
commitc7e302864a2eef7f9587ed22286c96a6074ac5b3 (patch)
tree8f0df2f66811309fd790966770434fa3ff68bfdf /OpenSim/Region/CoreModules
parentMerge branch 'ubitwork' (diff)
parentAmend to previous commit: normalize strings ToLower. (diff)
downloadopensim-SC-c7e302864a2eef7f9587ed22286c96a6074ac5b3.zip
opensim-SC-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.gz
opensim-SC-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.bz2
opensim-SC-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs123
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs150
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs124
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs43
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs123
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs36
10 files changed, 482 insertions, 145 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 2154827..ac22c3f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -124,15 +124,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 "Archiving", this, "save iar", 124 "Archiving", this, "save iar",
125 "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]", 125 "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]",
126 "Save user inventory archive (IAR).", 126 "Save user inventory archive (IAR).",
127 "<first> is the user's first name." + Environment.NewLine 127 "<first> is the user's first name.\n"
128 + "<last> is the user's last name." + Environment.NewLine 128 + "<last> is the user's last name.\n"
129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n"
130 + "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
131 + "-c|--creators preserves information about foreign creators." + Environment.NewLine
132 + "-v|--verbose extra debug messages." + Environment.NewLine
133 + "--noassets stops assets being saved to the IAR."
134 + "<IAR path> is the filesystem path at which to save the IAR." 130 + "<IAR path> is the filesystem path at which to save the IAR."
135 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 131 + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME)
132 + "-h|--home=<url> adds the url of the profile service to the saved user information.\n"
133 + "-c|--creators preserves information about foreign creators.\n"
134 + "-v|--verbose extra debug messages.\n"
135 + "--noassets stops assets being saved to the IAR.",
136 HandleSaveInvConsoleCommand); 136 HandleSaveInvConsoleCommand);
137 137
138 m_aScene = scene; 138 m_aScene = scene;
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
new file mode 100644
index 0000000..8077a7a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
@@ -0,0 +1,123 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors.Hypergrid;
39
40using OpenMetaverse;
41using OpenMetaverse.Packets;
42using log4net;
43using Nini.Config;
44
45namespace 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("@") &&
95 (d.FirstName.ToLower().Equals(words[0].ToLower()) ||
96 d.LastName.ToLower().Equals(words[1].ToLower())))
97 {
98 users.Add(d);
99 found = true;
100 break;
101 }
102 }
103 if (!found) // This is it! Let's ask the other world
104 {
105 // TODO
106 //UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]);
107 //uasConn.GetUserInfo(...);
108 }
109 }
110 else
111 {
112 foreach (UserData d in m_UserCache.Values)
113 {
114 if (d.LastName.StartsWith("@") &&
115 (d.FirstName.ToLower().StartsWith(query.ToLower()) ||
116 d.LastName.ToLower().StartsWith(query.ToLower())))
117 users.Add(d);
118 }
119 }
120 }
121
122 }
123} \ 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 554af14..23ef0fc 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -38,12 +38,13 @@ using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors.Hypergrid; 38using OpenSim.Services.Connectors.Hypergrid;
39 39
40using OpenMetaverse; 40using OpenMetaverse;
41using OpenMetaverse.Packets;
41using log4net; 42using log4net;
42using Nini.Config; 43using Nini.Config;
43 44
44namespace OpenSim.Region.CoreModules.Framework.UserManagement 45namespace OpenSim.Region.CoreModules.Framework.UserManagement
45{ 46{
46 class UserData 47 public class UserData
47 { 48 {
48 public UUID Id { get; set; } 49 public UUID Id { get; set; }
49 public string FirstName { get; set; } 50 public string FirstName { get; set; }
@@ -56,36 +57,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
56 { 57 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 private List<Scene> m_Scenes = new List<Scene>(); 60 protected bool m_Enabled;
61 protected List<Scene> m_Scenes = new List<Scene>();
60 62
61 // The cache 63 // The cache
62 Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); 64 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
63 65
64 #region ISharedRegionModule 66 #region ISharedRegionModule
65 67
66 public void Initialise(IConfigSource config) 68 public void Initialise(IConfigSource config)
67 { 69 {
68 //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); 70 string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name);
69 //if (m_Enabled) 71 if (umanmod == Name)
70 //{ 72 {
71 // IConfig libConfig = config.Configs["LibraryService"]; 73 m_Enabled = true;
72 // if (libConfig != null) 74 RegisterConsoleCmds();
73 // { 75 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
74 // string dllName = libConfig.GetString("LocalServiceModule", string.Empty); 76 }
75 // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
76 // if (dllName != string.Empty)
77 // {
78 // Object[] args = new Object[] { config };
79 // m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
80 // }
81 // }
82 //}
83 MainConsole.Instance.Commands.AddCommand("Users", true,
84 "show names",
85 "show names",
86 "Show the bindings between user UUIDs and user names",
87 String.Empty,
88 HandleShowUsers);
89 } 77 }
90 78
91 public bool IsSharedModule 79 public bool IsSharedModule
@@ -93,9 +81,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
93 get { return true; } 81 get { return true; }
94 } 82 }
95 83
96 public string Name 84 public virtual string Name
97 { 85 {
98 get { return "UserManagement Module"; } 86 get { return "BasicUserManagementModule"; }
99 } 87 }
100 88
101 public Type ReplaceableInterface 89 public Type ReplaceableInterface
@@ -105,17 +93,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
105 93
106 public void AddRegion(Scene scene) 94 public void AddRegion(Scene scene)
107 { 95 {
108 m_Scenes.Add(scene); 96 if (m_Enabled)
97 {
98 m_Scenes.Add(scene);
109 99
110 scene.RegisterModuleInterface<IUserManagement>(this); 100 scene.RegisterModuleInterface<IUserManagement>(this);
111 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); 101 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
112 scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); 102 scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded);
103 }
113 } 104 }
114 105
115 public void RemoveRegion(Scene scene) 106 public void RemoveRegion(Scene scene)
116 { 107 {
117 scene.UnregisterModuleInterface<IUserManagement>(this); 108 if (m_Enabled)
118 m_Scenes.Remove(scene); 109 {
110 scene.UnregisterModuleInterface<IUserManagement>(this);
111 m_Scenes.Remove(scene);
112 }
119 } 113 }
120 114
121 public void RegionLoaded(Scene s) 115 public void RegionLoaded(Scene s)
@@ -149,7 +143,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
149 143
150 void EventManager_OnNewClient(IClientAPI client) 144 void EventManager_OnNewClient(IClientAPI client)
151 { 145 {
146 client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed);
152 client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); 147 client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest);
148 client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest);
149 }
150
151 void HandleConnectionClosed(IClientAPI client)
152 {
153 client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest);
154 client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest);
153 } 155 }
154 156
155 void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) 157 void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
@@ -170,6 +172,78 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
170 } 172 }
171 } 173 }
172 174
175 public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
176 {
177 //EventManager.TriggerAvatarPickerRequest();
178
179 m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query);
180
181 List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query);
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);
198
199 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
200 // TODO: don't create new blocks if recycling an old packet
201
202 AvatarPickerReplyPacket.DataBlock[] searchData =
203 new AvatarPickerReplyPacket.DataBlock[users.Count];
204 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
205
206 agentData.AgentID = avatarID;
207 agentData.QueryID = RequestID;
208 replyPacket.AgentData = agentData;
209 //byte[] bytes = new byte[AvatarResponses.Count*32];
210
211 int i = 0;
212 foreach (UserData item in users)
213 {
214 UUID translatedIDtem = item.Id;
215 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
216 searchData[i].AvatarID = translatedIDtem;
217 searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName);
218 searchData[i].LastName = Utils.StringToBytes((string)item.LastName);
219 i++;
220 }
221 if (users.Count == 0)
222 {
223 searchData = new AvatarPickerReplyPacket.DataBlock[0];
224 }
225 replyPacket.Data = searchData;
226
227 AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
228 agent_data.AgentID = replyPacket.AgentData.AgentID;
229 agent_data.QueryID = replyPacket.AgentData.QueryID;
230
231 List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
232 for (i = 0; i < replyPacket.Data.Length; i++)
233 {
234 AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
235 data_arg.AvatarID = replyPacket.Data[i].AvatarID;
236 data_arg.FirstName = replyPacket.Data[i].FirstName;
237 data_arg.LastName = replyPacket.Data[i].LastName;
238 data_args.Add(data_arg);
239 }
240 client.SendAvatarPickerReply(agent_data, data_args);
241 }
242
243 protected virtual void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
244 {
245 }
246
173 #endregion Event Handlers 247 #endregion Event Handlers
174 248
175 private void CacheCreators(SceneObjectGroup sog) 249 private void CacheCreators(SceneObjectGroup sog)
@@ -425,13 +499,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
425 499
426 #endregion IUserManagement 500 #endregion IUserManagement
427 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
428 private void HandleShowUsers(string module, string[] cmd) 512 private void HandleShowUsers(string module, string[] cmd)
429 { 513 {
430 lock (m_UserCache) 514 lock (m_UserCache)
431 { 515 {
432 if (m_UserCache.Count == 0) 516 if (m_UserCache.Count == 0)
433 { 517 {
434 MainConsole.Instance.Output("No users not found"); 518 MainConsole.Instance.Output("No users found");
435 return; 519 return;
436 } 520 }
437 521
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index e22fd38..dc6efed 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -9,6 +9,7 @@
9 9
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" /> 11 <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" />
12 <RegionModule id="HGUserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.HGUserManagementModule" />
12 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" /> 13 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
13 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" /> 14 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
14 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" /> 15 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
new file mode 100644
index 0000000..f0d21e6
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
@@ -0,0 +1,124 @@
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
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Services.Interfaces;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenMetaverse;
39
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
43{
44 public class AuthorizationService : IAuthorizationService
45 {
46 private enum AccessFlags
47 {
48 None = 0, /* No restrictions */
49 DisallowResidents = 1, /* Only gods and managers*/
50 DisallowForeigners = 2, /* Only local people */
51 }
52
53 private static readonly ILog m_log =
54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType);
56
57 private IUserManagement m_UserManagement;
58 private IGridService m_GridService;
59
60 private Scene m_Scene;
61 AccessFlags m_accessValue = AccessFlags.None;
62
63
64 public AuthorizationService(IConfig config, Scene scene)
65 {
66 m_Scene = scene;
67 m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
68 m_GridService = scene.GridService;
69
70 if (config != null)
71 {
72 string accessStr = config.GetString("Region_" + scene.RegionInfo.RegionName.Replace(' ', '_'), String.Empty);
73 if (accessStr != string.Empty)
74 {
75 try
76 {
77 m_accessValue = (AccessFlags)Enum.Parse(typeof(AccessFlags), accessStr);
78 }
79 catch (ArgumentException)
80 {
81 m_log.WarnFormat("[AuthorizationService]: {0} is not a valid access flag", accessStr);
82 }
83 }
84 m_log.DebugFormat("[AuthorizationService]: Region {0} access restrictions: {1}", m_Scene.RegionInfo.RegionName, m_accessValue);
85 }
86
87 }
88
89 public bool IsAuthorizedForRegion(
90 string user, string firstName, string lastName, string regionID, out string message)
91 {
92 message = "authorized";
93
94 // This should not happen
95 if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
96 {
97 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}",
98 m_Scene.RegionInfo.RegionID, regionID);
99 return true;
100 }
101
102 if (m_accessValue == AccessFlags.None)
103 return true;
104
105 UUID userID = new UUID(user);
106 bool authorized = true;
107 if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners)
108 {
109 authorized = m_UserManagement.IsLocalGridUser(userID);
110 if (!authorized)
111 message = "no foreigner users allowed in this region";
112 }
113 if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents)
114 {
115 authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID);
116 if (!authorized)
117 message = "only Admins and Managers allowed in this region";
118 }
119
120 return authorized;
121 }
122
123 }
124} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
index 18a7177..c982db6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
@@ -39,13 +39,15 @@ using OpenMetaverse;
39 39
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization 40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
41{ 41{
42 public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService 42 public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService
43 { 43 {
44 private static readonly ILog m_log = 44 private static readonly ILog m_log =
45 LogManager.GetLogger( 45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private IAuthorizationService m_AuthorizationService; 48 private IAuthorizationService m_AuthorizationService;
49 private Scene m_Scene;
50 private IConfig m_AuthorizationConfig;
49 51
50 private bool m_Enabled = false; 52 private bool m_Enabled = false;
51 53
@@ -69,33 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
69 string name = moduleConfig.GetString("AuthorizationServices", string.Empty); 71 string name = moduleConfig.GetString("AuthorizationServices", string.Empty);
70 if (name == Name) 72 if (name == Name)
71 { 73 {
72 IConfig authorizationConfig = source.Configs["AuthorizationService"];
73 if (authorizationConfig == null)
74 {
75 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
76 return;
77 }
78
79 string serviceDll = authorizationConfig.GetString("LocalServiceModule",
80 String.Empty);
81
82 if (serviceDll == String.Empty)
83 {
84 m_log.Error("[AUTHORIZATION CONNECTOR]: No LocalServiceModule named in section AuthorizationService");
85 return;
86 }
87
88 Object[] args = new Object[] { source };
89 m_AuthorizationService =
90 ServerUtils.LoadPlugin<IAuthorizationService>(serviceDll,
91 args);
92
93 if (m_AuthorizationService == null)
94 {
95 m_log.Error("[AUTHORIZATION CONNECTOR]: Can't load authorization service");
96 return;
97 }
98 m_Enabled = true; 74 m_Enabled = true;
75 m_AuthorizationConfig = source.Configs["AuthorizationService"];
99 m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); 76 m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled");
100 } 77 }
101 } 78 }
@@ -115,6 +92,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
115 return; 92 return;
116 93
117 scene.RegisterModuleInterface<IAuthorizationService>(this); 94 scene.RegisterModuleInterface<IAuthorizationService>(this);
95 m_Scene = scene;
96
97 scene.EventManager.OnLoginsEnabled += new EventManager.LoginsEnabled(OnLoginsEnabled);
118 } 98 }
119 99
120 public void RemoveRegion(Scene scene) 100 public void RemoveRegion(Scene scene)
@@ -131,9 +111,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
131 scene.RegionInfo.RegionName); 111 scene.RegionInfo.RegionName);
132 } 112 }
133 113
114 private void OnLoginsEnabled(string regionName)
115 {
116 m_AuthorizationService = new AuthorizationService(m_AuthorizationConfig, m_Scene);
117 }
118
134 public bool IsAuthorizedForRegion( 119 public bool IsAuthorizedForRegion(
135 string userID, string firstName, string lastName, string regionID, out string message) 120 string userID, string firstName, string lastName, string regionID, out string message)
136 { 121 {
122 message = "";
123 if (!m_Enabled)
124 return true;
125
137 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); 126 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message);
138 } 127 }
139 } 128 }
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 35f47d2..b95bda5 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -26,8 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.IO; 31using System.IO;
32using System.Linq;
31using System.Reflection; 33using System.Reflection;
32using System.Security; 34using System.Security;
33using System.Timers; 35using System.Timers;
@@ -46,8 +48,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
46 { 48 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 50
49 private delegate void LookupUUIDS(List<UUID> uuidLst);
50
51 private Timer m_regionChangeTimer = new Timer(); 51 private Timer m_regionChangeTimer = new Timer();
52 public Scene Scene { get; private set; } 52 public Scene Scene { get; private set; }
53 public IUserManagement UserManager { get; private set; } 53 public IUserManagement UserManager { get; private set; }
@@ -907,98 +907,77 @@ namespace OpenSim.Region.CoreModules.World.Estate
907 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) 907 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
908 return; 908 return;
909 909
910 Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); 910 Dictionary<uint, float> sceneData = null;
911 List<UUID> uuidNameLookupList = new List<UUID>(); 911 List<UUID> uuidNameLookupList = new List<UUID>();
912 912
913 if (reportType == 1) 913 if (reportType == 1)
914 { 914 {
915 SceneData = Scene.PhysicsScene.GetTopColliders(); 915 sceneData = Scene.PhysicsScene.GetTopColliders();
916 } 916 }
917 else if (reportType == 0) 917 else if (reportType == 0)
918 { 918 {
919 SceneData = Scene.SceneGraph.GetTopScripts(); 919 IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
920
921 if (scriptModule != null)
922 sceneData = scriptModule.GetObjectScriptsExecutionTimes();
920 } 923 }
921 924
922 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); 925 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
923 lock (SceneData) 926 if (sceneData != null)
924 { 927 {
925 foreach (uint obj in SceneData.Keys) 928 var sortedSceneData
929 = sceneData.Select(
930 item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
931
932 sortedSceneData.OrderBy(item => item.Measurement);
933
934 int items = 0;
935
936 foreach (var entry in sortedSceneData)
926 { 937 {
927 SceneObjectPart prt = Scene.GetSceneObjectPart(obj); 938 // The object may have been deleted since we received the data.
928 if (prt != null) 939 if (entry.Part == null)
940 continue;
941
942 // Don't show scripts that haven't executed or where execution time is below one microsecond in
943 // order to produce a more readable report.
944 if (entry.Measurement < 0.001)
945 continue;
946
947 items++;
948 SceneObjectGroup so = entry.Part.ParentGroup;
949
950 LandStatReportItem lsri = new LandStatReportItem();
951 lsri.LocationX = so.AbsolutePosition.X;
952 lsri.LocationY = so.AbsolutePosition.Y;
953 lsri.LocationZ = so.AbsolutePosition.Z;
954 lsri.Score = entry.Measurement;
955 lsri.TaskID = so.UUID;
956 lsri.TaskLocalID = so.LocalId;
957 lsri.TaskName = entry.Part.Name;
958 lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
959
960 if (filter.Length != 0)
929 { 961 {
930 SceneObjectGroup sog = prt.ParentGroup; 962 if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
931 LandStatReportItem lsri = new LandStatReportItem();
932 lsri.LocationX = sog.AbsolutePosition.X;
933 lsri.LocationY = sog.AbsolutePosition.Y;
934 lsri.LocationZ = sog.AbsolutePosition.Z;
935 lsri.Score = SceneData[obj];
936 lsri.TaskID = sog.UUID;
937 lsri.TaskLocalID = sog.LocalId;
938 lsri.TaskName = sog.GetPartName(obj);
939 lsri.OwnerName = "waiting";
940 lock (uuidNameLookupList)
941 uuidNameLookupList.Add(sog.OwnerID);
942
943 if (filter.Length != 0)
944 { 963 {
945 if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
946 {
947 }
948 else
949 {
950 continue;
951 }
952 } 964 }
953 965 else
954 SceneReport.Add(lsri); 966 {
967 continue;
968 }
955 } 969 }
970
971 SceneReport.Add(lsri);
972
973 if (items >= 100)
974 break;
956 } 975 }
957 } 976 }
958 977
959 remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); 978 remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
960
961 if (uuidNameLookupList.Count > 0)
962 LookupUUID(uuidNameLookupList);
963 } 979 }
964 980
965 private static void LookupUUIDSCompleted(IAsyncResult iar)
966 {
967 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
968 icon.EndInvoke(iar);
969 }
970
971 private void LookupUUID(List<UUID> uuidLst)
972 {
973 LookupUUIDS d = LookupUUIDsAsync;
974
975 d.BeginInvoke(uuidLst,
976 LookupUUIDSCompleted,
977 d);
978 }
979
980 private void LookupUUIDsAsync(List<UUID> uuidLst)
981 {
982 UUID[] uuidarr;
983
984 lock (uuidLst)
985 {
986 uuidarr = uuidLst.ToArray();
987 }
988
989 for (int i = 0; i < uuidarr.Length; i++)
990 {
991 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
992
993 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
994 if (userManager != null)
995 userManager.GetUserName(uuidarr[i]);
996
997 // we drop it. It gets cached though... so we're ready for the next request.
998 // diva commnent 11/21/2010: uh?!? wft?
999 // justincc comment 21/01/2011: A side effect of userManager.GetUserName() I presume.
1000 }
1001 }
1002 #endregion 981 #endregion
1003 982
1004 #region Outgoing Packets 983 #region Outgoing Packets
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 0f83d82..02ac091 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1664,7 +1664,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1664 { 1664 {
1665 if (e.OwnerID == targetID) 1665 if (e.OwnerID == targetID)
1666 { 1666 {
1667 if (e.scriptScore >= 0.01) 1667 if (e.ContainsScripts())
1668 { 1668 {
1669 returns.Add(e); 1669 returns.Add(e);
1670 } 1670 }
@@ -1681,7 +1681,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1681 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); 1681 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1682 if (landobject.LandData.OwnerID != e.OwnerID) 1682 if (landobject.LandData.OwnerID != e.OwnerID)
1683 { 1683 {
1684 if (e.scriptScore >= 0.01) 1684 if (e.ContainsScripts())
1685 { 1685 {
1686 returns.Add(e); 1686 returns.Add(e);
1687 } 1687 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 4805ccb..c51e140 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
86 private volatile bool m_tainted; 86 private volatile bool m_tainted;
87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); 87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
88 88
89 private String m_InitialTerrain = "pinhead-island";
90
89 /// <summary> 91 /// <summary>
90 /// Human readable list of terrain file extensions that are supported. 92 /// Human readable list of terrain file extensions that are supported.
91 /// </summary> 93 /// </summary>
@@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
109 /// <param name="config">Config for the region</param> 111 /// <param name="config">Config for the region</param>
110 public void Initialise(IConfigSource config) 112 public void Initialise(IConfigSource config)
111 { 113 {
114 IConfig terrainConfig = config.Configs["Terrain"];
115 if (terrainConfig != null)
116 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
112 } 117 }
113 118
114 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
120 { 125 {
121 if (m_scene.Heightmap == null) 126 if (m_scene.Heightmap == null)
122 { 127 {
123 m_channel = new TerrainChannel(); 128 m_channel = new TerrainChannel(m_InitialTerrain);
124 m_scene.Heightmap = m_channel; 129 m_scene.Heightmap = m_channel;
125 m_revert = new TerrainChannel(); 130 m_revert = new TerrainChannel();
126 UpdateRevertMap(); 131 UpdateRevertMap();
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index f9384e9..3efb7dd 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -92,7 +92,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
92 return; 92 return;
93 } 93 }
94 94
95//m_log.DebugFormat("MAP NAME=({0})", mapName); 95 //m_log.DebugFormat("MAP NAME=({0})", mapName);
96
97 // Hack to get around the fact that ll V3 now drops the port from the
98 // map name. See https://jira.secondlife.com/browse/VWR-28570
99 //
100 // Caller, use this magic form instead:
101 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
102 // or url encode if possible.
103 // the hacks we do with this viewer...
104 //
105 string mapNameOrig = mapName;
106 if (mapName.Contains("|"))
107 mapName = mapName.Replace('|', ':');
108 if (mapName.Contains("+"))
109 mapName = mapName.Replace('+', ' ');
110 if (mapName.Contains("!"))
111 mapName = mapName.Replace('!', '/');
96 112
97 // try to fetch from GridServer 113 // try to fetch from GridServer
98 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 114 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
@@ -114,7 +130,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
114 data.MapImageId = UUID.Zero; 130 data.MapImageId = UUID.Zero;
115 else 131 else
116 data.MapImageId = info.TerrainImage; 132 data.MapImageId = info.TerrainImage;
117 data.Name = info.RegionName; 133 // ugh! V2-3 is very sensitive about the result being
134 // exactly the same as the requested name
135 if (regionInfos.Count == 1)
136 data.Name = mapNameOrig;
137 else
138 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 139 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 140 data.WaterHeight = 0; // not used
120 data.X = (ushort)(info.RegionLocX / Constants.RegionSize); 141 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
@@ -138,6 +159,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
138 // flags are agent flags sent from the viewer. 159 // flags are agent flags sent from the viewer.
139 // they have different values depending on different viewers, apparently 160 // they have different values depending on different viewers, apparently
140 remoteClient.SendMapBlock(blocks, flags); 161 remoteClient.SendMapBlock(blocks, flags);
162
163 // send extra user messages for V3
164 // because the UI is very confusing
165 // while we don't fix the hard-coded urls
166 if (flags == 2)
167 {
168 if (regionInfos.Count == 0)
169 remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
170 else if (regionInfos.Count == 1)
171 remoteClient.SendAgentAlertMessage("Region found!", false);
172 }
141 } 173 }
142 174
143// private Scene GetClientScene(IClientAPI client) 175// private Scene GetClientScene(IClientAPI client)