diff options
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 17 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | 50 | ||||
-rw-r--r-- | bin/Robust.ini.example | 14 |
3 files changed, 65 insertions, 16 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 4123f49..ff45d94 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -67,10 +67,25 @@ namespace OpenSim.Server.Handlers.Asset | |||
67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | 67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); |
68 | 68 | ||
69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); | 69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); |
70 | bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); | ||
71 | |||
72 | AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; | ||
73 | |||
74 | if (!allowDelete) | ||
75 | { | ||
76 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.None; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | if (allowDeleteAllTypes) | ||
81 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.All; | ||
82 | else | ||
83 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; | ||
84 | } | ||
70 | 85 | ||
71 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 86 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
72 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 87 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); |
73 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); | 88 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); |
74 | 89 | ||
75 | MainConsole.Instance.Commands.AddCommand("Assets", false, | 90 | MainConsole.Instance.Commands.AddCommand("Assets", false, |
76 | "show asset", | 91 | "show asset", |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 9a8aee6..986394b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -42,18 +42,32 @@ using OpenSim.Framework.Servers.HttpServer; | |||
42 | 42 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 43 | namespace OpenSim.Server.Handlers.Asset |
44 | { | 44 | { |
45 | /// <summary> | ||
46 | /// Remote deletes allowed. | ||
47 | /// </summary> | ||
48 | public enum AllowedRemoteDeleteTypes | ||
49 | { | ||
50 | None, | ||
51 | MapTile, | ||
52 | All | ||
53 | } | ||
54 | |||
45 | public class AssetServerDeleteHandler : BaseStreamHandler | 55 | public class AssetServerDeleteHandler : BaseStreamHandler |
46 | { | 56 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 58 | ||
49 | private IAssetService m_AssetService; | 59 | private IAssetService m_AssetService; |
50 | protected bool m_allowDelete; | ||
51 | 60 | ||
52 | public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : | 61 | /// <summary> |
62 | /// Asset types that can be deleted remotely. | ||
63 | /// </summary> | ||
64 | private AllowedRemoteDeleteTypes m_allowedTypes; | ||
65 | |||
66 | public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) : | ||
53 | base("DELETE", "/assets") | 67 | base("DELETE", "/assets") |
54 | { | 68 | { |
55 | m_AssetService = service; | 69 | m_AssetService = service; |
56 | m_allowDelete = allowDelete; | 70 | m_allowedTypes = allowedTypes; |
57 | } | 71 | } |
58 | 72 | ||
59 | public override byte[] Handle(string path, Stream request, | 73 | public override byte[] Handle(string path, Stream request, |
@@ -63,19 +77,27 @@ namespace OpenSim.Server.Handlers.Asset | |||
63 | 77 | ||
64 | string[] p = SplitParams(path); | 78 | string[] p = SplitParams(path); |
65 | 79 | ||
66 | if (p.Length > 0 && m_allowDelete) | 80 | if (p.Length > 0) |
67 | { | 81 | { |
68 | string assetID = p[0]; | 82 | if (m_allowedTypes != AllowedRemoteDeleteTypes.None) |
69 | |||
70 | AssetBase asset = m_AssetService.Get(assetID); | ||
71 | if (asset != null && (int)(asset.Flags & AssetFlags.Maptile) != 0) | ||
72 | { | ||
73 | result = m_AssetService.Delete(assetID); | ||
74 | } | ||
75 | else | ||
76 | { | 83 | { |
77 | m_log.DebugFormat( | 84 | string assetID = p[0]; |
78 | "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but flags are not Maptile", assetID); | 85 | |
86 | AssetBase asset = m_AssetService.Get(assetID); | ||
87 | if (asset != null) | ||
88 | { | ||
89 | if (m_allowedTypes == AllowedRemoteDeleteTypes.All | ||
90 | || (int)(asset.Flags & AssetFlags.Maptile) != 0) | ||
91 | { | ||
92 | result = m_AssetService.Delete(assetID); | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | m_log.DebugFormat( | ||
97 | "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}", | ||
98 | assetID, (AssetFlags)asset.Flags, m_allowedTypes); | ||
99 | } | ||
100 | } | ||
79 | } | 101 | } |
80 | } | 102 | } |
81 | 103 | ||
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 2eb551d..7503c5e 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -77,7 +77,19 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto | |||
77 | LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" | 77 | LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" |
78 | DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" | 78 | DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" |
79 | AssetLoaderArgs = "./assets/AssetSets.xml" | 79 | AssetLoaderArgs = "./assets/AssetSets.xml" |
80 | AllowRemoteDelete = "false" | 80 | |
81 | ; Allow maptile assets to remotely deleted by remote calls to the asset service. | ||
82 | ; There is no harm in having this as false - it just means that historical maptile assets are not deleted. | ||
83 | ; This only applies to maptiles served via the version 1 viewer mechanisms | ||
84 | ; Default is false | ||
85 | AllowRemoteDelete = false | ||
86 | |||
87 | ; Allow all assets to be remotely deleted. | ||
88 | ; Only set this to true if you are operating a grid where you control all calls to the asset service | ||
89 | ; (where a necessary condition is that you control all simulators) and you need this for admin purposes. | ||
90 | ; If set to true, AllowRemoteDelete = true is required as well. | ||
91 | ; Default is false. | ||
92 | AllowRemoteDeleteAllTypes = false | ||
81 | 93 | ||
82 | ; * This configuration loads the inventory server modules. It duplicates | 94 | ; * This configuration loads the inventory server modules. It duplicates |
83 | ; * the function of the legacy inventory server | 95 | ; * the function of the legacy inventory server |