aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorOren Hurvitz2014-01-05 14:03:10 +0200
committerdahlia2014-01-20 00:38:44 -0800
commitd1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b (patch)
tree8bfd9347ad00c25d3c2734bf39f82b19e143f841 /OpenSim/Region/OptionalModules
parentWhen asked to change the Material for one face, change only that face; not th... (diff)
downloadopensim-SC_OLD-d1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b.zip
opensim-SC_OLD-d1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b.tar.gz
opensim-SC_OLD-d1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b.tar.bz2
opensim-SC_OLD-d1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b.tar.xz
Check agent permissions before modifying an object's materials. Also, when creating a Material asset, set the current agent as the Creator.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs31
1 files changed, 21 insertions, 10 deletions
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index 9779594..4b635d8 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -109,7 +109,10 @@ namespace OpenSim.Region.OptionalModules.Materials
109 string capsBase = "/CAPS/" + caps.CapsObjectPath; 109 string capsBase = "/CAPS/" + caps.CapsObjectPath;
110 110
111 IRequestHandler renderMaterialsPostHandler 111 IRequestHandler renderMaterialsPostHandler
112 = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); 112 = new RestStreamHandler("POST", capsBase + "/",
113 (request, path, param, httpRequest, httpResponse)
114 => RenderMaterialsPostCap(request, agentID),
115 "RenderMaterials", null);
113 caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); 116 caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler);
114 117
115 // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET 118 // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET
@@ -117,12 +120,18 @@ namespace OpenSim.Region.OptionalModules.Materials
117 // handler normally and then add a GET handler via MainServer 120 // handler normally and then add a GET handler via MainServer
118 121
119 IRequestHandler renderMaterialsGetHandler 122 IRequestHandler renderMaterialsGetHandler
120 = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); 123 = new RestStreamHandler("GET", capsBase + "/",
124 (request, path, param, httpRequest, httpResponse)
125 => RenderMaterialsGetCap(request),
126 "RenderMaterials", null);
121 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); 127 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler);
122 128
123 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well 129 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well
124 IRequestHandler renderMaterialsPutHandler 130 IRequestHandler renderMaterialsPutHandler
125 = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); 131 = new RestStreamHandler("PUT", capsBase + "/",
132 (request, path, param, httpRequest, httpResponse)
133 => RenderMaterialsPostCap(request, agentID),
134 "RenderMaterials", null);
126 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); 135 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
127 } 136 }
128 137
@@ -195,9 +204,7 @@ namespace OpenSim.Region.OptionalModules.Materials
195 } 204 }
196 } 205 }
197 206
198 public string RenderMaterialsPostCap(string request, string path, 207 public string RenderMaterialsPostCap(string request, UUID agentID)
199 string param, IOSHttpRequest httpRequest,
200 IOSHttpResponse httpResponse)
201 { 208 {
202 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 209 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
203 OSDMap resp = new OSDMap(); 210 OSDMap resp = new OSDMap();
@@ -295,6 +302,12 @@ namespace OpenSim.Region.OptionalModules.Materials
295 continue; 302 continue;
296 } 303 }
297 304
305 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
306 {
307 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
308 continue;
309 }
310
298 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); 311 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
299 if (te == null) 312 if (te == null)
300 { 313 {
@@ -326,7 +339,7 @@ namespace OpenSim.Region.OptionalModules.Materials
326 // This asset might exist already, but it's ok to try to store it again 339 // This asset might exist already, but it's ok to try to store it again
327 string name = "Material " + ChooseMaterialName(mat, sop); 340 string name = "Material " + ChooseMaterialName(mat, sop);
328 name = name.Substring(0, Math.Min(64, name.Length)).Trim(); 341 name = name.Substring(0, Math.Min(64, name.Length)).Trim();
329 AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, sop.OwnerID.ToString()); 342 AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString());
330 asset.Data = data; 343 asset.Data = data;
331 m_scene.AssetService.Store(asset); 344 m_scene.AssetService.Store(asset);
332 } 345 }
@@ -422,9 +435,7 @@ namespace OpenSim.Region.OptionalModules.Materials
422 } 435 }
423 436
424 437
425 public string RenderMaterialsGetCap(string request, string path, 438 public string RenderMaterialsGetCap(string request)
426 string param, IOSHttpRequest httpRequest,
427 IOSHttpResponse httpResponse)
428 { 439 {
429 OSDMap resp = new OSDMap(); 440 OSDMap resp = new OSDMap();
430 int matsCount = 0; 441 int matsCount = 0;