From b542622b3a841e73f071aab563ba1e211c5a87e3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 21 Sep 2012 07:44:18 -0700 Subject: [PATCH] HG 2.0: added asset import/export policies at the sim too. --- .../Asset/HGAssetBroker.cs | 23 ++++++++++++------- bin/Robust.HG.ini.example | 2 +- bin/config-include/GridCommon.ini.example | 20 ++++++++++++++++ .../StandaloneCommon.ini.example | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 008465fcc9..04568525f0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -56,6 +56,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset private bool m_Enabled = false; + private AssetPermissions m_AssetPerms; + public Type ReplaceableInterface { get { return null; } @@ -128,6 +130,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset if (m_LocalAssetServiceURI != string.Empty) m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/'); + IConfig hgConfig = source.Configs["HGAssetService"]; + m_AssetPerms = new AssetPermissions(hgConfig); + m_Enabled = true; m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); } @@ -206,14 +211,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset asset = m_HGService.Get(id); if (asset != null) { - // Now store it locally - // For now, let me just do it for textures and scripts - if (((AssetType)asset.Type == AssetType.Texture) || - ((AssetType)asset.Type == AssetType.LSLBytecode) || - ((AssetType)asset.Type == AssetType.LSLText)) - { + // Now store it locally, if allowed + if (m_AssetPerms.AllowedImport(asset.Type)) m_GridService.Store(asset); - } + else + return null; } } else @@ -328,7 +330,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset string id = string.Empty; if (IsHG(asset.ID)) - id = m_HGService.Store(asset); + { + if (m_AssetPerms.AllowedExport(asset.Type)) + id = m_HGService.Store(asset); + else + return String.Empty; + } else id = m_GridService.Store(asset); diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 399779d091..afb3f6feea 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -437,7 +437,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 UserAccountsService = "OpenSim.Services.UserAccountService.dll:UserAccountService" HomeURI = "http://127.0.0.1:8002" - ;; The asset types that this service can export to / import from other grids. + ;; The asset types that this grid can export to / import from other grids. ;; Comma separated. ;; Valid values are all the asset types in OpenMetaverse.AssetType, namely: ;; Unknown, Texture, Sound, CallingCard, Landmark, Clothing, Object, Notecard, LSLText, diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 8d7f6fc427..79f7ed6c3f 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -137,6 +137,26 @@ ;; uncomment the next line. You may want to do this on sims that have licensed content. ; OutboundPermission = False +[HGAssetService] + ; + ; === HG ONLY === + ; Change this to your server + ; accessible from other grids + ; + HomeURI = "http://mygridserver.com:8002" + + ;; The asset types that this grid can export to / import from other grids. + ;; Comma separated. + ;; Valid values are all the asset types in OpenMetaverse.AssetType, namely: + ;; Unknown, Texture, Sound, CallingCard, Landmark, Clothing, Object, Notecard, LSLText, + ;; LSLBytecode, TextureTGA, Bodypart, SoundWAV, ImageTGA, ImageJPEG, Animation, Gesture, Mesh + ;; + ;; Leave blank or commented if you don't want to apply any restrictions. + ;; A more strict, but still reasonable, policy may be to disallow the exchange + ;; of scripts, like so: + ; DisallowExport ="LSLText" + ; DisallowImport ="LSLBytecode" + [HGFriendsModule] ; User level required to be able to send friendship invitations to foreign users ;LevelHGFriends = 0; diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index d5eb50d467..048710a368 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -53,7 +53,7 @@ [HGAssetService] HomeURI = "http://127.0.0.1:9000" - ;; The asset types that this service can export to / import from other grids. + ;; The asset types that this grid can export to / import from other grids. ;; Comma separated. ;; Valid values are all the asset types in OpenMetaverse.AssetType, namely: ;; Unknown, Texture, Sound, CallingCard, Landmark, Clothing, Object, Notecard, LSLText,