aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-02 01:41:38 +0000
committerJustin Clark-Casey (justincc)2012-11-02 01:41:38 +0000
commitce7beb6f20cb09e19e0f695f445cfa860b9e9c78 (patch)
tree1904f199f3abebbe756381f1627cb343368e3e31 /OpenSim/Server/Handlers
parentMove check to allow only deletion of maptiles up to AssetServerDeleteHandler ... (diff)
downloadopensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.zip
opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.gz
opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.bz2
opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.xz
Add [AssetService] AllowRemoteDeleteAllTypes (default false).
This allows a closed grid to delete asset types other than maptile remotely. Only operational if AllowRemoteDelete = true also. Defaults to false - do not enable if anybody other than you can make asset service requests.
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs17
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs50
2 files changed, 52 insertions, 15 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
43namespace OpenSim.Server.Handlers.Asset 43namespace 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