diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 198 |
1 files changed, 164 insertions, 34 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 964efda..582b267 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -62,6 +62,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
62 | private string m_ThisGatekeeper; | 62 | private string m_ThisGatekeeper; |
63 | private bool m_RestrictInventoryAccessAbroad; | 63 | private bool m_RestrictInventoryAccessAbroad; |
64 | 64 | ||
65 | private bool m_bypassPermissions = true; | ||
66 | |||
67 | // This simple check makes it possible to support grids in which all the simulators | ||
68 | // share all central services of the Robust server EXCEPT assets. In other words, | ||
69 | // grids where the simulators' assets are kept in one DB and the users' inventory assets | ||
70 | // are kept on another. When users rez items from inventory or take objects from world, | ||
71 | // an HG-like asset copy takes place between the 2 servers, the world asset server and | ||
72 | // the user's asset server. | ||
73 | private bool m_CheckSeparateAssets = false; | ||
74 | private string m_LocalAssetsURL = string.Empty; | ||
75 | |||
65 | // private bool m_Initialized = false; | 76 | // private bool m_Initialized = false; |
66 | 77 | ||
67 | #region INonSharedRegionModule | 78 | #region INonSharedRegionModule |
@@ -88,16 +99,26 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
88 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; | 99 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; |
89 | if (thisModuleConfig != null) | 100 | if (thisModuleConfig != null) |
90 | { | 101 | { |
91 | // legacy configuration [obsolete] | 102 | m_HomeURI = Util.GetConfigVarFromSections<string>(source, "HomeURI", |
92 | m_HomeURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); | 103 | new string[] { "Startup", "Hypergrid", "HGInventoryAccessModule" }, String.Empty); |
93 | // preferred | 104 | m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI", |
94 | m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); | 105 | new string[] { "Startup", "Hypergrid", "HGInventoryAccessModule" }, String.Empty); |
106 | // Legacy. Renove soon! | ||
107 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", m_ThisGatekeeper); | ||
108 | |||
95 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 109 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); |
96 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); | ||
97 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); | 110 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); |
111 | m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false); | ||
112 | m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty); | ||
113 | m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' }); | ||
114 | |||
98 | } | 115 | } |
99 | else | 116 | else |
100 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 117 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
118 | |||
119 | m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(source, "serverside_object_permissions", | ||
120 | new string[] { "Startup", "Permissions" }, true); | ||
121 | |||
101 | } | 122 | } |
102 | } | 123 | } |
103 | } | 124 | } |
@@ -109,9 +130,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
109 | 130 | ||
110 | base.AddRegion(scene); | 131 | base.AddRegion(scene); |
111 | m_assMapper = new HGAssetMapper(scene, m_HomeURI); | 132 | m_assMapper = new HGAssetMapper(scene, m_HomeURI); |
112 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | 133 | scene.EventManager.OnNewInventoryItemUploadComplete += PostInventoryAsset; |
113 | scene.EventManager.OnTeleportStart += TeleportStart; | 134 | scene.EventManager.OnTeleportStart += TeleportStart; |
114 | scene.EventManager.OnTeleportFail += TeleportFail; | 135 | scene.EventManager.OnTeleportFail += TeleportFail; |
136 | |||
137 | // We're fgoing to enforce some stricter permissions if Outbound is false | ||
138 | scene.Permissions.OnTakeObject += CanTakeObject; | ||
139 | scene.Permissions.OnTakeCopyObject += CanTakeObject; | ||
140 | scene.Permissions.OnTransferUserInventory += OnTransferUserInventory; | ||
115 | } | 141 | } |
116 | 142 | ||
117 | #endregion | 143 | #endregion |
@@ -133,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
133 | if (sp is ScenePresence) | 159 | if (sp is ScenePresence) |
134 | { | 160 | { |
135 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); | 161 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); |
136 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | 162 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
137 | { | 163 | { |
138 | if (m_RestrictInventoryAccessAbroad) | 164 | if (m_RestrictInventoryAccessAbroad) |
139 | { | 165 | { |
@@ -183,8 +209,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
183 | } | 209 | } |
184 | } | 210 | } |
185 | 211 | ||
186 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | 212 | public void PostInventoryAsset(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) |
187 | { | 213 | { |
214 | if (type == AssetType.Link) | ||
215 | return; | ||
216 | |||
188 | string userAssetServer = string.Empty; | 217 | string userAssetServer = string.Empty; |
189 | if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 218 | if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) |
190 | { | 219 | { |
@@ -219,18 +248,32 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
219 | { | 248 | { |
220 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | 249 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); |
221 | 250 | ||
222 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | 251 | PostInventoryAsset(remoteClient.AgentId, AssetType.Unknown, newAssetID, "", 0); |
223 | 252 | ||
224 | return newAssetID; | 253 | return newAssetID; |
225 | } | 254 | } |
226 | 255 | ||
256 | /// | ||
257 | /// UpdateInventoryItemAsset | ||
258 | /// | ||
259 | public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) | ||
260 | { | ||
261 | if (base.UpdateInventoryItemAsset(ownerID, item, asset)) | ||
262 | { | ||
263 | PostInventoryAsset(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); | ||
264 | return true; | ||
265 | } | ||
266 | |||
267 | return false; | ||
268 | } | ||
269 | |||
227 | /// | 270 | /// |
228 | /// Used in DeleteToInventory | 271 | /// Used in DeleteToInventory |
229 | /// | 272 | /// |
230 | protected override void ExportAsset(UUID agentID, UUID assetID) | 273 | protected override void ExportAsset(UUID agentID, UUID assetID) |
231 | { | 274 | { |
232 | if (!assetID.Equals(UUID.Zero)) | 275 | if (!assetID.Equals(UUID.Zero)) |
233 | UploadInventoryItem(agentID, assetID, "", 0); | 276 | PostInventoryAsset(agentID, AssetType.Unknown, assetID, "", 0); |
234 | else | 277 | else |
235 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | 278 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); |
236 | } | 279 | } |
@@ -242,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
242 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 285 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
243 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 286 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
244 | { | 287 | { |
245 | m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); | 288 | m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); |
246 | 289 | ||
247 | //if (fromTaskID.Equals(UUID.Zero)) | 290 | //if (fromTaskID.Equals(UUID.Zero)) |
248 | //{ | 291 | //{ |
@@ -268,50 +311,98 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
268 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 311 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
269 | RezSelected, RemoveItem, fromTaskID, attachment); | 312 | RezSelected, RemoveItem, fromTaskID, attachment); |
270 | 313 | ||
271 | if (sog == null) | ||
272 | remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false); | ||
273 | |||
274 | return sog; | 314 | return sog; |
275 | 315 | ||
276 | } | 316 | } |
277 | 317 | ||
278 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 318 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
279 | { | 319 | { |
280 | string userAssetServer = string.Empty; | 320 | string senderAssetServer = string.Empty; |
281 | if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) | 321 | string receiverAssetServer = string.Empty; |
282 | m_assMapper.Get(item.AssetID, sender, userAssetServer); | 322 | bool isForeignSender, isForeignReceiver; |
323 | isForeignSender = IsForeignUser(sender, out senderAssetServer); | ||
324 | isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); | ||
325 | |||
326 | // They're both local. Nothing to do. | ||
327 | if (!isForeignSender && !isForeignReceiver) | ||
328 | return; | ||
329 | |||
330 | // At least one of them is foreign. | ||
331 | // If both users have the same asset server, no need to transfer the asset | ||
332 | if (senderAssetServer.Equals(receiverAssetServer)) | ||
333 | { | ||
334 | m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); | ||
335 | return; | ||
336 | } | ||
337 | |||
338 | if (isForeignSender && senderAssetServer != string.Empty) | ||
339 | m_assMapper.Get(item.AssetID, sender, senderAssetServer); | ||
283 | 340 | ||
284 | if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 341 | if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) |
285 | m_assMapper.Post(item.AssetID, receiver, userAssetServer); | 342 | m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); |
286 | } | 343 | } |
287 | 344 | ||
288 | public override bool IsForeignUser(UUID userID, out string assetServerURL) | 345 | public override bool IsForeignUser(UUID userID, out string assetServerURL) |
289 | { | 346 | { |
290 | assetServerURL = string.Empty; | 347 | assetServerURL = string.Empty; |
291 | 348 | ||
292 | if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) | 349 | if (UserManagementModule != null) |
293 | { // foreign | 350 | { |
294 | ScenePresence sp = null; | 351 | if (!m_CheckSeparateAssets) |
295 | if (m_Scene.TryGetScenePresence(userID, out sp)) | ||
296 | { | 352 | { |
297 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 353 | if (!UserManagementModule.IsLocalGridUser(userID)) |
298 | if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 354 | { // foreign |
299 | { | 355 | ScenePresence sp = null; |
300 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 356 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
301 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 357 | { |
358 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
359 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
360 | { | ||
361 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
362 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
363 | } | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | ||
368 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
369 | } | ||
370 | return true; | ||
302 | } | 371 | } |
303 | } | 372 | } |
304 | else | 373 | else |
305 | { | 374 | { |
306 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | 375 | if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) |
307 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 376 | { |
377 | m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); | ||
378 | return false; | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); | ||
383 | return true; | ||
384 | } | ||
308 | } | 385 | } |
309 | return true; | ||
310 | } | 386 | } |
311 | |||
312 | return false; | 387 | return false; |
313 | } | 388 | } |
314 | 389 | ||
390 | private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) | ||
391 | { | ||
392 | assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); | ||
393 | if (assetsURL == string.Empty) | ||
394 | { | ||
395 | AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); | ||
396 | if (agent != null) | ||
397 | { | ||
398 | assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); | ||
399 | assetsURL = assetsURL.Trim(new char[] { '/' }); | ||
400 | } | ||
401 | } | ||
402 | return m_LocalAssetsURL.Equals(assetsURL); | ||
403 | } | ||
404 | |||
405 | |||
315 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 406 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
316 | { | 407 | { |
317 | InventoryItemBase item = base.GetItem(agentID, itemID); | 408 | InventoryItemBase item = base.GetItem(agentID, itemID); |
@@ -346,7 +437,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
346 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); | 437 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); |
347 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); | 438 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); |
348 | 439 | ||
349 | inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); | 440 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); |
441 | |||
442 | foreach (InventoryFolderBase f in content.Folders) | ||
443 | { | ||
444 | if (f.Name != "My Suitcase" && f.Name != "Current Outfit") | ||
445 | keep.Add(f); | ||
446 | } | ||
447 | |||
448 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); | ||
350 | } | 449 | } |
351 | } | 450 | } |
352 | } | 451 | } |
@@ -379,7 +478,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
379 | 478 | ||
380 | foreach (InventoryFolderBase f in content.Folders) | 479 | foreach (InventoryFolderBase f in content.Folders) |
381 | { | 480 | { |
382 | if (f.Name != "My Suitcase") | 481 | if (f.Name != "My Suitcase" && f.Name != "Current Outfit") |
383 | { | 482 | { |
384 | f.Name = f.Name + " (Unavailable)"; | 483 | f.Name = f.Name + " (Unavailable)"; |
385 | keep.Add(f); | 484 | keep.Add(f); |
@@ -404,5 +503,36 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
404 | } | 503 | } |
405 | 504 | ||
406 | #endregion | 505 | #endregion |
506 | |||
507 | #region Permissions | ||
508 | |||
509 | private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) | ||
510 | { | ||
511 | if (m_bypassPermissions) return true; | ||
512 | |||
513 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) | ||
514 | { | ||
515 | SceneObjectGroup sog = null; | ||
516 | if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer) | ||
517 | return true; | ||
518 | |||
519 | return false; | ||
520 | } | ||
521 | |||
522 | return true; | ||
523 | } | ||
524 | |||
525 | private bool OnTransferUserInventory(UUID itemID, UUID userID, UUID recipientID) | ||
526 | { | ||
527 | if (m_bypassPermissions) return true; | ||
528 | |||
529 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(recipientID)) | ||
530 | return false; | ||
531 | |||
532 | return true; | ||
533 | } | ||
534 | |||
535 | |||
536 | #endregion | ||
407 | } | 537 | } |
408 | } \ No newline at end of file | 538 | } \ No newline at end of file |