diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 8b9e749aa4..0f2ece7573 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -67,10 +67,25 @@ namespace OpenSim.Server.Handlers.Asset throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); + bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); + + AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; + + if (!allowDelete) + { + allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.None; + } + else + { + if (allowDeleteAllTypes) + allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.All; + else + allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; + } server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); + server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); MainConsole.Instance.Commands.AddCommand("Assets", false, "show asset", diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 9a8aee632c..986394bf59 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -42,18 +42,32 @@ using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset { + /// + /// Remote deletes allowed. + /// + public enum AllowedRemoteDeleteTypes + { + None, + MapTile, + All + } + public class AssetServerDeleteHandler : BaseStreamHandler { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; - protected bool m_allowDelete; - public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : + /// + /// Asset types that can be deleted remotely. + /// + private AllowedRemoteDeleteTypes m_allowedTypes; + + public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) : base("DELETE", "/assets") { m_AssetService = service; - m_allowDelete = allowDelete; + m_allowedTypes = allowedTypes; } public override byte[] Handle(string path, Stream request, @@ -63,19 +77,27 @@ namespace OpenSim.Server.Handlers.Asset string[] p = SplitParams(path); - if (p.Length > 0 && m_allowDelete) + if (p.Length > 0) { - string assetID = p[0]; + if (m_allowedTypes != AllowedRemoteDeleteTypes.None) + { + string assetID = p[0]; - AssetBase asset = m_AssetService.Get(assetID); - if (asset != null && (int)(asset.Flags & AssetFlags.Maptile) != 0) - { - result = m_AssetService.Delete(assetID); - } - else - { - m_log.DebugFormat( - "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but flags are not Maptile", assetID); + AssetBase asset = m_AssetService.Get(assetID); + if (asset != null) + { + if (m_allowedTypes == AllowedRemoteDeleteTypes.All + || (int)(asset.Flags & AssetFlags.Maptile) != 0) + { + result = m_AssetService.Delete(assetID); + } + else + { + m_log.DebugFormat( + "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}", + assetID, (AssetFlags)asset.Flags, m_allowedTypes); + } + } } } diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 6919b67dab..fb9a57500f 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -61,7 +61,19 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" AssetLoaderArgs = "./assets/AssetSets.xml" - AllowRemoteDelete = "false" + + ; Allow maptile assets to remotely deleted by remote calls to the asset service. + ; There is no harm in having this as false - it just means that historical maptile assets are not deleted. + ; This only applies to maptiles served via the version 1 viewer mechanisms + ; Default is false + AllowRemoteDelete = false + + ; Allow all assets to be remotely deleted. + ; Only set this to true if you are operating a grid where you control all calls to the asset service + ; (where a necessary condition is that you control all simulators) and you need this for admin purposes. + ; If set to true, AllowRemoteDelete = true is required as well. + ; Default is false. + AllowRemoteDeleteAllTypes = false ; * This configuration loads the inventory server modules. It duplicates ; * the function of the legacy inventory server