aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs63
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs12
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs69
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs48
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs139
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs59
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs16
14 files changed, 294 insertions, 211 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 079d733..757e255 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -237,7 +237,7 @@ namespace OpenSim
237 string permissionModules = Util.GetConfigVarFromSections<string>(Config, "permissionmodules", 237 string permissionModules = Util.GetConfigVarFromSections<string>(Config, "permissionmodules",
238 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); 238 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule");
239 239
240 m_permsModules = new List<string>(permissionModules.Split(',')); 240 m_permsModules = new List<string>(permissionModules.Split(',').Select(m => m.Trim()));
241 241
242 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty); 242 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
243 managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty); 243 managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 67c847b..f1885da 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -212,6 +212,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
212 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 212 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
213 { 213 {
214 byte[] data = null; 214 byte[] data = null;
215 uint everyonemask = 0;
216 uint groupmask = 0;
215 217
216 if (invType == (sbyte)InventoryType.Landmark && presence != null) 218 if (invType == (sbyte)InventoryType.Landmark && presence != null)
217 { 219 {
@@ -220,6 +222,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
220 data = Encoding.ASCII.GetBytes(strdata); 222 data = Encoding.ASCII.GetBytes(strdata);
221 name = prefix + name; 223 name = prefix + name;
222 description += suffix; 224 description += suffix;
225 groupmask = (uint)PermissionMask.AllAndExport;
226 everyonemask = (uint)(PermissionMask.AllAndExport & ~PermissionMask.Modify);
223 } 227 }
224 228
225 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); 229 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
@@ -227,9 +231,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
227 m_Scene.CreateNewInventoryItem( 231 m_Scene.CreateNewInventoryItem(
228 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 232 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
229 name, description, 0, callbackID, asset.FullID, asset.Type, invType, 233 name, description, 0, callbackID, asset.FullID, asset.Type, invType,
230 (uint)PermissionMask.All | (uint)PermissionMask.Export, // Base 234 (uint)PermissionMask.AllAndExport, // Base
231 (uint)PermissionMask.All | (uint)PermissionMask.Export, // Current 235 (uint)PermissionMask.AllAndExport, // Current
232 0, nextOwnerMask, 0, creationDate, false); // Data from viewer 236 everyonemask,
237 nextOwnerMask, groupmask, creationDate, false); // Data from viewer
233 } 238 }
234 else 239 else
235 { 240 {
@@ -573,41 +578,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
573 InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, 578 InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions,
574 IClientAPI remoteClient) 579 IClientAPI remoteClient)
575 { 580 {
576 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; 581 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export | PermissionMask.FoldedMask);
577 uint allObjectsNextOwnerPerms = 0x7fffffff; 582
578
579 // For the porposes of inventory, an object is modify if the prims
580 // are modify. This allows renaming an object that contains no
581 // mod items.
582 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 583 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
583 { 584 {
584 uint groupPerms = grp.GetEffectivePermissions(true); 585 effectivePerms &= grp.CurrentAndFoldedNextPermissions();
585 if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0)
586 groupPerms |= (uint)PermissionMask.Modify;
587
588 effectivePerms &= groupPerms;
589 } 586 }
590 effectivePerms |= (uint)PermissionMask.Move; 587
591
592 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 588 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
593 { 589 {
594 uint perms = effectivePerms; 590 // apply parts inventory items next owner
595 uint nextPerms = (perms & 7) << 13; 591 PermissionsUtil.ApplyNoModFoldedPermissions(effectivePerms, ref effectivePerms);
596 if ((nextPerms & (uint)PermissionMask.Copy) == 0) 592 // change to next owner
597 perms &= ~(uint)PermissionMask.Copy; 593 uint basePerms = effectivePerms & so.RootPart.NextOwnerMask;
598 if ((nextPerms & (uint)PermissionMask.Transfer) == 0) 594 // fix and update folded
599 perms &= ~(uint)PermissionMask.Transfer; 595 basePerms = PermissionsUtil.FixAndFoldPermissions(basePerms);
600 if ((nextPerms & (uint)PermissionMask.Modify) == 0) 596
601 perms &= ~(uint)PermissionMask.Modify; 597 item.BasePermissions = basePerms;
602 598 item.CurrentPermissions = basePerms;
603// item.BasePermissions = perms & so.RootPart.NextOwnerMask; 599 item.NextPermissions = basePerms & so.RootPart.NextOwnerMask;
604 600 item.EveryOnePermissions = basePerms & so.RootPart.EveryoneMask;
605 uint nextp = so.RootPart.NextOwnerMask | (uint)PermissionMask.FoldedMask; 601 item.GroupPermissions = basePerms & so.RootPart.GroupMask;
606 item.BasePermissions = perms & nextp;
607 item.CurrentPermissions = item.BasePermissions;
608 item.NextPermissions = perms & so.RootPart.NextOwnerMask;
609 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
610 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
611 602
612 // apply next owner perms on rez 603 // apply next owner perms on rez
613 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 604 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
@@ -626,7 +617,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
626 (uint)PermissionMask.Modify | 617 (uint)PermissionMask.Modify |
627 (uint)PermissionMask.Move | 618 (uint)PermissionMask.Move |
628 (uint)PermissionMask.Export | 619 (uint)PermissionMask.Export |
629 7); // Preserve folded permissions 620 (uint)PermissionMask.FoldedMask); // Preserve folded permissions ??
630 } 621 }
631 622
632 return item; 623 return item;
@@ -1144,9 +1135,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1144 if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0) 1135 if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0)
1145 { 1136 {
1146 // We have permissions stored there so use them 1137 // We have permissions stored there so use them
1147 part.NextOwnerMask = ((item.BasePermissions & 7) << 13); 1138 part.NextOwnerMask = ((item.BasePermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift);
1148 if ((item.BasePermissions & (uint)PermissionMask.FoldedExport) != 0)
1149 part.NextOwnerMask |= (uint)PermissionMask.Export;
1150 part.NextOwnerMask |= (uint)PermissionMask.Move; 1139 part.NextOwnerMask |= (uint)PermissionMask.Move;
1151 } 1140 }
1152 else 1141 else
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index 09891f7..035097f 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -223,20 +223,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
223 if (parms.Length - i < 2) 223 if (parms.Length - i < 2)
224 break; 224 break;
225 225
226 //Have we reached the end of the list of headers?
227 //End is marked by a string with a single digit.
228 //We already know we have at least one parameter
229 //so it is safe to do this check at top of loop.
230 if (Char.IsDigit(parms[i][0]))
231 break;
232
233 if (htc.HttpCustomHeaders == null) 226 if (htc.HttpCustomHeaders == null)
234 htc.HttpCustomHeaders = new List<string>(); 227 htc.HttpCustomHeaders = new List<string>();
235 228
236 htc.HttpCustomHeaders.Add(parms[i]); 229 htc.HttpCustomHeaders.Add(parms[i]);
237 htc.HttpCustomHeaders.Add(parms[i+1]); 230 htc.HttpCustomHeaders.Add(parms[i+1]);
231 int nexti = i + 2;
232 if (nexti >= parms.Length || Char.IsDigit(parms[nexti][0]))
233 break;
238 234
239 i += 2; 235 i = nexti;
240 } 236 }
241 break; 237 break;
242 238
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 290daa9..66ebdbe 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -26,15 +26,15 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Threading;
30using System.Collections.Generic; 29using System.Collections.Generic;
31using System.Collections; 30using System.Collections;
32using System.Reflection; 31using System.Reflection;
32using System.Net;
33using System.Net.Sockets;
33using log4net; 34using log4net;
34using Mono.Addins; 35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
@@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
89 protected Dictionary<string, UrlData> m_UrlMap = 89 protected Dictionary<string, UrlData> m_UrlMap =
90 new Dictionary<string, UrlData>(); 90 new Dictionary<string, UrlData>();
91 91
92 protected bool m_enabled = false;
93 protected string m_ErrorStr;
92 protected uint m_HttpsPort = 0; 94 protected uint m_HttpsPort = 0;
93 protected IHttpServer m_HttpServer = null; 95 protected IHttpServer m_HttpServer = null;
94 protected IHttpServer m_HttpsServer = null; 96 protected IHttpServer m_HttpsServer = null;
@@ -118,6 +120,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
118 public void Initialise(IConfigSource config) 120 public void Initialise(IConfigSource config)
119 { 121 {
120 IConfig networkConfig = config.Configs["Network"]; 122 IConfig networkConfig = config.Configs["Network"];
123 m_enabled = false;
121 124
122 if (networkConfig != null) 125 if (networkConfig != null)
123 { 126 {
@@ -128,9 +131,47 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
128 if (ssl_enabled) 131 if (ssl_enabled)
129 m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort); 132 m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort);
130 } 133 }
134 else
135 {
136 m_ErrorStr = "[Network] configuration missing, HTTP listener for LSL disabled";
137 m_log.Warn("[URL MODULE]: " + m_ErrorStr);
138 return;
139 }
140
141 if (String.IsNullOrWhiteSpace(ExternalHostNameForLSL))
142 {
143 m_ErrorStr = "ExternalHostNameForLSL not defined in configuration, HTTP listener for LSL disabled";
144 m_log.Warn("[URL MODULE]: " + m_ErrorStr);
145 return;
146 }
147
148 IPAddress ia = null;
149 try
150 {
151 foreach (IPAddress Adr in Dns.GetHostAddresses(ExternalHostNameForLSL))
152 {
153 if (Adr.AddressFamily == AddressFamily.InterNetwork ||
154 Adr.AddressFamily == AddressFamily.InterNetworkV6) // ipv6 will most likely smoke
155 {
156 ia = Adr;
157 break;
158 }
159 }
160 }
161 catch
162 {
163 ia = null;
164 }
131 165
132 if (ExternalHostNameForLSL == null) 166 if (ia == null)
133 ExternalHostNameForLSL = System.Environment.MachineName; 167 {
168 m_ErrorStr = "Could not resolve ExternalHostNameForLSL, HTTP listener for LSL disabled";
169 m_log.Warn("[URL MODULE]: " + m_ErrorStr);
170 return;
171 }
172
173 m_enabled = true;
174 m_ErrorStr = String.Empty;
134 175
135 IConfig llFunctionsConfig = config.Configs["LL-Functions"]; 176 IConfig llFunctionsConfig = config.Configs["LL-Functions"];
136 177
@@ -146,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
146 187
147 public void AddRegion(Scene scene) 188 public void AddRegion(Scene scene)
148 { 189 {
149 if (m_HttpServer == null) 190 if (m_enabled && m_HttpServer == null)
150 { 191 {
151 // There can only be one 192 // There can only be one
152 // 193 //
@@ -197,11 +238,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
197 { 238 {
198 UUID urlcode = UUID.Random(); 239 UUID urlcode = UUID.Random();
199 240
241 if(!m_enabled)
242 {
243 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
244 return urlcode;
245 }
246
200 lock (m_UrlMap) 247 lock (m_UrlMap)
201 { 248 {
202 if (m_UrlMap.Count >= TotalUrls) 249 if (m_UrlMap.Count >= TotalUrls)
203 { 250 {
204 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 251 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
252 "Too many URLs already open" });
205 return urlcode; 253 return urlcode;
206 } 254 }
207 string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 255 string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
@@ -243,6 +291,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
243 { 291 {
244 UUID urlcode = UUID.Random(); 292 UUID urlcode = UUID.Random();
245 293
294 if(!m_enabled)
295 {
296 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
297 return urlcode;
298 }
299
246 if (m_HttpsServer == null) 300 if (m_HttpsServer == null)
247 { 301 {
248 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 302 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
@@ -253,7 +307,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
253 { 307 {
254 if (m_UrlMap.Count >= TotalUrls) 308 if (m_UrlMap.Count >= TotalUrls)
255 { 309 {
256 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 310 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
311 "Too many URLs already open" });
257 return urlcode; 312 return urlcode;
258 } 313 }
259 string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; 314 string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/";
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 660e03f..a5203ea 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
113 // wrap this in a try block so that defaults will work if 113 // wrap this in a try block so that defaults will work if
114 // the config file doesn't specify otherwise. 114 // the config file doesn't specify otherwise.
115 int maxlisteners = 1000; 115 int maxlisteners = 1000;
116 int maxhandles = 64; 116 int maxhandles = 65;
117 try 117 try
118 { 118 {
119 m_whisperdistance = config.Configs["Chat"].GetInt( 119 m_whisperdistance = config.Configs["Chat"].GetInt(
@@ -130,8 +130,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
130 catch (Exception) 130 catch (Exception)
131 { 131 {
132 } 132 }
133 if (maxlisteners < 1) maxlisteners = int.MaxValue; 133
134 if (maxhandles < 1) maxhandles = int.MaxValue; 134 if (maxlisteners < 1)
135 maxlisteners = int.MaxValue;
136 if (maxhandles < 1)
137 maxhandles = int.MaxValue;
138
139 if (maxlisteners < maxhandles)
140 maxlisteners = maxhandles;
141
135 m_listenerManager = new ListenerManager(maxlisteners, maxhandles); 142 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
136 m_pendingQ = new Queue(); 143 m_pendingQ = new Queue();
137 m_pending = Queue.Synchronized(m_pendingQ); 144 m_pending = Queue.Synchronized(m_pendingQ);
@@ -605,11 +612,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
605 li.GetHandle().Equals(handle)) 612 li.GetHandle().Equals(handle))
606 { 613 {
607 lis.Value.Remove(li); 614 lis.Value.Remove(li);
615 m_curlisteners--;
608 if (lis.Value.Count == 0) 616 if (lis.Value.Count == 0)
609 { 617 m_listeners.Remove(lis.Key); // bailing of loop so this does not smoke
610 m_listeners.Remove(lis.Key);
611 m_curlisteners--;
612 }
613 // there should be only one, so we bail out early 618 // there should be only one, so we bail out early
614 return; 619 return;
615 } 620 }
@@ -718,6 +723,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
718 } 723 }
719 } 724 }
720 725
726 if(handles.Count >= m_maxhandles)
727 return -1;
728
721 // Note: 0 is NOT a valid handle for llListen() to return 729 // Note: 0 is NOT a valid handle for llListen() to return
722 for (int i = 1; i <= m_maxhandles; i++) 730 for (int i = 1; i <= m_maxhandles; i++)
723 { 731 {
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 90d65c7..a7a9d1d 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -118,6 +118,11 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
118 return false; 118 return false;
119 119
120 SceneObjectGroup group = part.ParentGroup; 120 SceneObjectGroup group = part.ParentGroup;
121 if(group == null || group.IsDeleted || group.inTransit)
122 return false;
123
124 // make sure we are not buying a child part
125 part = group.RootPart;
121 126
122 switch (saleType) 127 switch (saleType)
123 { 128 {
@@ -157,18 +162,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
157 break; 162 break;
158 163
159 case 2: // Sell a copy 164 case 2: // Sell a copy
160 Vector3 inventoryStoredPosition = new Vector3(
161 Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6),
162 Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
163 group.AbsolutePosition.Z);
164
165 Vector3 originalPosition = group.AbsolutePosition;
166
167 group.AbsolutePosition = inventoryStoredPosition;
168
169 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
170 group.AbsolutePosition = originalPosition;
171
172 uint perms = group.EffectiveOwnerPerms; 165 uint perms = group.EffectiveOwnerPerms;
173 166
174 if ((perms & (uint)PermissionMask.Transfer) == 0) 167 if ((perms & (uint)PermissionMask.Transfer) == 0)
@@ -185,6 +178,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
185 return false; 178 return false;
186 } 179 }
187 180
181 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
182
188 AssetBase asset = m_scene.CreateAsset( 183 AssetBase asset = m_scene.CreateAsset(
189 group.GetPartName(localID), 184 group.GetPartName(localID),
190 group.GetPartDescription(localID), 185 group.GetPartDescription(localID),
@@ -205,22 +200,21 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
205 item.AssetType = asset.Type; 200 item.AssetType = asset.Type;
206 item.InvType = (int)InventoryType.Object; 201 item.InvType = (int)InventoryType.Object;
207 item.Folder = categoryID; 202 item.Folder = categoryID;
203
204 perms = group.CurrentAndFoldedNextPermissions();
205 // apply parts inventory next perms
206 PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms);
207 // change to next owner perms
208 perms &= part.NextOwnerMask;
209 // update folded
210 perms = PermissionsUtil.FixAndFoldPermissions(perms);
211
212 item.BasePermissions = perms;
213 item.CurrentPermissions = perms;
214 item.NextPermissions = part.NextOwnerMask & perms;
215 item.EveryOnePermissions = part.EveryoneMask & perms;
216 item.GroupPermissions = part.GroupMask & perms;
208 217
209 uint nextPerms=(perms & 7) << 13;
210 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
211 perms &= ~(uint)PermissionMask.Copy;
212 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
213 perms &= ~(uint)PermissionMask.Transfer;
214 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
215 perms &= ~(uint)PermissionMask.Modify;
216
217 item.BasePermissions = perms & part.NextOwnerMask;
218 item.CurrentPermissions = perms & part.NextOwnerMask;
219 item.NextPermissions = part.NextOwnerMask;
220 item.EveryOnePermissions = part.EveryoneMask &
221 part.NextOwnerMask;
222 item.GroupPermissions = part.GroupMask &
223 part.NextOwnerMask;
224 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 218 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
225 item.CreationDate = Util.UnixTimeSinceEpoch(); 219 item.CreationDate = Util.UnixTimeSinceEpoch();
226 220
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 8eee864..18d164f 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -2022,7 +2022,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2022 2022
2023 uint perms = GetObjectPermissions(sp, sog, true); 2023 uint perms = GetObjectPermissions(sp, sog, true);
2024 if((perms & (uint)PermissionMask.Copy) == 0) 2024 if((perms & (uint)PermissionMask.Copy) == 0)
2025 {
2026 sp.ControllingClient.SendAgentAlertMessage("Copying this item has been denied by the permissions system", false);
2025 return false; 2027 return false;
2028 }
2026 2029
2027 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0) 2030 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
2028 return false; 2031 return false;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 2f016fa..afdd99e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -682,30 +682,26 @@ namespace OpenSim.Region.Framework.Scenes
682 // These will be applied to the root prim at next rez. 682 // These will be applied to the root prim at next rez.
683 // The legacy slam bit (bit 3) and folded permission (bits 0-2) 683 // The legacy slam bit (bit 3) and folded permission (bits 0-2)
684 // are preserved due to the above mangling 684 // are preserved due to the above mangling
685 ownerPerms &= nextPerms; 685// ownerPerms &= nextPerms;
686 686
687 // Mask the base permissions. This is a conservative 687 // Mask the base permissions. This is a conservative
688 // approach altering only the three main perms 688 // approach altering only the three main perms
689 basePerms &= nextPerms; 689// basePerms &= nextPerms;
690 690
691 // Mask out the folded portion of the base mask. 691 // Mask out the folded portion of the base mask.
692 // While the owner mask carries the actual folded 692 // While the owner mask carries the actual folded
693 // permissions, the base mask carries the original 693 // permissions, the base mask carries the original
694 // base mask, before masking with the folded perms. 694 // base mask, before masking with the folded perms.
695 // We need this later for rezzing. 695 // We need this later for rezzing.
696 basePerms &= ~(uint)PermissionMask.FoldedMask; 696// basePerms &= ~(uint)PermissionMask.FoldedMask;
697 basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0); 697// basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
698 698
699 // If this is an object, root prim perms may be more 699 // If this is an object, root prim perms may be more
700 // permissive than folded perms. Use folded perms as 700 // permissive than folded perms. Use folded perms as
701 // a mask 701 // a mask
702 if (item.InvType == (int)InventoryType.Object) 702 uint foldedPerms = (item.CurrentPermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift;
703 if (foldedPerms != 0 && item.InvType == (int)InventoryType.Object)
703 { 704 {
704 // Create a safe mask for the current perms
705 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
706 if ((item.CurrentPermissions & (uint)PermissionMask.FoldedExport) != 0)
707 foldedPerms |= (uint)PermissionMask.Export;
708
709 foldedPerms |= permsMask; 705 foldedPerms |= permsMask;
710 706
711 bool isRootMod = (item.CurrentPermissions & 707 bool isRootMod = (item.CurrentPermissions &
@@ -729,6 +725,11 @@ namespace OpenSim.Region.Framework.Scenes
729 } 725 }
730 } 726 }
731 727
728 // move here so nextperms are mandatory
729 ownerPerms &= nextPerms;
730 basePerms &= nextPerms;
731 basePerms &= ~(uint)PermissionMask.FoldedMask;
732 basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
732 // Assign to the actual item. Make sure the slam bit is 733 // Assign to the actual item. Make sure the slam bit is
733 // set, if it wasn't set before. 734 // set, if it wasn't set before.
734 itemCopy.BasePermissions = basePerms; 735 itemCopy.BasePermissions = basePerms;
@@ -1266,20 +1267,26 @@ namespace OpenSim.Region.Framework.Scenes
1266 // TODO: Fix this after the inventory fixer exists and has beenr run 1267 // TODO: Fix this after the inventory fixer exists and has beenr run
1267 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions()) 1268 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
1268 { 1269 {
1269 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1270 uint perms = taskItem.BasePermissions & taskItem.NextPermissions;
1270 if (taskItem.InvType == (int)InventoryType.Object) 1271 if (taskItem.InvType == (int)InventoryType.Object)
1271 agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move)); 1272 {
1273 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms );
1274 perms = PermissionsUtil.FixAndFoldPermissions(perms);
1275 }
1272 else 1276 else
1273 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 1277 perms &= taskItem.CurrentPermissions;
1274 1278
1275 agentItem.BasePermissions = agentItem.CurrentPermissions; 1279 // always unlock
1276 1280 perms |= (uint)PermissionMask.Move;
1281
1282 agentItem.BasePermissions = perms;
1283 agentItem.CurrentPermissions = perms;
1284 agentItem.NextPermissions = perms & taskItem.NextPermissions;
1285 agentItem.EveryOnePermissions = perms & taskItem.EveryonePermissions;
1286 agentItem.GroupPermissions = perms & taskItem.GroupPermissions;
1287
1277 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 1288 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
1278 agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner); 1289 agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
1279 agentItem.NextPermissions = taskItem.NextPermissions;
1280 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
1281 // Group permissions make no sense here
1282 agentItem.GroupPermissions = 0;
1283 } 1290 }
1284 else 1291 else
1285 { 1292 {
@@ -1287,7 +1294,7 @@ namespace OpenSim.Region.Framework.Scenes
1287 agentItem.CurrentPermissions = taskItem.CurrentPermissions; 1294 agentItem.CurrentPermissions = taskItem.CurrentPermissions;
1288 agentItem.NextPermissions = taskItem.NextPermissions; 1295 agentItem.NextPermissions = taskItem.NextPermissions;
1289 agentItem.EveryOnePermissions = taskItem.EveryonePermissions; 1296 agentItem.EveryOnePermissions = taskItem.EveryonePermissions;
1290 agentItem.GroupPermissions = 0; 1297 agentItem.GroupPermissions = taskItem.GroupPermissions;
1291 } 1298 }
1292 1299
1293 message = null; 1300 message = null;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 12e53a8..36844a9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -252,18 +252,26 @@ namespace OpenSim.Region.Framework.Scenes
252 } 252 }
253 253
254 // new test code, to place in better place later 254 // new test code, to place in better place later
255 private object PermissionsLock = new object(); 255 private object m_PermissionsLock = new object();
256 private bool m_EffectivePermsInvalid = true;
257
258 public void InvalidateEffectivePerms()
259 {
260 lock(m_PermissionsLock)
261 m_EffectivePermsInvalid = true;
262 }
256 263
257 private uint m_EffectiveEveryOnePerms; 264 private uint m_EffectiveEveryOnePerms;
258 public uint EffectiveEveryOnePerms 265 public uint EffectiveEveryOnePerms
259 { 266 {
260 get 267 get
261 { 268 {
262 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) 269 lock(m_PermissionsLock)
263 // bc this is on heavy duty code paths 270 {
264 // but for now we need to test the concept 271 if(m_EffectivePermsInvalid)
265// AggregateDeepPerms(); 272 AggregatePerms();
266 return m_EffectiveEveryOnePerms; 273 return m_EffectiveEveryOnePerms;
274 }
267 } 275 }
268 } 276 }
269 277
@@ -272,11 +280,12 @@ namespace OpenSim.Region.Framework.Scenes
272 { 280 {
273 get 281 get
274 { 282 {
275 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) 283 lock(m_PermissionsLock)
276 // bc this is on heavy duty code paths 284 {
277 // but for now we need to test the concept 285 if(m_EffectivePermsInvalid)
278// AggregateDeepPerms(); 286 AggregatePerms();
279 return m_EffectiveGroupPerms; 287 return m_EffectiveGroupPerms;
288 }
280 } 289 }
281 } 290 }
282 291
@@ -285,11 +294,12 @@ namespace OpenSim.Region.Framework.Scenes
285 { 294 {
286 get 295 get
287 { 296 {
288 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) 297 lock(m_PermissionsLock)
289 // bc this is on heavy duty code paths 298 {
290 // but for now we need to test the concept 299 if(m_EffectivePermsInvalid)
291// AggregateDeepPerms(); 300 AggregatePerms();
292 return m_EffectiveGroupOrEveryOnePerms; 301 return m_EffectiveGroupOrEveryOnePerms;
302 }
293 } 303 }
294 } 304 }
295 305
@@ -298,11 +308,12 @@ namespace OpenSim.Region.Framework.Scenes
298 { 308 {
299 get 309 get
300 { 310 {
301 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) 311 lock(m_PermissionsLock)
302 // bc this is on heavy duty code paths 312 {
303 // but for now we need to test the concept 313 if(m_EffectivePermsInvalid)
304 // AggregateDeepPerms(); 314 AggregatePerms();
305 return m_EffectiveOwnerPerms; 315 return m_EffectiveOwnerPerms;
316 }
306 } 317 }
307 } 318 }
308 319
@@ -310,12 +321,12 @@ namespace OpenSim.Region.Framework.Scenes
310 // AggregatePerms does same using cached parts content perms 321 // AggregatePerms does same using cached parts content perms
311 public void AggregateDeepPerms() 322 public void AggregateDeepPerms()
312 { 323 {
313 lock(PermissionsLock) 324 lock(m_PermissionsLock)
314 { 325 {
315 // aux 326 // aux
316 const uint allmask = (uint)PermissionMask.AllEffective; 327 const uint allmask = (uint)PermissionMask.AllEffective;
317 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); 328 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
318 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); 329 const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
319 330
320 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; 331 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
321 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; 332 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
@@ -327,6 +338,8 @@ namespace OpenSim.Region.Framework.Scenes
327 uint rootEveryonePerms = RootPart.EveryoneMask; 338 uint rootEveryonePerms = RootPart.EveryoneMask;
328 uint everyone = rootEveryonePerms; 339 uint everyone = rootEveryonePerms;
329 340
341 // date is time of writing april 30th 2017
342 bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
330 SceneObjectPart[] parts = m_parts.GetArray(); 343 SceneObjectPart[] parts = m_parts.GetArray();
331 for (int i = 0; i < parts.Length; i++) 344 for (int i = 0; i < parts.Length; i++)
332 { 345 {
@@ -334,12 +347,13 @@ namespace OpenSim.Region.Framework.Scenes
334 part.AggregateInnerPerms(); 347 part.AggregateInnerPerms();
335 owner &= part.AggregatedInnerOwnerPerms; 348 owner &= part.AggregatedInnerOwnerPerms;
336 group &= part.AggregatedInnerGroupPerms; 349 group &= part.AggregatedInnerGroupPerms;
337 everyone &= part.AggregatedInnerEveryonePerms; 350 if(newObject)
351 everyone &= part.AggregatedInnerEveryonePerms;
338 } 352 }
339 // recover modify and move 353 // recover modify and move
340 rootOwnerPerms &= movemodmask; 354 rootOwnerPerms &= movemodmask;
341 owner |= rootOwnerPerms; 355 owner |= rootOwnerPerms;
342 if((owner & copytransfermast) == 0) 356 if((owner & copytransfermask) == 0)
343 owner |= (uint)PermissionMask.Transfer; 357 owner |= (uint)PermissionMask.Transfer;
344 358
345 owner &= basePerms; 359 owner &= basePerms;
@@ -370,6 +384,7 @@ namespace OpenSim.Region.Framework.Scenes
370 384
371 m_EffectiveEveryOnePerms = everyone & owner; 385 m_EffectiveEveryOnePerms = everyone & owner;
372 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; 386 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
387 m_EffectivePermsInvalid = false;
373 } 388 }
374 } 389 }
375 390
@@ -377,7 +392,7 @@ namespace OpenSim.Region.Framework.Scenes
377 // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop 392 // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop
378 public void AggregatePerms() 393 public void AggregatePerms()
379 { 394 {
380 lock(PermissionsLock) 395 lock(m_PermissionsLock)
381 { 396 {
382 // aux 397 // aux
383 const uint allmask = (uint)PermissionMask.AllEffective; 398 const uint allmask = (uint)PermissionMask.AllEffective;
@@ -394,13 +409,17 @@ namespace OpenSim.Region.Framework.Scenes
394 uint rootEveryonePerms = RootPart.EveryoneMask; 409 uint rootEveryonePerms = RootPart.EveryoneMask;
395 uint everyone = rootEveryonePerms; 410 uint everyone = rootEveryonePerms;
396 411
412 bool needUpdate = false;
413 // date is time of writing april 30th 2017
414 bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
397 SceneObjectPart[] parts = m_parts.GetArray(); 415 SceneObjectPart[] parts = m_parts.GetArray();
398 for (int i = 0; i < parts.Length; i++) 416 for (int i = 0; i < parts.Length; i++)
399 { 417 {
400 SceneObjectPart part = parts[i]; 418 SceneObjectPart part = parts[i];
401 owner &= part.AggregatedInnerOwnerPerms; 419 owner &= part.AggregatedInnerOwnerPerms;
402 group &= part.AggregatedInnerGroupPerms; 420 group &= part.AggregatedInnerGroupPerms;
403 everyone &= part.AggregatedInnerEveryonePerms; 421 if(newObject)
422 everyone &= part.AggregatedInnerEveryonePerms;
404 } 423 }
405 // recover modify and move 424 // recover modify and move
406 rootOwnerPerms &= movemodmask; 425 rootOwnerPerms &= movemodmask;
@@ -409,7 +428,12 @@ namespace OpenSim.Region.Framework.Scenes
409 owner |= (uint)PermissionMask.Transfer; 428 owner |= (uint)PermissionMask.Transfer;
410 429
411 owner &= basePerms; 430 owner &= basePerms;
412 m_EffectiveOwnerPerms = owner; 431 if(owner != m_EffectiveOwnerPerms)
432 {
433 needUpdate = true;
434 m_EffectiveOwnerPerms = owner;
435 }
436
413 uint ownertransfermask = owner & (uint)PermissionMask.Transfer; 437 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
414 438
415 // recover modify and move 439 // recover modify and move
@@ -421,7 +445,12 @@ namespace OpenSim.Region.Framework.Scenes
421 group |= ownertransfermask; 445 group |= ownertransfermask;
422 446
423 uint groupOrEveryone = group; 447 uint groupOrEveryone = group;
424 m_EffectiveGroupPerms = group & owner; 448 uint tmpPerms = group & owner;
449 if(tmpPerms != m_EffectiveGroupPerms)
450 {
451 needUpdate = true;
452 m_EffectiveGroupPerms = tmpPerms;
453 }
425 454
426 // recover move 455 // recover move
427 rootEveryonePerms &= (uint)PermissionMask.Move; 456 rootEveryonePerms &= (uint)PermissionMask.Move;
@@ -434,35 +463,42 @@ namespace OpenSim.Region.Framework.Scenes
434 463
435 groupOrEveryone |= everyone; 464 groupOrEveryone |= everyone;
436 465
437 m_EffectiveEveryOnePerms = everyone & owner; 466 tmpPerms = everyone & owner;
438 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; 467 if(tmpPerms != m_EffectiveEveryOnePerms)
439 } 468 {
440 } 469 needUpdate = true;
470 m_EffectiveEveryOnePerms = tmpPerms;
471 }
441 472
442 public uint GetEffectivePermissions() 473 tmpPerms = groupOrEveryone & owner;
443 { 474 if(tmpPerms != m_EffectiveGroupOrEveryOnePerms)
444 return GetEffectivePermissions(false); 475 {
476 needUpdate = true;
477 m_EffectiveGroupOrEveryOnePerms = tmpPerms;
478 }
479
480 m_EffectivePermsInvalid = false;
481
482 if(needUpdate)
483 RootPart.ScheduleFullUpdate();
484 }
445 } 485 }
446 486
447 public uint GetEffectivePermissions(bool useBase) 487 public uint CurrentAndFoldedNextPermissions()
448 { 488 {
449 uint perms=(uint)(PermissionMask.Modify | 489 uint perms=(uint)(PermissionMask.Modify |
450 PermissionMask.Copy | 490 PermissionMask.Copy |
451 PermissionMask.Move | 491 PermissionMask.Move |
452 PermissionMask.Transfer) | 7; 492 PermissionMask.Transfer |
493 PermissionMask.FoldedMask);
453 494
454 uint ownerMask = 0x7fffffff; 495 uint ownerMask = RootPart.OwnerMask;
455 496
456 SceneObjectPart[] parts = m_parts.GetArray(); 497 SceneObjectPart[] parts = m_parts.GetArray();
457 for (int i = 0; i < parts.Length; i++) 498 for (int i = 0; i < parts.Length; i++)
458 { 499 {
459 SceneObjectPart part = parts[i]; 500 SceneObjectPart part = parts[i];
460 501 ownerMask &= part.BaseMask;
461 if (useBase)
462 ownerMask &= part.BaseMask;
463 else
464 ownerMask &= part.OwnerMask;
465
466 perms &= part.Inventory.MaskEffectivePermissions(); 502 perms &= part.Inventory.MaskEffectivePermissions();
467 } 503 }
468 504
@@ -472,17 +508,8 @@ namespace OpenSim.Region.Framework.Scenes
472 perms &= ~(uint)PermissionMask.Copy; 508 perms &= ~(uint)PermissionMask.Copy;
473 if ((ownerMask & (uint)PermissionMask.Transfer) == 0) 509 if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
474 perms &= ~(uint)PermissionMask.Transfer; 510 perms &= ~(uint)PermissionMask.Transfer;
475 511 if ((ownerMask & (uint)PermissionMask.Export) == 0)
476 // If root prim permissions are applied here, this would screw 512 perms &= ~(uint)PermissionMask.Export;
477 // with in-inventory manipulation of the next owner perms
478 // in a major way. So, let's move this to the give itself.
479 // Yes. I know. Evil.
480// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
481// perms &= ~((uint)PermissionMask.Modify >> 13);
482// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
483// perms &= ~((uint)PermissionMask.Copy >> 13);
484// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
485// perms &= ~((uint)PermissionMask.Transfer >> 13);
486 513
487 return perms; 514 return perms;
488 } 515 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 19bf53f..f948336 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2579,6 +2579,8 @@ namespace OpenSim.Region.Framework.Scenes
2579 AggregatedInnerOwnerPerms = owner & mask; 2579 AggregatedInnerOwnerPerms = owner & mask;
2580 AggregatedInnerGroupPerms = group & mask; 2580 AggregatedInnerGroupPerms = group & mask;
2581 AggregatedInnerEveryonePerms = everyone & mask; 2581 AggregatedInnerEveryonePerms = everyone & mask;
2582 if(ParentGroup != null)
2583 ParentGroup.InvalidateEffectivePerms();
2582 } 2584 }
2583 } 2585 }
2584 2586
@@ -5286,9 +5288,9 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5286 // Export needs to be preserved in the base and everyone 5288 // Export needs to be preserved in the base and everyone
5287 // mask, but removed in the owner mask as a next owner 5289 // mask, but removed in the owner mask as a next owner
5288 // can never change the export status 5290 // can never change the export status
5289 BaseMask &= NextOwnerMask | (uint)PermissionMask.Export; 5291 BaseMask &= (NextOwnerMask | (uint)PermissionMask.Export);
5290 OwnerMask &= NextOwnerMask; 5292 OwnerMask &= NextOwnerMask;
5291 EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export; 5293 EveryoneMask &= (NextOwnerMask | (uint)PermissionMask.Export);
5292 GroupMask = 0; // Giving an object zaps group permissions 5294 GroupMask = 0; // Giving an object zaps group permissions
5293 5295
5294 Inventory.ApplyNextOwnerPermissions(); 5296 Inventory.ApplyNextOwnerPermissions();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index b53c355..8c9d0bb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1332,6 +1332,8 @@ namespace OpenSim.Region.Framework.Scenes
1332 { 1332 {
1333 foreach (TaskInventoryItem item in m_items.Values) 1333 foreach (TaskInventoryItem item in m_items.Values)
1334 { 1334 {
1335 if(item.InvType == (sbyte)InventoryType.Landmark)
1336 continue;
1335 owner &= item.CurrentPermissions; 1337 owner &= item.CurrentPermissions;
1336 group &= item.GroupPermissions; 1338 group &= item.GroupPermissions;
1337 everyone &= item.EveryonePermissions; 1339 everyone &= item.EveryonePermissions;
@@ -1340,33 +1342,35 @@ namespace OpenSim.Region.Framework.Scenes
1340 1342
1341 public uint MaskEffectivePermissions() 1343 public uint MaskEffectivePermissions()
1342 { 1344 {
1345 // used to propagate permissions restrictions outwards
1346 // Modify does not propagate outwards.
1343 uint mask=0x7fffffff; 1347 uint mask=0x7fffffff;
1344 1348
1345 foreach (TaskInventoryItem item in m_items.Values) 1349 foreach (TaskInventoryItem item in m_items.Values)
1346 { 1350 {
1347 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) 1351 if(item.InvType == (sbyte)InventoryType.Landmark)
1348 mask &= ~((uint)PermissionMask.Copy >> 13); 1352 continue;
1349 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) 1353
1350 mask &= ~((uint)PermissionMask.Transfer >> 13); 1354 // apply current to normal permission bits
1351 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) 1355 uint newperms = item.CurrentPermissions;
1352 mask &= ~((uint)PermissionMask.Modify >> 13);
1353
1354 if (item.InvType == (int)InventoryType.Object)
1355 {
1356 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1357 mask &= ~((uint)PermissionMask.Copy >> 13);
1358 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
1359 mask &= ~((uint)PermissionMask.Transfer >> 13);
1360 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1361 mask &= ~((uint)PermissionMask.Modify >> 13);
1362 }
1363 1356
1364 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1357 if ((newperms & (uint)PermissionMask.Copy) == 0)
1365 mask &= ~(uint)PermissionMask.Copy; 1358 mask &= ~(uint)PermissionMask.Copy;
1366 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 1359 if ((newperms & (uint)PermissionMask.Transfer) == 0)
1367 mask &= ~(uint)PermissionMask.Transfer; 1360 mask &= ~(uint)PermissionMask.Transfer;
1368 if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) 1361 if ((newperms & (uint)PermissionMask.Export) == 0)
1369 mask &= ~(uint)PermissionMask.Modify; 1362 mask &= ~((uint)PermissionMask.Export);
1363
1364 // apply next owner restricted by current to folded bits
1365 newperms &= item.NextPermissions;
1366
1367 if ((newperms & (uint)PermissionMask.Copy) == 0)
1368 mask &= ~((uint)PermissionMask.FoldedCopy);
1369 if ((newperms & (uint)PermissionMask.Transfer) == 0)
1370 mask &= ~((uint)PermissionMask.FoldedTransfer);
1371 if ((newperms & (uint)PermissionMask.Export) == 0)
1372 mask &= ~((uint)PermissionMask.FoldedExport);
1373
1370 } 1374 }
1371 return mask; 1375 return mask;
1372 } 1376 }
@@ -1375,19 +1379,6 @@ namespace OpenSim.Region.Framework.Scenes
1375 { 1379 {
1376 foreach (TaskInventoryItem item in m_items.Values) 1380 foreach (TaskInventoryItem item in m_items.Values)
1377 { 1381 {
1378 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
1379 {
1380// m_log.DebugFormat (
1381// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}",
1382// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions);
1383
1384 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1385 item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
1386 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
1387 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
1388 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1389 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1390 }
1391 item.CurrentPermissions &= item.NextPermissions; 1382 item.CurrentPermissions &= item.NextPermissions;
1392 item.BasePermissions &= item.NextPermissions; 1383 item.BasePermissions &= item.NextPermissions;
1393 item.EveryonePermissions &= item.NextPermissions; 1384 item.EveryonePermissions &= item.NextPermissions;
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
index 10facf2..e93175f 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
@@ -755,8 +755,8 @@ namespace PrimMesher
755 if (hollowAngles.angles[0].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[maxJ].angle + 0.000001f) 755 if (hollowAngles.angles[0].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[maxJ].angle + 0.000001f)
756 { 756 {
757 newFace.v1 = 0; 757 newFace.v1 = 0;
758 newFace.v2 = numTotalVerts - maxJ - 1; 758 newFace.v2 = numTotalVerts - 1;
759 newFace.v3 = numTotalVerts - 1; 759 newFace.v3 = numTotalVerts - maxJ - 1;
760 760
761 faces.Add(newFace); 761 faces.Add(newFace);
762 } 762 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 47c3cb8..2000c44 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -13405,6 +13405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13405 List<string> param = new List<string>(); 13405 List<string> param = new List<string>();
13406 bool ok; 13406 bool ok;
13407 Int32 flag; 13407 Int32 flag;
13408 int nCustomHeaders = 0;
13408 13409
13409 for (int i = 0; i < parameters.Data.Length; i += 2) 13410 for (int i = 0; i < parameters.Data.Length; i += 2)
13410 { 13411 {
@@ -13431,6 +13432,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13431 //Second Life documentation for llHTTPRequest. 13432 //Second Life documentation for llHTTPRequest.
13432 for (int count = 1; count <= 8; ++count) 13433 for (int count = 1; count <= 8; ++count)
13433 { 13434 {
13435 if(nCustomHeaders >= 8)
13436 {
13437 Error("llHTTPRequest", "Max number of custom headers is 8, excess ignored");
13438 break;
13439 }
13440
13434 //Enough parameters remaining for (another) header? 13441 //Enough parameters remaining for (another) header?
13435 if (parameters.Data.Length - i < 2) 13442 if (parameters.Data.Length - i < 2)
13436 { 13443 {
@@ -13445,15 +13452,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13445 13452
13446 param.Add(parameters.Data[i].ToString()); 13453 param.Add(parameters.Data[i].ToString());
13447 param.Add(parameters.Data[i+1].ToString()); 13454 param.Add(parameters.Data[i+1].ToString());
13455 nCustomHeaders++;
13448 13456
13449 //Have we reached the end of the list of headers? 13457 //Have we reached the end of the list of headers?
13450 //End is marked by a string with a single digit. 13458 //End is marked by a string with a single digit.
13451 if (i+2 >= parameters.Data.Length || 13459 if (i + 2 >= parameters.Data.Length ||
13452 Char.IsDigit(parameters.Data[i].ToString()[0])) 13460 Char.IsDigit(parameters.Data[i + 2].ToString()[0]))
13453 { 13461 {
13454 break; 13462 break;
13455 } 13463 }
13456
13457 i += 2; 13464 i += 2;
13458 } 13465 }
13459 } 13466 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs
index 8cac50e..241a24d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs
@@ -87,17 +87,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
87 uint port = 9999; 87 uint port = 9999;
88 MainServer.RemoveHttpServer(port); 88 MainServer.RemoveHttpServer(port);
89 89
90 BaseHttpServer server = new BaseHttpServer(port, false, "", "", ""); 90 m_engine = new MockScriptEngine();
91 m_urlModule = new UrlModule();
92
93 IConfigSource config = new IniConfigSource();
94 config.AddConfig("Network");
95 config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1");
96 m_scene = new SceneHelpers().SetupScene();
97
98 BaseHttpServer server = new BaseHttpServer(port, false, 0, "");
91 MainServer.AddHttpServer(server); 99 MainServer.AddHttpServer(server);
92 MainServer.Instance = server; 100 MainServer.Instance = server;
93 101
94 server.Start(); 102 server.Start();
95 103
96 m_engine = new MockScriptEngine(); 104 SceneHelpers.SetupSceneModules(m_scene, config, m_engine, m_urlModule);
97 m_urlModule = new UrlModule();
98
99 m_scene = new SceneHelpers().SetupScene();
100 SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule);
101 105
102 SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); 106 SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
103 m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); 107 m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart);