aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs10
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs46
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs47
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs93
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs94
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs58
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs1889
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs43
-rw-r--r--OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs3
25 files changed, 1643 insertions, 874 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 2242e42..6e4a710 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -369,7 +369,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
369 else if (Cache != null) 369 else if (Cache != null)
370 { 370 {
371 string assetName = "j2kCache_" + AssetId.ToString(); 371 string assetName = "j2kCache_" + AssetId.ToString();
372 AssetBase layerDecodeAsset = Cache.Get(assetName); 372 AssetBase layerDecodeAsset;
373 Cache.Get(assetName, out layerDecodeAsset);
373 374
374 if (layerDecodeAsset != null) 375 if (layerDecodeAsset != null)
375 { 376 {
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 23c1f03..403236c 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -260,10 +260,9 @@ namespace OpenSim.Region.CoreModules.Asset
260 /// Cache doesn't guarantee in any situation that asset is stored to it. 260 /// Cache doesn't guarantee in any situation that asset is stored to it.
261 /// </para> 261 /// </para>
262 /// </remarks> 262 /// </remarks>
263 public AssetBase Get(string id) 263 public bool Get(string id, out AssetBase assetBase)
264 { 264 {
265 m_getCount++; 265 m_getCount++;
266 AssetBase assetBase;
267 if (m_cache.TryGetValue(id, out assetBase)) 266 if (m_cache.TryGetValue(id, out assetBase))
268 m_hitCount++; 267 m_hitCount++;
269 268
@@ -284,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Asset
284// if (null == assetBase) 283// if (null == assetBase)
285// m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); 284// m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id);
286 285
287 return assetBase; 286 return true;
288 } 287 }
289 288
290 #endregion 289 #endregion
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 51fc3d1..10c0e85 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -115,7 +115,10 @@ namespace OpenSim.Region.CoreModules.Asset
115 public bool Check(string id) 115 public bool Check(string id)
116 { 116 {
117 // XXX This is probably not an efficient implementation. 117 // XXX This is probably not an efficient implementation.
118 return Get(id) != null; 118 AssetBase asset;
119 if (!Get(id, out asset))
120 return false;
121 return asset != null;
119 } 122 }
120 123
121 public void Cache(AssetBase asset) 124 public void Cache(AssetBase asset)
@@ -129,9 +132,10 @@ namespace OpenSim.Region.CoreModules.Asset
129 // We don't do negative caching 132 // We don't do negative caching
130 } 133 }
131 134
132 public AssetBase Get(string id) 135 public bool Get(string id, out AssetBase asset)
133 { 136 {
134 return (AssetBase)m_Cache.Get(id); 137 asset = (AssetBase)m_Cache.Get(id);
138 return true;
135 } 139 }
136 140
137 public void Expire(string id) 141 public void Expire(string id)
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 187f090..610e279 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -474,6 +474,8 @@ namespace OpenSim.Region.CoreModules.Asset
474 { 474 {
475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) 475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
476 { 476 {
477 if (stream.Length == 0) // Empty file will trigger exception below
478 return null;
477 BinaryFormatter bformatter = new BinaryFormatter(); 479 BinaryFormatter bformatter = new BinaryFormatter();
478 480
479 asset = (AssetBase)bformatter.Deserialize(stream); 481 asset = (AssetBase)bformatter.Deserialize(stream);
@@ -531,15 +533,26 @@ namespace OpenSim.Region.CoreModules.Asset
531 return found; 533 return found;
532 } 534 }
533 535
536 // For IAssetService
534 public AssetBase Get(string id) 537 public AssetBase Get(string id)
535 { 538 {
539 AssetBase asset;
540 Get(id, out asset);
541 return asset;
542 }
543
544 public bool Get(string id, out AssetBase asset)
545 {
546 asset = null;
547
536 m_Requests++; 548 m_Requests++;
537 549
538 object dummy; 550 object dummy;
539 if (m_negativeCache.TryGetValue(id, out dummy)) 551 if (m_negativeCache.TryGetValue(id, out dummy))
540 return null; 552 {
553 return false;
554 }
541 555
542 AssetBase asset = null;
543 asset = GetFromWeakReference(id); 556 asset = GetFromWeakReference(id);
544 if (asset != null && m_updateFileTimeOnCacheHit) 557 if (asset != null && m_updateFileTimeOnCacheHit)
545 { 558 {
@@ -578,13 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset
578 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); 591 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
579 } 592 }
580 593
581 if(asset == null) 594 return true;
582 {
583
584
585 }
586
587 return asset;
588 } 595 }
589 596
590 public bool Check(string id) 597 public bool Check(string id)
@@ -599,7 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset
599 606
600 public AssetBase GetCached(string id) 607 public AssetBase GetCached(string id)
601 { 608 {
602 return Get(id); 609 AssetBase asset;
610 Get(id, out asset);
611 return asset;
603 } 612 }
604 613
605 public void Expire(string id) 614 public void Expire(string id)
@@ -797,6 +806,9 @@ namespace OpenSim.Region.CoreModules.Asset
797 806
798 return; 807 return;
799 } 808 }
809 catch (UnauthorizedAccessException e)
810 {
811 }
800 finally 812 finally
801 { 813 {
802 if (stream != null) 814 if (stream != null)
@@ -1227,19 +1239,23 @@ namespace OpenSim.Region.CoreModules.Asset
1227 1239
1228 public AssetMetadata GetMetadata(string id) 1240 public AssetMetadata GetMetadata(string id)
1229 { 1241 {
1230 AssetBase asset = Get(id); 1242 AssetBase asset;
1243 Get(id, out asset);
1231 return asset.Metadata; 1244 return asset.Metadata;
1232 } 1245 }
1233 1246
1234 public byte[] GetData(string id) 1247 public byte[] GetData(string id)
1235 { 1248 {
1236 AssetBase asset = Get(id); 1249 AssetBase asset;
1250 Get(id, out asset);
1237 return asset.Data; 1251 return asset.Data;
1238 } 1252 }
1239 1253
1240 public bool Get(string id, object sender, AssetRetrieved handler) 1254 public bool Get(string id, object sender, AssetRetrieved handler)
1241 { 1255 {
1242 AssetBase asset = Get(id); 1256 AssetBase asset;
1257 if (!Get(id, out asset))
1258 return false;
1243 handler(id, sender, asset); 1259 handler(id, sender, asset);
1244 return true; 1260 return true;
1245 } 1261 }
@@ -1270,7 +1286,9 @@ namespace OpenSim.Region.CoreModules.Asset
1270 1286
1271 public bool UpdateContent(string id, byte[] data) 1287 public bool UpdateContent(string id, byte[] data)
1272 { 1288 {
1273 AssetBase asset = Get(id); 1289 AssetBase asset;
1290 if (!Get(id, out asset))
1291 return false;
1274 asset.Data = data; 1292 asset.Data = data;
1275 Cache(asset); 1293 Cache(asset);
1276 return true; 1294 return true;
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 208963d..abe9b23 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -131,14 +131,15 @@ namespace OpenSim.Region.CoreModules.Asset
131 // We don't do negative caching 131 // We don't do negative caching
132 } 132 }
133 133
134 public AssetBase Get(string id) 134 public bool Get(string id, out AssetBase asset)
135 { 135 {
136 Object asset = null; 136 Object a = null;
137 m_Cache.TryGet(id, out asset); 137 m_Cache.TryGet(id, out a);
138 138
139 Debug(asset); 139 Debug(a);
140 140
141 return (AssetBase)asset; 141 asset = (AssetBase)a;
142 return true;
142 } 143 }
143 144
144 public void Expire(string id) 145 public void Expire(string id)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8b8ac20..cf188aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -481,14 +481,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
482// group.Name, group.LocalId, sp.Name, attachmentPt, silent); 482// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
483 483
484 if (sp.GetAttachments().Contains(group))
485 {
486// m_log.WarnFormat(
487// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
488// group.Name, group.LocalId, sp.Name, AttachmentPt);
489
490 return false;
491 }
492 484
493 if (group.GetSittingAvatarsCount() != 0) 485 if (group.GetSittingAvatarsCount() != 0)
494 { 486 {
@@ -500,6 +492,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
500 return false; 492 return false;
501 } 493 }
502 494
495 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
496 if (attachments.Contains(group))
497 {
498// if (DebugLevel > 0)
499// m_log.WarnFormat(
500// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
501// group.Name, group.LocalId, sp.Name, attachmentPt);
502
503 return false;
504 }
505
503 Vector3 attachPos = group.AbsolutePosition; 506 Vector3 attachPos = group.AbsolutePosition;
504 507
505 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 508 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@@ -533,7 +536,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
533 { 536 {
534 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; 537 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint;
535 attachPos = group.RootPart.AttachedPos; 538 attachPos = group.RootPart.AttachedPos;
536 group.HasGroupChanged = true;
537 } 539 }
538 540
539 // if we still didn't find a suitable attachment point....... 541 // if we still didn't find a suitable attachment point.......
@@ -544,18 +546,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
544 attachPos = Vector3.Zero; 546 attachPos = Vector3.Zero;
545 } 547 }
546 548
547 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
548
549 if (attachments.Contains(group))
550 {
551 if (DebugLevel > 0)
552 m_log.WarnFormat(
553 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
554 group.Name, group.LocalId, sp.Name, attachmentPt);
555
556 return false;
557 }
558
559 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones 549 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
560 while (attachments.Count >= 5) 550 while (attachments.Count >= 5)
561 { 551 {
@@ -579,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
579 lock (sp.AttachmentsSyncLock) 569 lock (sp.AttachmentsSyncLock)
580 { 570 {
581 group.AttachmentPoint = attachmentPt; 571 group.AttachmentPoint = attachmentPt;
582 group.AbsolutePosition = attachPos; 572 group.RootPart.AttachedPos = attachPos;
583 573
584 if (addToInventory && sp.PresenceType != PresenceType.Npc) 574 if (addToInventory && sp.PresenceType != PresenceType.Npc)
585 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 575 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
@@ -956,7 +946,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
956 m_scene.DeleteFromStorage(so.UUID); 946 m_scene.DeleteFromStorage(so.UUID);
957 m_scene.EventManager.TriggerParcelPrimCountTainted(); 947 m_scene.EventManager.TriggerParcelPrimCountTainted();
958 948
959 so.AttachedAvatar = sp.UUID;
960 949
961 foreach (SceneObjectPart part in so.Parts) 950 foreach (SceneObjectPart part in so.Parts)
962 { 951 {
@@ -969,11 +958,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
969 } 958 }
970 } 959 }
971 960
972 so.AbsolutePosition = attachOffset;
973 so.RootPart.AttachedPos = attachOffset;
974 so.IsAttachment = true;
975 so.RootPart.SetParentLocalId(sp.LocalId); 961 so.RootPart.SetParentLocalId(sp.LocalId);
962 so.AttachedAvatar = sp.UUID;
976 so.AttachmentPoint = attachmentpoint; 963 so.AttachmentPoint = attachmentpoint;
964 so.RootPart.AttachedPos = attachOffset;
965 so.AbsolutePosition = attachOffset;
966 so.IsAttachment = true;
977 967
978 sp.AddAttachment(so); 968 sp.AddAttachment(so);
979 969
@@ -1322,7 +1312,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1322 if (part == null) 1312 if (part == null)
1323 return; 1313 return;
1324 1314
1325 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 1315 SceneObjectGroup group = part.ParentGroup;
1316
1317 if (!m_scene.Permissions.CanTakeObject(group, sp))
1326 { 1318 {
1327 remoteClient.SendAgentAlertMessage( 1319 remoteClient.SendAgentAlertMessage(
1328 "You don't have sufficient permissions to attach this object", false); 1320 "You don't have sufficient permissions to attach this object", false);
@@ -1334,7 +1326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1334 AttachmentPt &= 0x7f; 1326 AttachmentPt &= 0x7f;
1335 1327
1336 // Calls attach with a Zero position 1328 // Calls attach with a Zero position
1337 SceneObjectGroup group = part.ParentGroup;
1338 if (AttachObject(sp, group , AttachmentPt, false, true, append)) 1329 if (AttachObject(sp, group , AttachmentPt, false, true, append))
1339 { 1330 {
1340 if (DebugLevel > 0) 1331 if (DebugLevel > 0)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index fb408a4..535d946 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -299,7 +299,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
299 if (bakedTextureFace == null) 299 if (bakedTextureFace == null)
300 continue; 300 continue;
301 301
302 AssetBase asset = cache.Get(bakedTextureFace.TextureID.ToString()); 302 AssetBase asset;
303 cache.Get(bakedTextureFace.TextureID.ToString(), out asset);
303 304
304 if (asset != null && asset.Local) 305 if (asset != null && asset.Local)
305 { 306 {
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index d1f6054..315ce1b 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private bool enabled = true; 54 private bool enabled = true;
55 private bool m_UseNewAvnCode = false;
55 private List<Scene> m_SceneList = new List<Scene>(); 56 private List<Scene> m_SceneList = new List<Scene>();
56 private string m_RestURL = String.Empty; 57 private string m_RestURL = String.Empty;
57 IMessageTransferModule m_TransferModule = null; 58 IMessageTransferModule m_TransferModule = null;
@@ -82,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
82 } 83 }
83 84
84 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); 85 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
86 m_UseNewAvnCode = cnf.GetBoolean("UseNewAvnCode", m_UseNewAvnCode);
85 } 87 }
86 88
87 public void AddRegion(Scene scene) 89 public void AddRegion(Scene scene)
@@ -244,68 +246,73 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
244 return; 246 return;
245 } 247 }
246 248
247 Scene scene = FindScene(new UUID(im.fromAgentID)); 249 if(m_UseNewAvnCode)
248 if (scene == null) 250 {
249 scene = m_SceneList[0]; 251 Scene scene = FindScene(new UUID(im.fromAgentID));
252 if (scene == null)
253 scene = m_SceneList[0];
250 254
251// Avination new code 255 UUID scopeID = scene.RegionInfo.ScopeID;
252// SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( 256 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
253// "POST", m_RestURL+"/SaveMessage/?scope=" + 257 "POST", m_RestURL+"/SaveMessage/?scope=" + scopeID.ToString(), im, 20000);
254// scene.RegionInfo.ScopeID.ToString(), im);
255 258
256// current opensim and osgrid compatible 259 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
257 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 260 {
258 "POST", m_RestURL+"/SaveMessage/", im, 10000); 261 IClientAPI client = FindClient(new UUID(im.fromAgentID));
259// current opensim and osgrid compatible end 262 if (client == null)
263 return;
260 264
261 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 265 if (string.IsNullOrEmpty(reply.Message))
262 { 266 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
263 IClientAPI client = FindClient(new UUID(im.fromAgentID));
264 if (client == null)
265 return;
266/* Avination new code
267 if (reply.Message == String.Empty)
268 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
269 267
270 bool sendReply = true; 268 bool sendReply = true;
271 269
272 switch (reply.Disposition) 270 switch (reply.Disposition)
273 {
274 case 0: // Normal
275 break;
276 case 1: // Only once per user
277 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
278 { 271 {
279 sendReply = false; 272 case 0: // Normal
273 break;
274 case 1: // Only once per user
275 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
276 sendReply = false;
277 else
278 {
279 if (!m_repliesSent.ContainsKey(client))
280 m_repliesSent[client] = new List<UUID>();
281 m_repliesSent[client].Add(new UUID(im.toAgentID));
282 }
283 break;
280 } 284 }
281 else 285
286 if (sendReply)
282 { 287 {
283 if (!m_repliesSent.ContainsKey(client)) 288 client.SendInstantMessage(new GridInstantMessage(
284 m_repliesSent[client] = new List<UUID>(); 289 null, new UUID(im.toAgentID),
285 m_repliesSent[client].Add(new UUID(im.toAgentID)); 290 "System", new UUID(im.fromAgentID),
291 (byte)InstantMessageDialog.MessageFromAgent,
292 reply.Message,
293 false, new Vector3()));
286 } 294 }
287 break;
288 } 295 }
296 }
297 else
298 {
299 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
300 "POST", m_RestURL+"/SaveMessage/", im, 20000);
289 301
290 if (sendReply) 302 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
291 { 303 {
304 IClientAPI client = FindClient(new UUID(im.fromAgentID));
305 if (client == null)
306 return;
307
292 client.SendInstantMessage(new GridInstantMessage( 308 client.SendInstantMessage(new GridInstantMessage(
293 null, new UUID(im.toAgentID),
294 "System", new UUID(im.fromAgentID),
295 (byte)InstantMessageDialog.MessageFromAgent,
296 reply.Message,
297 false, new Vector3()));
298 }
299*/
300// current opensim and osgrid compatible
301 client.SendInstantMessage(new GridInstantMessage(
302 null, new UUID(im.toAgentID), 309 null, new UUID(im.toAgentID),
303 "System", new UUID(im.fromAgentID), 310 "System", new UUID(im.fromAgentID),
304 (byte)InstantMessageDialog.MessageFromAgent, 311 (byte)InstantMessageDialog.MessageFromAgent,
305 "User is not logged in. "+ 312 "User is not logged in. "+
306 (success ? "Message saved." : "Message not saved"), 313 (success ? "Message saved." : "Message not saved"),
307 false, new Vector3())); 314 false, new Vector3()));
308// current opensim and osgrid compatible end 315 }
309 } 316 }
310 } 317 }
311 } 318 }
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index bc8aeca..89e3020 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
149 149
150 if (profileConfig == null) 150 if (profileConfig == null)
151 { 151 {
152 m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration"); 152 //m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration");
153 Enabled = false; 153 Enabled = false;
154 return; 154 return;
155 } 155 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 6dc982b..87b76dc 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1703,11 +1703,81 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1703 return agent; 1703 return agent;
1704 } 1704 }
1705 1705
1706 public bool CrossAgentCreateFarChild(ScenePresence agent, GridRegion neighbourRegion, Vector3 pos, EntityTransferContext ctx)
1707 {
1708 ulong regionhandler = neighbourRegion.RegionHandle;
1709
1710 if(agent.knowsNeighbourRegion(regionhandler))
1711 return true;
1712
1713 string reason;
1714 ulong currentRegionHandler = agent.Scene.RegionInfo.RegionHandle;
1715 GridRegion source = new GridRegion(agent.Scene.RegionInfo);
1716
1717 AgentCircuitData currentAgentCircuit =
1718 agent.Scene.AuthenticateHandler.GetAgentCircuitData(agent.ControllingClient.CircuitCode);
1719 AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
1720 agentCircuit.startpos = pos;
1721 agentCircuit.child = true;
1722
1723 agentCircuit.Appearance = new AvatarAppearance();
1724 agentCircuit.Appearance.AvatarHeight = agent.Appearance.AvatarHeight;
1725
1726 if (currentAgentCircuit != null)
1727 {
1728 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
1729 agentCircuit.IPAddress = currentAgentCircuit.IPAddress;
1730 agentCircuit.Viewer = currentAgentCircuit.Viewer;
1731 agentCircuit.Channel = currentAgentCircuit.Channel;
1732 agentCircuit.Mac = currentAgentCircuit.Mac;
1733 agentCircuit.Id0 = currentAgentCircuit.Id0;
1734 }
1735
1736 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1737 agent.AddNeighbourRegion(neighbourRegion, agentCircuit.CapsPath);
1738
1739 IPEndPoint endPoint = neighbourRegion.ExternalEndPoint;
1740 if (Scene.SimulationService.CreateAgent(source, neighbourRegion, agentCircuit, (int)TeleportFlags.Default, ctx, out reason))
1741 {
1742 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
1743 int newSizeX = neighbourRegion.RegionSizeX;
1744 int newSizeY = neighbourRegion.RegionSizeY;
1745
1746 if (m_eqModule != null)
1747 {
1748 #region IP Translation for NAT
1749 IClientIPEndpoint ipepClient;
1750 if (agent.ClientView.TryGet(out ipepClient))
1751 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
1752
1753 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
1754 "and EstablishAgentCommunication with seed cap {8}", LogHeader,
1755 source.RegionName, agent.Name,
1756 neighbourRegion.RegionName, neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, newSizeX, newSizeY , capsPath);
1757
1758 m_eqModule.EnableSimulator(regionhandler,
1759 endPoint, agent.UUID, newSizeX, newSizeY);
1760 m_eqModule.EstablishAgentCommunication(agent.UUID, endPoint, capsPath,
1761 regionhandler, newSizeX, newSizeY);
1762 }
1763 else
1764 {
1765 agent.ControllingClient.InformClientOfNeighbour(regionhandler, endPoint);
1766 }
1767 return true;
1768 }
1769 agent.RemoveNeighbourRegion(regionhandler);
1770 return false;
1771 }
1772
1706 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx) 1773 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx)
1707 { 1774 {
1708 int ts = Util.EnvironmentTickCount(); 1775 int ts = Util.EnvironmentTickCount();
1776 bool sucess = true;
1777 string reason = String.Empty;
1709 try 1778 try
1710 { 1779 {
1780
1711 AgentData cAgent = new AgentData(); 1781 AgentData cAgent = new AgentData();
1712 agent.CopyTo(cAgent,true); 1782 agent.CopyTo(cAgent,true);
1713 1783
@@ -1725,18 +1795,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1725 // Beyond this point, extra cleanup is needed beyond removing transit state 1795 // Beyond this point, extra cleanup is needed beyond removing transit state
1726 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); 1796 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring);
1727 1797
1728 if (!agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx)) 1798 if (sucess && !agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx))
1799 {
1800 sucess = false;
1801 reason = "agent update failed";
1802 }
1803
1804 if(!sucess)
1729 { 1805 {
1730 // region doesn't take it 1806 // region doesn't take it
1731 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); 1807 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1732 1808
1733 m_log.WarnFormat( 1809 m_log.WarnFormat(
1734 "[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.", 1810 "[ENTITY TRANSFER MODULE]: agent {0} crossing to {1} failed: {2}",
1735 neighbourRegion.RegionName, agent.Name); 1811 agent.Name, neighbourRegion.RegionName, reason);
1736 1812
1737 ReInstantiateScripts(agent); 1813 ReInstantiateScripts(agent);
1738 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero) 1814 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero)
1815 {
1739 agent.AddToPhysicalScene(isFlying); 1816 agent.AddToPhysicalScene(isFlying);
1817 }
1740 1818
1741 return false; 1819 return false;
1742 } 1820 }
@@ -1777,7 +1855,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1777 1855
1778 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 1856 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1779 1857
1780 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); 1858 Vector3 vel2 = Vector3.Zero;
1859 if((agent.crossingFlags & 2) != 0)
1860 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
1781 1861
1782 if (m_eqModule != null) 1862 if (m_eqModule != null)
1783 { 1863 {
@@ -1804,7 +1884,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1804 1884
1805 // this may need the attachments 1885 // this may need the attachments
1806 1886
1807 agent.HasMovedAway(true); 1887 agent.HasMovedAway((agent.crossingFlags & 8) == 0);
1808 1888
1809 agent.MakeChildAgent(neighbourRegion.RegionHandle); 1889 agent.MakeChildAgent(neighbourRegion.RegionHandle);
1810 1890
@@ -2135,7 +2215,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2135 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY, 2215 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
2136 0f); 2216 0f);
2137 } 2217 }
2138 2218 #endregion
2139 2219
2140 #region NotFoundLocationCache class 2220 #region NotFoundLocationCache class
2141 // A collection of not found locations to make future lookups 'not found' lookups quick. 2221 // A collection of not found locations to make future lookups 'not found' lookups quick.
@@ -2620,7 +2700,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2620 { 2700 {
2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete 2701 // FIXME: It would be better to never add the scene object at all rather than add it and then delete
2622 // it 2702 // it
2623 if (!Scene.Permissions.CanObjectEntry(so.UUID, true, so.AbsolutePosition)) 2703 if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition))
2624 { 2704 {
2625 // Deny non attachments based on parcel settings 2705 // Deny non attachments based on parcel settings
2626 // 2706 //
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 95e7456..ba3a7c9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -541,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
541 541
542 #region Permissions 542 #region Permissions
543 543
544 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 544 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
545 { 545 {
546 if (m_bypassPermissions) return true; 546 if (m_bypassPermissions) return true;
547 547
548 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) 548 if(sp == null || sog == null)
549 return false;
550
551 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID))
549 { 552 {
550 SceneObjectGroup sog = null; 553 if (sog.OwnerID == sp.UUID)
551 if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer)
552 return true; 554 return true;
553
554 return false; 555 return false;
555 } 556 }
556 557
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 0104823..67c847b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -427,20 +427,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
427 originalRotations[objectGroup.UUID] = inventoryStoredRotation; 427 originalRotations[objectGroup.UUID] = inventoryStoredRotation;
428 428
429 // Restore attachment data after trip through the sim 429 // Restore attachment data after trip through the sim
430 if (objectGroup.RootPart.AttachPoint > 0) 430 if (objectGroup.AttachmentPoint > 0)
431 { 431 {
432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos; 432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos;
433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation; 433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
434 } 434 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
435 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
436 objectGroup.RootPart.Shape.LastAttachPoint = (byte)objectGroup.AttachmentPoint;
435 437
436 // Trees could be attached and it's been done, but it makes
437 // no sense. State must be preserved because it's the tree type
438 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
439 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
440 {
441 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
442 if (objectGroup.RootPart.AttachPoint > 0)
443 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
444 } 438 }
445 439
446 objectGroup.AbsolutePosition = inventoryStoredPosition; 440 objectGroup.AbsolutePosition = inventoryStoredPosition;
@@ -605,15 +599,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
605 perms &= ~(uint)PermissionMask.Transfer; 599 perms &= ~(uint)PermissionMask.Transfer;
606 if ((nextPerms & (uint)PermissionMask.Modify) == 0) 600 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
607 perms &= ~(uint)PermissionMask.Modify; 601 perms &= ~(uint)PermissionMask.Modify;
608 602
609 item.BasePermissions = perms & so.RootPart.NextOwnerMask; 603// item.BasePermissions = perms & so.RootPart.NextOwnerMask;
604
605 uint nextp = so.RootPart.NextOwnerMask | (uint)PermissionMask.FoldedMask;
606 item.BasePermissions = perms & nextp;
610 item.CurrentPermissions = item.BasePermissions; 607 item.CurrentPermissions = item.BasePermissions;
611 item.NextPermissions = perms & so.RootPart.NextOwnerMask; 608 item.NextPermissions = perms & so.RootPart.NextOwnerMask;
612 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; 609 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
613 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; 610 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
614 611
615 // apply next owner perms on rez 612 // apply next owner perms on rez
616 item.CurrentPermissions |= SceneObjectGroup.SLAM; 613 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
617 } 614 }
618 else 615 else
619 { 616 {
@@ -1124,7 +1121,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1124// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1121// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
1125 1122
1126 if ((rootPart.OwnerID != item.Owner) || 1123 if ((rootPart.OwnerID != item.Owner) ||
1127 (item.CurrentPermissions & 16) != 0 || 1124 (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 ||
1128 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 1125 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
1129 { 1126 {
1130 //Need to kill the for sale here 1127 //Need to kill the for sale here
@@ -1136,32 +1133,48 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1136 foreach (SceneObjectPart part in so.Parts) 1133 foreach (SceneObjectPart part in so.Parts)
1137 { 1134 {
1138 part.GroupMask = 0; // DO NOT propagate here 1135 part.GroupMask = 0; // DO NOT propagate here
1139 1136 if( part.OwnerID != part.GroupID)
1140 part.LastOwnerID = part.OwnerID; 1137 part.LastOwnerID = part.OwnerID;
1141 part.OwnerID = item.Owner; 1138 part.OwnerID = item.Owner;
1142 part.RezzerID = item.Owner; 1139 part.RezzerID = item.Owner;
1143 part.Inventory.ChangeInventoryOwner(item.Owner); 1140 part.Inventory.ChangeInventoryOwner(item.Owner);
1144 1141
1145 // This applies the base mask from the item as the next 1142 // Reconstruct the original item's base permissions. They
1146 // permissions for the object. This is correct because the 1143 // can be found in the lower (folded) bits.
1147 // giver's base mask was masked by the giver's next owner 1144 if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0)
1148 // mask, so the base mask equals the original next owner mask. 1145 {
1149 part.NextOwnerMask = item.BasePermissions; 1146 // We have permissions stored there so use them
1147 part.NextOwnerMask = ((item.BasePermissions & 7) << 13);
1148 if ((item.BasePermissions & (uint)PermissionMask.FoldedExport) != 0)
1149 part.NextOwnerMask |= (uint)PermissionMask.Export;
1150 part.NextOwnerMask |= (uint)PermissionMask.Move;
1151 }
1152 else
1153 {
1154 // This is a legacy object and we can't avoid the issues that
1155 // caused perms loss or escalation before, treat it the legacy
1156 // way.
1157 part.NextOwnerMask = item.NextPermissions;
1158 }
1150 } 1159 }
1151 1160
1152 so.ApplyNextOwnerPermissions(); 1161 so.ApplyNextOwnerPermissions();
1153 1162
1154 // In case the user has changed flags on a received item 1163 // In case the user has changed flags on a received item
1155 // we have to apply those changes after the slam. Else we 1164 // we have to apply those changes after the slam. Else we
1156 // get a net loss of permissions 1165 // get a net loss of permissions.
1166 // On legacy objects, this opts for a loss of permissions rather
1167 // than the previous handling that allowed escalation.
1157 foreach (SceneObjectPart part in so.Parts) 1168 foreach (SceneObjectPart part in so.Parts)
1158 { 1169 {
1159 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) 1170 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1160 { 1171 {
1172 part.GroupMask = item.GroupPermissions & part.BaseMask;
1161 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; 1173 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
1162 part.NextOwnerMask = item.NextPermissions & part.BaseMask; 1174 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1163 } 1175 }
1164 } 1176 }
1177
1165 } 1178 }
1166 } 1179 }
1167 else 1180 else
@@ -1180,6 +1193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1180 } 1193 }
1181 1194
1182 rootPart.TrimPermissions(); 1195 rootPart.TrimPermissions();
1196 so.AggregateDeepPerms();
1183 1197
1184 if (isAttachment) 1198 if (isAttachment)
1185 so.FromItemID = item.ID; 1199 so.FromItemID = item.ID;
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 51f973a..32cb5a3 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -957,9 +957,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
957 957
958 public virtual bool IsLocalGridUser(UUID uuid) 958 public virtual bool IsLocalGridUser(UUID uuid)
959 { 959 {
960 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); 960 lock (m_Scenes)
961 if (account == null || (account != null && !account.LocalToGrid)) 961 {
962 return false; 962 if (m_Scenes.Count == 0)
963 return true;
964 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);
965 if (account == null || (account != null && !account.LocalToGrid))
966 return false;
967 }
963 968
964 return true; 969 return true;
965 } 970 }
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 3f332fa..290daa9 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -83,17 +83,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
83 LogManager.GetLogger( 83 LogManager.GetLogger(
84 MethodBase.GetCurrentMethod().DeclaringType); 84 MethodBase.GetCurrentMethod().DeclaringType);
85 85
86 private Dictionary<UUID, UrlData> m_RequestMap = 86 protected Dictionary<UUID, UrlData> m_RequestMap =
87 new Dictionary<UUID, UrlData>(); 87 new Dictionary<UUID, UrlData>();
88 88
89 private 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 private uint m_HttpsPort = 0; 92 protected uint m_HttpsPort = 0;
93 private IHttpServer m_HttpServer = null; 93 protected IHttpServer m_HttpServer = null;
94 private IHttpServer m_HttpsServer = null; 94 protected IHttpServer m_HttpsServer = null;
95 95
96 public string ExternalHostNameForLSL { get; private set; } 96 public string ExternalHostNameForLSL { get; protected set; }
97 97
98 /// <summary> 98 /// <summary>
99 /// The default maximum number of urls 99 /// The default maximum number of urls
@@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
107 107
108 public Type ReplaceableInterface 108 public Type ReplaceableInterface
109 { 109 {
110 get { return null; } 110 get { return typeof(IUrlModule); }
111 } 111 }
112 112
113 public string Name 113 public string Name
@@ -453,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
453 } 453 }
454 454
455 455
456 private void RemoveUrl(UrlData data) 456 protected void RemoveUrl(UrlData data)
457 { 457 {
458 if (data.isSsl) 458 if (data.isSsl)
459 m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/"); 459 m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/");
@@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
461 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); 461 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
462 } 462 }
463 463
464 private Hashtable NoEvents(UUID requestID, UUID sessionID) 464 protected Hashtable NoEvents(UUID requestID, UUID sessionID)
465 { 465 {
466 Hashtable response = new Hashtable(); 466 Hashtable response = new Hashtable();
467 UrlData url; 467 UrlData url;
@@ -499,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
499 return response; 499 return response;
500 } 500 }
501 501
502 private bool HasEvents(UUID requestID, UUID sessionID) 502 protected bool HasEvents(UUID requestID, UUID sessionID)
503 { 503 {
504 UrlData url=null; 504 UrlData url=null;
505 505
@@ -531,7 +531,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
531 } 531 }
532 } 532 }
533 533
534 private void Drop(UUID requestID, UUID sessionID) 534 protected void Drop(UUID requestID, UUID sessionID)
535 { 535 {
536 UrlData url = null; 536 UrlData url = null;
537 lock (m_RequestMap) 537 lock (m_RequestMap)
@@ -552,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
552 } 552 }
553 } 553 }
554 554
555 private Hashtable GetEvents(UUID requestID, UUID sessionID) 555 protected Hashtable GetEvents(UUID requestID, UUID sessionID)
556 { 556 {
557 UrlData url = null; 557 UrlData url = null;
558 RequestData requestData = null; 558 RequestData requestData = null;
@@ -757,7 +757,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
757 } 757 }
758 } 758 }
759 759
760 private void OnScriptReset(uint localID, UUID itemID) 760 protected void OnScriptReset(uint localID, UUID itemID)
761 { 761 {
762 ScriptRemoved(itemID); 762 ScriptRemoved(itemID);
763 } 763 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
index 9e75ee2..2e6f472 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
@@ -85,12 +85,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
85 85
86 public LocalUserProfilesServicesConnector() 86 public LocalUserProfilesServicesConnector()
87 { 87 {
88 m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params"); 88 //m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params");
89 } 89 }
90 90
91 public LocalUserProfilesServicesConnector(IConfigSource source) 91 public LocalUserProfilesServicesConnector(IConfigSource source)
92 { 92 {
93 m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly."); 93 //m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly.");
94 InitialiseService(source); 94 InitialiseService(source);
95 } 95 }
96 96
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
104 IConfig config = source.Configs[ConfigName]; 104 IConfig config = source.Configs[ConfigName];
105 if (config == null) 105 if (config == null)
106 { 106 {
107 m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini"); 107 //m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini");
108 return; 108 return;
109 } 109 }
110 110
@@ -225,4 +225,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
225 } 225 }
226 #endregion 226 #endregion
227 } 227 }
228} \ No newline at end of file 228}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index f5aa971..92ae36f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -209,7 +209,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
209 209
210 if (m_Cache != null) 210 if (m_Cache != null)
211 { 211 {
212 asset = m_Cache.Get(id); 212 if (!m_Cache.Get(id, out asset))
213 return null;
213 214
214 if (asset != null) 215 if (asset != null)
215 return asset; 216 return asset;
@@ -238,10 +239,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
238 239
239 public AssetBase GetCached(string id) 240 public AssetBase GetCached(string id)
240 { 241 {
242 AssetBase asset = null;
241 if (m_Cache != null) 243 if (m_Cache != null)
242 return m_Cache.Get(id); 244 m_Cache.Get(id, out asset);
243 245
244 return null; 246 return asset;
245 } 247 }
246 248
247 public AssetMetadata GetMetadata(string id) 249 public AssetMetadata GetMetadata(string id)
@@ -250,8 +252,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
250 252
251 if (m_Cache != null) 253 if (m_Cache != null)
252 { 254 {
253 if (m_Cache != null) 255 if (!m_Cache.Get(id, out asset))
254 m_Cache.Get(id); 256 return null;
255 257
256 if (asset != null) 258 if (asset != null)
257 return asset.Metadata; 259 return asset.Metadata;
@@ -273,8 +275,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
273 275
274 if (m_Cache != null) 276 if (m_Cache != null)
275 { 277 {
276 if (m_Cache != null) 278 if (!m_Cache.Get(id, out asset))
277 m_Cache.Get(id); 279 return null;
278 280
279 if (asset != null) 281 if (asset != null)
280 return asset.Data; 282 return asset.Data;
@@ -292,7 +294,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
292 AssetBase asset = null; 294 AssetBase asset = null;
293 295
294 if (m_Cache != null) 296 if (m_Cache != null)
295 asset = m_Cache.Get(id); 297 {
298 if (!m_Cache.Get(id, out asset))
299 return false;
300 }
296 301
297 if (asset != null) 302 if (asset != null)
298 { 303 {
@@ -382,7 +387,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
382 AssetBase asset = null; 387 AssetBase asset = null;
383 388
384 if (m_Cache != null) 389 if (m_Cache != null)
385 asset = m_Cache.Get(id); 390 m_Cache.Get(id, out asset);
386 391
387 if (asset != null) 392 if (asset != null)
388 { 393 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 7190aa0..37a48bb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -158,7 +158,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
158 158
159 AssetBase asset = null; 159 AssetBase asset = null;
160 if (m_Cache != null) 160 if (m_Cache != null)
161 asset = m_Cache.Get(id); 161 {
162 if (!m_Cache.Get(id, out asset))
163 return null;
164 }
162 165
163 if (asset == null) 166 if (asset == null)
164 { 167 {
@@ -177,17 +180,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
177 { 180 {
178// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id); 181// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id);
179 182
183 AssetBase asset = null;
180 if (m_Cache != null) 184 if (m_Cache != null)
181 return m_Cache.Get(id); 185 m_Cache.Get(id, out asset);
182 186
183 return null; 187 return asset;
184 } 188 }
185 189
186 public AssetMetadata GetMetadata(string id) 190 public AssetMetadata GetMetadata(string id)
187 { 191 {
188 AssetBase asset = null; 192 AssetBase asset = null;
189 if (m_Cache != null) 193 if (m_Cache != null)
190 asset = m_Cache.Get(id); 194 {
195 if (!m_Cache.Get(id, out asset))
196 return null;
197 }
191 198
192 if (asset != null) 199 if (asset != null)
193 return asset.Metadata; 200 return asset.Metadata;
@@ -210,7 +217,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
210 AssetBase asset = null; 217 AssetBase asset = null;
211 218
212 if (m_Cache != null) 219 if (m_Cache != null)
213 asset = m_Cache.Get(id); 220 {
221 if (!m_Cache.Get(id, out asset))
222 return null;
223 }
214 224
215 if (asset != null) 225 if (asset != null)
216 return asset.Data; 226 return asset.Data;
@@ -232,7 +242,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
232 242
233 if (m_Cache != null) 243 if (m_Cache != null)
234 { 244 {
235 AssetBase asset = m_Cache.Get(id); 245 AssetBase asset;
246 if (!m_Cache.Get(id, out asset))
247 return false;
236 248
237 if (asset != null) 249 if (asset != null)
238 { 250 {
@@ -287,7 +299,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
287 { 299 {
288 AssetBase asset = null; 300 AssetBase asset = null;
289 if (m_Cache != null) 301 if (m_Cache != null)
290 m_Cache.Get(id); 302 m_Cache.Get(id, out asset);
291 if (asset != null) 303 if (asset != null)
292 { 304 {
293 asset.Data = data; 305 asset.Data = data;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 5d12f8b..53b9796 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -149,9 +149,11 @@ namespace OpenSim.Region.CoreModules.World.Land
149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache 149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0); 150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
151 151
152 m_scene.EventManager.OnObjectAddedToScene += EventManagerOnParcelPrimCountAdd;
152 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 153 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
153 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 154
154 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; 155 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
156 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
155 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; 157 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
156 158
157 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 159 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
@@ -287,8 +289,10 @@ namespace OpenSim.Region.CoreModules.World.Land
287 289
288 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, 290 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
289 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); 291 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
290 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 292 LandData ldata = fullSimParcel.LandData;
291 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 293 ldata.SimwideArea = ldata.Area;
294 ldata.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
295 ldata.ClaimDate = Util.UnixTimeSinceEpoch();
292 296
293 return AddLandObject(fullSimParcel); 297 return AddLandObject(fullSimParcel);
294 } 298 }
@@ -813,6 +817,9 @@ namespace OpenSim.Region.CoreModules.World.Land
813 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 817 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
814 } 818 }
815 819
820 if(m_landList.Count == 0 || m_landIDList == null)
821 return null;
822
816 lock (m_landIDList) 823 lock (m_landIDList)
817 { 824 {
818 try 825 try
@@ -824,8 +831,6 @@ namespace OpenSim.Region.CoreModules.World.Land
824 return null; 831 return null;
825 } 832 }
826 } 833 }
827
828 return m_landList[m_landIDList[x / 4, y / 4]];
829 } 834 }
830 835
831 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID 836 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
@@ -1576,6 +1581,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1576 } 1581 }
1577 } 1582 }
1578 } 1583 }
1584 FinalizeLandPrimCountUpdate(); // update simarea information
1579 } 1585 }
1580 } 1586 }
1581 1587
@@ -1640,9 +1646,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1640 foreach (HashSet<SceneObjectGroup> objs in returns.Values) 1646 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1641 { 1647 {
1642 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs); 1648 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
1643 if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2)) 1649 if (m_scene.Permissions.CanReturnObjects(null, remoteClient, objs2))
1644 { 1650 {
1645 m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId); 1651 m_scene.returnObjects(objs2.ToArray(), remoteClient);
1646 } 1652 }
1647 else 1653 else
1648 { 1654 {
@@ -2035,7 +2041,7 @@ namespace OpenSim.Region.CoreModules.World.Land
2035 { 2041 {
2036 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 2042 SceneObjectGroup[] objs = new SceneObjectGroup[1];
2037 objs[0] = obj; 2043 objs[0] = obj;
2038 ((Scene)client.Scene).returnObjects(objs, client.AgentId); 2044 ((Scene)client.Scene).returnObjects(objs, client);
2039 } 2045 }
2040 2046
2041 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 2047 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 73b4cb5..2b5cb31 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -356,6 +356,7 @@ namespace OpenSim.Region.CoreModules.World.Land
356 } 356 }
357 } 357 }
358 358
359 // the total prims a parcel owner can have on a region
359 public int GetSimulatorMaxPrimCount() 360 public int GetSimulatorMaxPrimCount()
360 { 361 {
361 if (overrideSimulatorMaxPrimCount != null) 362 if (overrideSimulatorMaxPrimCount != null)
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.World.Land
370 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus 371 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus
371 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) 372 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)
372 +0.5 ); 373 +0.5 );
373 374 // sanity check
374 if(simMax > m_scene.RegionInfo.ObjectCapacity) 375 if(simMax > m_scene.RegionInfo.ObjectCapacity)
375 simMax = m_scene.RegionInfo.ObjectCapacity; 376 simMax = m_scene.RegionInfo.ObjectCapacity;
376 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", 377 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}",
@@ -1043,7 +1044,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1043 else 1044 else
1044 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); 1045 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]);
1045 1046
1046 LandData.Area = tempArea * landUnit * landUnit; 1047 tempArea *= landUnit * landUnit;
1048 LandData.Area = tempArea;
1047 } 1049 }
1048 1050
1049 #endregion 1051 #endregion
@@ -1647,8 +1649,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1647 { 1649 {
1648 foreach (SceneObjectGroup obj in primsOverMe) 1650 foreach (SceneObjectGroup obj in primsOverMe)
1649 { 1651 {
1650 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero && 1652 if(m_scene.Permissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original))
1651 (obj.GetEffectivePermissions() & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0)
1652 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0); 1653 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0);
1653 } 1654 }
1654 } 1655 }
@@ -1662,7 +1663,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1662 { 1663 {
1663 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 1664 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1664 objs[0] = obj; 1665 objs[0] = obj;
1665 m_scene.returnObjects(objs, obj.OwnerID); 1666 m_scene.returnObjects(objs, null);
1666 } 1667 }
1667 1668
1668 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 1669 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
@@ -1693,6 +1694,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1693 { 1694 {
1694 if (obj.GroupID == LandData.GroupID) 1695 if (obj.GroupID == LandData.GroupID)
1695 { 1696 {
1697 if (obj.OwnerID == LandData.OwnerID)
1698 continue;
1696 if (!returns.ContainsKey(obj.OwnerID)) 1699 if (!returns.ContainsKey(obj.OwnerID))
1697 returns[obj.OwnerID] = 1700 returns[obj.OwnerID] =
1698 new List<SceneObjectGroup>(); 1701 new List<SceneObjectGroup>();
@@ -1734,8 +1737,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1734 1737
1735 foreach (List<SceneObjectGroup> ol in returns.Values) 1738 foreach (List<SceneObjectGroup> ol in returns.Values)
1736 { 1739 {
1737 if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) 1740 if (m_scene.Permissions.CanReturnObjects(this, remote_client, ol))
1738 m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); 1741 m_scene.returnObjects(ol.ToArray(), remote_client);
1739 } 1742 }
1740 } 1743 }
1741 1744
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 857f919..2a720db 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -92,10 +92,8 @@ namespace OpenSim.Region.CoreModules.World.Land
92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this); 92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
93 93
94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; 94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene;
96 OnObjectBeingRemovedFromScene; 96 m_Scene.EventManager.OnParcelPrimCountTainted += OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnParcelPrimCountTainted +=
98 OnParcelPrimCountTainted;
99 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); }; 97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
100 } 98 }
101 99
@@ -215,29 +213,15 @@ namespace OpenSim.Region.CoreModules.World.Land
215 else 213 else
216 parcelCounts.Users[obj.OwnerID] = partCount; 214 parcelCounts.Users[obj.OwnerID] = partCount;
217 215
218 if (obj.IsSelected) 216 if (obj.IsSelected || obj.GetSittingAvatarsCount() > 0)
219 {
220 parcelCounts.Selected += partCount; 217 parcelCounts.Selected += partCount;
221 } 218
219 if (obj.OwnerID == landData.OwnerID)
220 parcelCounts.Owner += partCount;
221 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
222 parcelCounts.Group += partCount;
222 else 223 else
223 { 224 parcelCounts.Others += partCount;
224 if (landData.IsGroupOwned)
225 {
226 if (obj.OwnerID == landData.GroupID)
227 parcelCounts.Owner += partCount;
228 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
229 parcelCounts.Group += partCount;
230 else
231 parcelCounts.Others += partCount;
232 }
233 else
234 {
235 if (obj.OwnerID == landData.OwnerID)
236 parcelCounts.Owner += partCount;
237 else
238 parcelCounts.Others += partCount;
239 }
240 }
241 } 225 }
242 } 226 }
243 227
@@ -393,7 +377,6 @@ namespace OpenSim.Region.CoreModules.World.Land
393 count = counts.Owner; 377 count = counts.Owner;
394 count += counts.Group; 378 count += counts.Group;
395 count += counts.Others; 379 count += counts.Others;
396 count += counts.Selected;
397 } 380 }
398 } 381 }
399 382
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index 0d8ece7..a349aa1 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
151 151
152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); 152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false); 153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); 154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, m_userId, UUID.Zero, Quaternion.Identity, false);
155 155
156 Assert.That(pc.Owner, Is.EqualTo(6)); 156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0)); 157 Assert.That(pc.Group, Is.EqualTo(0));
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2837358..90d65c7 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -89,28 +89,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
89 if (part == null) 89 if (part == null)
90 return; 90 return;
91 91
92 if (part.ParentGroup.IsDeleted) 92 SceneObjectGroup sog = part.ParentGroup;
93 if (sog == null || sog.IsDeleted)
93 return; 94 return;
94 95
95 if (part.OwnerID != part.GroupID && part.OwnerID != client.AgentId && (!m_scene.Permissions.IsGod(client.AgentId))) 96 // Does the user have the power to put the object on sale?
96 return; 97 if (!m_scene.Permissions.CanSellObject(client, sog, saleType))
97
98 if (part.OwnerID == part.GroupID) // Group owned
99 { 98 {
100 // Does the user have the power to put the object on sale? 99 client.SendAgentAlertMessage("You don't have permission to set object on sale", false);
101 if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID, m_scene)) 100 return;
102 {
103 client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false);
104 return;
105 }
106 } 101 }
107 102
108 part = part.ParentGroup.RootPart; 103 part = sog.RootPart;
109 104
110 part.ObjectSaleType = saleType; 105 part.ObjectSaleType = saleType;
111 part.SalePrice = salePrice; 106 part.SalePrice = salePrice;
112 107
113 part.ParentGroup.HasGroupChanged = true; 108 sog.HasGroupChanged = true;
114 109
115 part.SendPropertiesToClient(client); 110 part.SendPropertiesToClient(client);
116 } 111 }
@@ -127,7 +122,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
127 switch (saleType) 122 switch (saleType)
128 { 123 {
129 case 1: // Sell as original (in-place sale) 124 case 1: // Sell as original (in-place sale)
130 uint effectivePerms = group.GetEffectivePermissions(); 125 uint effectivePerms = group.EffectiveOwnerPerms;
131 126
132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 127 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
133 { 128 {
@@ -136,8 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
136 return false; 131 return false;
137 } 132 }
138 133
139 group.SetOwnerId(remoteClient.AgentId); 134 group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
140 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
141 135
142 if (m_scene.Permissions.PropagatePermissions()) 136 if (m_scene.Permissions.PropagatePermissions())
143 { 137 {
@@ -147,6 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
147 child.TriggerScriptChangedEvent(Changed.OWNER); 141 child.TriggerScriptChangedEvent(Changed.OWNER);
148 child.ApplyNextOwnerPermissions(); 142 child.ApplyNextOwnerPermissions();
149 } 143 }
144 group.AggregatePerms();
150 } 145 }
151 146
152 part.ObjectSaleType = 0; 147 part.ObjectSaleType = 0;
@@ -174,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
174 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); 169 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
175 group.AbsolutePosition = originalPosition; 170 group.AbsolutePosition = originalPosition;
176 171
177 uint perms = group.GetEffectivePermissions(); 172 uint perms = group.EffectiveOwnerPerms;
178 173
179 if ((perms & (uint)PermissionMask.Transfer) == 0) 174 if ((perms & (uint)PermissionMask.Transfer) == 0)
180 { 175 {
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 75d90f3..8eee864 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected Scene m_scene; 51 protected Scene m_scene;
52 protected ScenePermissions scenePermissions;
52 protected bool m_Enabled; 53 protected bool m_Enabled;
53 54
54 private InventoryFolderImpl m_libraryRootFolder; 55 private InventoryFolderImpl m_libraryRootFolder;
@@ -69,15 +70,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
69 } 70 }
70 71
71 #region Constants 72 #region Constants
72 // These are here for testing. They will be taken out
73
74 //private uint PERM_ALL = (uint)2147483647;
75 private uint PERM_COPY = (uint)32768;
76 //private uint PERM_MODIFY = (uint)16384;
77 private uint PERM_MOVE = (uint)524288;
78 private uint PERM_TRANS = (uint)8192;
79 private uint PERM_LOCKED = (uint)540672;
80
81 /// <value> 73 /// <value>
82 /// Different user set names that come in from the configuration file. 74 /// Different user set names that come in from the configuration file.
83 /// </value> 75 /// </value>
@@ -96,14 +88,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
96 private bool m_bypassPermissionsValue = true; 88 private bool m_bypassPermissionsValue = true;
97 private bool m_propagatePermissions = false; 89 private bool m_propagatePermissions = false;
98 private bool m_debugPermissions = false; 90 private bool m_debugPermissions = false;
99 private bool m_allowGridGods = false; 91 private bool m_allowGridAdmins = false;
100 private bool m_RegionOwnerIsGod = false; 92 private bool m_RegionOwnerIsAdmin = false;
101 private bool m_RegionManagerIsGod = false; 93 private bool m_RegionManagerIsAdmin = false;
102 private bool m_forceGridGodsOnly; 94 private bool m_forceGridAdminsOnly;
103 private bool m_forceGodModeAlwaysOn; 95 private bool m_forceAdminModeAlwaysOn;
104 private bool m_allowGodActionsWithoutGodMode; 96 private bool m_allowAdminActionsWithoutGodMode;
105
106 private bool m_SimpleBuildPermissions = false;
107 97
108 /// <value> 98 /// <value>
109 /// The set of users that are allowed to create scripts. This is only active if permissions are not being 99 /// The set of users that are allowed to create scripts. This is only active if permissions are not being
@@ -172,25 +162,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
172 162
173 string[] sections = new string[] { "Startup", "Permissions" }; 163 string[] sections = new string[] { "Startup", "Permissions" };
174 164
175 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false); 165 m_allowGridAdmins = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false);
176 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true); 166 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true);
177 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true); 167 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true);
178 168
179 m_forceGridGodsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false); 169 m_forceGridAdminsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false);
180 if(!m_forceGridGodsOnly) 170 if(!m_forceGridAdminsOnly)
181 { 171 {
182 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true); 172 m_RegionOwnerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true);
183 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false); 173 m_RegionManagerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false);
184 } 174 }
185 else 175 else
186 m_allowGridGods = true; 176 m_allowGridAdmins = true;
187 177
188 m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false); 178 m_forceAdminModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false);
189 m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false); 179 m_allowAdminActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false);
190 if(m_allowGodActionsWithoutGodMode) 180 if(m_allowAdminActionsWithoutGodMode)
191 m_forceGodModeAlwaysOn = false; 181 m_forceAdminModeAlwaysOn = false;
192
193 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions",sections, false);
194 182
195 m_allowedScriptCreators 183 m_allowedScriptCreators
196 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators); 184 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);
@@ -266,63 +254,78 @@ namespace OpenSim.Region.CoreModules.World.Permissions
266 m_scene = scene; 254 m_scene = scene;
267 255
268 scene.RegisterModuleInterface<IPermissionsModule>(this); 256 scene.RegisterModuleInterface<IPermissionsModule>(this);
257 scenePermissions = m_scene.Permissions;
269 258
270 //Register functions with Scene External Checks! 259 //Register functions with Scene External Checks!
271 m_scene.Permissions.OnBypassPermissions += BypassPermissions; 260 scenePermissions.OnBypassPermissions += BypassPermissions;
272 m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions; 261 scenePermissions.OnSetBypassPermissions += SetBypassPermissions;
273 m_scene.Permissions.OnPropagatePermissions += PropagatePermissions; 262 scenePermissions.OnPropagatePermissions += PropagatePermissions;
274 m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags; 263
275 m_scene.Permissions.OnAbandonParcel += CanAbandonParcel; 264 scenePermissions.OnIsGridGod += IsGridAdministrator;
276 m_scene.Permissions.OnReclaimParcel += CanReclaimParcel; 265 scenePermissions.OnIsAdministrator += IsAdministrator;
277 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 266 scenePermissions.OnIsEstateManager += IsEstateManager;
278 m_scene.Permissions.OnDeedObject += CanDeedObject; 267
279 m_scene.Permissions.OnIsGod += IsGod; 268 scenePermissions.OnGenerateClientFlags += GenerateClientFlags;
280 m_scene.Permissions.OnIsGridGod += IsGridGod; 269
281 m_scene.Permissions.OnIsAdministrator += IsAdministrator; 270 scenePermissions.OnIssueEstateCommand += CanIssueEstateCommand;
282 m_scene.Permissions.OnIsEstateManager += IsEstateManager; 271 scenePermissions.OnRunConsoleCommand += CanRunConsoleCommand;
283 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 272
284 m_scene.Permissions.OnDeleteObject += CanDeleteObject; 273 scenePermissions.OnTeleport += CanTeleport;
285 m_scene.Permissions.OnEditObject += CanEditObject; 274
286 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; 275 scenePermissions.OnInstantMessage += CanInstantMessage;
287 m_scene.Permissions.OnInstantMessage += CanInstantMessage; 276
288 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; 277 scenePermissions.OnAbandonParcel += CanAbandonParcel;
289 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; 278 scenePermissions.OnReclaimParcel += CanReclaimParcel;
290 m_scene.Permissions.OnMoveObject += CanMoveObject; 279 scenePermissions.OnDeedParcel += CanDeedParcel;
291 m_scene.Permissions.OnObjectEntry += CanObjectEntry; 280 scenePermissions.OnSellParcel += CanSellParcel;
292 m_scene.Permissions.OnReturnObjects += CanReturnObjects; 281 scenePermissions.OnEditParcelProperties += CanEditParcelProperties;
293 m_scene.Permissions.OnRezObject += CanRezObject; 282 scenePermissions.OnTerraformLand += CanTerraformLand;
294 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; 283 scenePermissions.OnBuyLand += CanBuyLand;
295 m_scene.Permissions.OnRunScript += CanRunScript; 284
296 m_scene.Permissions.OnCompileScript += CanCompileScript; 285 scenePermissions.OnReturnObjects += CanReturnObjects;
297 m_scene.Permissions.OnSellParcel += CanSellParcel; 286
298 m_scene.Permissions.OnTakeObject += CanTakeObject; 287 scenePermissions.OnRezObject += CanRezObject;
299 m_scene.Permissions.OnSellGroupObject += CanSellGroupObject; 288 scenePermissions.OnObjectEntry += CanObjectEntry;
300 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; 289 scenePermissions.OnObjectEnterWithScripts += OnObjectEnterWithScripts;
301 m_scene.Permissions.OnTerraformLand += CanTerraformLand; 290
302 m_scene.Permissions.OnLinkObject += CanLinkObject; 291 scenePermissions.OnDuplicateObject += CanDuplicateObject;
303 m_scene.Permissions.OnDelinkObject += CanDelinkObject; 292 scenePermissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs;
304 m_scene.Permissions.OnBuyLand += CanBuyLand; 293 scenePermissions.OnDeleteObject += CanDeleteObject;
305 294 scenePermissions.OnEditObjectByIDs += CanEditObjectByIDs;
306 m_scene.Permissions.OnViewNotecard += CanViewNotecard; 295 scenePermissions.OnEditObject += CanEditObject;
307 m_scene.Permissions.OnViewScript += CanViewScript; 296 scenePermissions.OnInventoryTransfer += CanInventoryTransfer;
308 m_scene.Permissions.OnEditNotecard += CanEditNotecard; 297 scenePermissions.OnMoveObject += CanMoveObject;
309 m_scene.Permissions.OnEditScript += CanEditScript; 298 scenePermissions.OnTakeObject += CanTakeObject;
310 299 scenePermissions.OnTakeCopyObject += CanTakeCopyObject;
311 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; 300 scenePermissions.OnLinkObject += CanLinkObject;
312 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; 301 scenePermissions.OnDelinkObject += CanDelinkObject;
313 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; 302 scenePermissions.OnDeedObject += CanDeedObject;
314 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; 303 scenePermissions.OnSellGroupObject += CanSellGroupObject;
315 m_scene.Permissions.OnResetScript += CanResetScript; 304 scenePermissions.OnSellObjectByUserID += CanSellObjectByUserID;
316 305 scenePermissions.OnSellObject += CanSellObject;
317 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; 306
318 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; 307 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory;
319 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; 308 scenePermissions.OnEditObjectInventory += CanEditObjectInventory;
320 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; 309 scenePermissions.OnCopyObjectInventory += CanCopyObjectInventory;
321 310 scenePermissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
322 m_scene.Permissions.OnTeleport += CanTeleport; 311 scenePermissions.OnDoObjectInvToObjectInv += CanDoObjectInvToObjectInv;
323 312 scenePermissions.OnDropInObjectInv += CanDropInObjectInv;
324 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; 313
325 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; 314 scenePermissions.OnViewNotecard += CanViewNotecard;
315 scenePermissions.OnViewScript += CanViewScript;
316 scenePermissions.OnEditNotecard += CanEditNotecard;
317 scenePermissions.OnEditScript += CanEditScript;
318 scenePermissions.OnResetScript += CanResetScript;
319 scenePermissions.OnRunScript += CanRunScript;
320 scenePermissions.OnCompileScript += CanCompileScript;
321
322 scenePermissions.OnCreateUserInventory += CanCreateUserInventory;
323 scenePermissions.OnCopyUserInventory += CanCopyUserInventory;
324 scenePermissions.OnEditUserInventory += CanEditUserInventory;
325 scenePermissions.OnDeleteUserInventory += CanDeleteUserInventory;
326
327 scenePermissions.OnControlPrimMedia += CanControlPrimMedia;
328 scenePermissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
326 329
327 m_scene.AddCommand("Users", this, "bypass permissions", 330 m_scene.AddCommand("Users", this, "bypass permissions",
328 "bypass permissions <true / false>", 331 "bypass permissions <true / false>",
@@ -351,6 +354,78 @@ namespace OpenSim.Region.CoreModules.World.Permissions
351 return; 354 return;
352 355
353 m_scene.UnregisterModuleInterface<IPermissionsModule>(this); 356 m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
357
358 scenePermissions.OnBypassPermissions -= BypassPermissions;
359 scenePermissions.OnSetBypassPermissions -= SetBypassPermissions;
360 scenePermissions.OnPropagatePermissions -= PropagatePermissions;
361
362 scenePermissions.OnIsGridGod -= IsGridAdministrator;
363 scenePermissions.OnIsAdministrator -= IsAdministrator;
364 scenePermissions.OnIsEstateManager -= IsEstateManager;
365
366 scenePermissions.OnGenerateClientFlags -= GenerateClientFlags;
367
368 scenePermissions.OnIssueEstateCommand -= CanIssueEstateCommand;
369 scenePermissions.OnRunConsoleCommand -= CanRunConsoleCommand;
370
371 scenePermissions.OnTeleport -= CanTeleport;
372
373 scenePermissions.OnInstantMessage -= CanInstantMessage;
374
375 scenePermissions.OnAbandonParcel -= CanAbandonParcel;
376 scenePermissions.OnReclaimParcel -= CanReclaimParcel;
377 scenePermissions.OnDeedParcel -= CanDeedParcel;
378 scenePermissions.OnSellParcel -= CanSellParcel;
379 scenePermissions.OnEditParcelProperties -= CanEditParcelProperties;
380 scenePermissions.OnTerraformLand -= CanTerraformLand;
381 scenePermissions.OnBuyLand -= CanBuyLand;
382
383 scenePermissions.OnRezObject -= CanRezObject;
384 scenePermissions.OnObjectEntry -= CanObjectEntry;
385 scenePermissions.OnObjectEnterWithScripts -= OnObjectEnterWithScripts;
386
387 scenePermissions.OnReturnObjects -= CanReturnObjects;
388
389 scenePermissions.OnDuplicateObject -= CanDuplicateObject;
390 scenePermissions.OnDeleteObjectByIDs -= CanDeleteObjectByIDs;
391 scenePermissions.OnDeleteObject -= CanDeleteObject;
392 scenePermissions.OnEditObjectByIDs -= CanEditObjectByIDs;
393 scenePermissions.OnEditObject -= CanEditObject;
394 scenePermissions.OnInventoryTransfer -= CanInventoryTransfer;
395 scenePermissions.OnMoveObject -= CanMoveObject;
396 scenePermissions.OnTakeObject -= CanTakeObject;
397 scenePermissions.OnTakeCopyObject -= CanTakeCopyObject;
398 scenePermissions.OnLinkObject -= CanLinkObject;
399 scenePermissions.OnDelinkObject -= CanDelinkObject;
400 scenePermissions.OnDeedObject -= CanDeedObject;
401
402 scenePermissions.OnSellGroupObject -= CanSellGroupObject;
403 scenePermissions.OnSellObjectByUserID -= CanSellObjectByUserID;
404 scenePermissions.OnSellObject -= CanSellObject;
405
406 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory;
407 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory;
408 scenePermissions.OnCopyObjectInventory -= CanCopyObjectInventory;
409 scenePermissions.OnDeleteObjectInventory -= CanDeleteObjectInventory;
410 scenePermissions.OnDoObjectInvToObjectInv -= CanDoObjectInvToObjectInv;
411 scenePermissions.OnDropInObjectInv -= CanDropInObjectInv;
412
413 scenePermissions.OnViewNotecard -= CanViewNotecard;
414 scenePermissions.OnViewScript -= CanViewScript;
415 scenePermissions.OnEditNotecard -= CanEditNotecard;
416 scenePermissions.OnEditScript -= CanEditScript;
417 scenePermissions.OnResetScript -= CanResetScript;
418 scenePermissions.OnRunScript -= CanRunScript;
419 scenePermissions.OnCompileScript -= CanCompileScript;
420
421 scenePermissions.OnCreateUserInventory -= CanCreateUserInventory;
422 scenePermissions.OnCopyUserInventory -= CanCopyUserInventory;
423 scenePermissions.OnEditUserInventory -= CanEditUserInventory;
424 scenePermissions.OnDeleteUserInventory -= CanDeleteUserInventory;
425
426 scenePermissions.OnControlPrimMedia -= CanControlPrimMedia;
427 scenePermissions.OnInteractWithPrimMedia -= CanInteractWithPrimMedia;
428
354 } 429 }
355 430
356 public void Close() 431 public void Close()
@@ -480,6 +555,36 @@ namespace OpenSim.Region.CoreModules.World.Permissions
480 return false; 555 return false;
481 } 556 }
482 557
558 protected bool GroupMemberPowers(UUID groupID, UUID userID, ref ulong powers)
559 {
560 powers = 0;
561 if (null == GroupsModule)
562 return false;
563
564 GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID);
565
566 if (gmd != null)
567 {
568 powers = gmd.GroupPowers;
569 return true;
570 }
571 return false;
572 }
573
574 protected bool GroupMemberPowers(UUID groupID, ScenePresence sp, ref ulong powers)
575 {
576 powers = 0;
577 IClientAPI client = sp.ControllingClient;
578 if (client == null)
579 return false;
580
581 if(!client.IsGroupMember(groupID))
582 return false;
583
584 powers = client.GetGroupPowers(groupID);
585 return true;
586 }
587
483 /// <summary> 588 /// <summary>
484 /// Parse a user set configuration setting 589 /// Parse a user set configuration setting
485 /// </summary> 590 /// </summary>
@@ -526,13 +631,13 @@ namespace OpenSim.Region.CoreModules.World.Permissions
526 if (user == UUID.Zero) 631 if (user == UUID.Zero)
527 return false; 632 return false;
528 633
529 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) 634 if (m_RegionOwnerIsAdmin && m_scene.RegionInfo.EstateSettings.EstateOwner == user)
530 return true; 635 return true;
531 636
532 if (IsEstateManager(user) && m_RegionManagerIsGod) 637 if (m_RegionManagerIsAdmin && IsEstateManager(user))
533 return true; 638 return true;
534 639
535 if (IsGridGod(user, null)) 640 if (IsGridAdministrator(user))
536 return true; 641 return true;
537 642
538 return false; 643 return false;
@@ -544,14 +649,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
544 /// <param name="user">The user</param> 649 /// <param name="user">The user</param>
545 /// <param name="scene">Unused, can be null</param> 650 /// <param name="scene">Unused, can be null</param>
546 /// <returns></returns> 651 /// <returns></returns>
547 protected bool IsGridGod(UUID user, Scene scene) 652 protected bool IsGridAdministrator(UUID user)
548 { 653 {
549 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 654 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
550 if (m_bypassPermissions) return m_bypassPermissionsValue; 655 if (m_bypassPermissions) return m_bypassPermissionsValue;
551 656
552 if (user == UUID.Zero) return false; 657 if (user == UUID.Zero)
658 return false;
553 659
554 if (m_allowGridGods) 660 if (m_allowGridAdmins)
555 { 661 {
556 ScenePresence sp = m_scene.GetScenePresence(user); 662 ScenePresence sp = m_scene.GetScenePresence(user);
557 if (sp != null) 663 if (sp != null)
@@ -567,10 +673,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
567 673
568 protected bool IsFriendWithPerms(UUID user, UUID objectOwner) 674 protected bool IsFriendWithPerms(UUID user, UUID objectOwner)
569 { 675 {
570 if (user == UUID.Zero) 676 if (FriendsModule == null)
571 return false; 677 return false;
572 678
573 if (FriendsModule == null) 679 if (user == UUID.Zero)
574 return false; 680 return false;
575 681
576 int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner); 682 int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner);
@@ -606,75 +712,178 @@ namespace OpenSim.Region.CoreModules.World.Permissions
606 712
607 #region Object Permissions 713 #region Object Permissions
608 714
609 public uint GenerateClientFlags(UUID user, UUID objID) 715 const uint DEFAULT_FLAGS = (uint)(
610 { 716 PrimFlags.ObjectCopy | // Tells client you can copy the object
611 // Here's the way this works, 717 PrimFlags.ObjectModify | // tells client you can modify the object
612 // ObjectFlags and Permission flags are two different enumerations 718 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
613 // ObjectFlags, however, tells the client to change what it will allow the user to do. 719 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
614 // So, that means that all of the permissions type ObjectFlags are /temporary/ and only 720 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
615 // supposed to be set when customizing the objectflags for the client. 721 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
722 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
723 );
724
725 const uint NOT_DEFAULT_FLAGS = (uint)~(
726 PrimFlags.ObjectCopy | // Tells client you can copy the object
727 PrimFlags.ObjectModify | // tells client you can modify the object
728 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
729 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
730 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
731 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
732 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
733 );
734
735 const uint EXTRAOWNERMASK = (uint)(
736 PrimFlags.ObjectYouOwner |
737 PrimFlags.ObjectAnyOwner
738 );
739
740 const uint EXTRAGODMASK = (uint)(
741 PrimFlags.ObjectYouOwner |
742 PrimFlags.ObjectAnyOwner |
743 PrimFlags.ObjectOwnerModify |
744 PrimFlags.ObjectModify |
745 PrimFlags.ObjectMove
746 );
747
748 const uint GOD_FLAGS = (uint)(
749 PrimFlags.ObjectCopy | // Tells client you can copy the object
750 PrimFlags.ObjectModify | // tells client you can modify the object
751 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
752 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
753 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
754 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
755 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
756 );
757
758 const uint LOCKED_GOD_FLAGS = (uint)(
759 PrimFlags.ObjectCopy | // Tells client you can copy the object
760 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
761 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
762 PrimFlags.ObjectAnyOwner // Tells client that someone owns the object
763 );
764
765 const uint SHAREDMASK = (uint)(
766 PermissionMask.Move |
767 PermissionMask.Modify |
768 PermissionMask.Copy
769 );
770
771 public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
772 {
773 if(sp == null || task == null || curEffectivePerms == 0)
774 return 0;
616 775
617 // These temporary objectflags get computed and added in this function based on the 776 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
618 // Permission mask that's appropriate! 777 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
619 // Outside of this method, they should never be added to objectflags!
620 // -teravus
621 778
622 SceneObjectPart task = m_scene.GetSceneObjectPart(objID); 779 uint returnMask;
623 780
624 // this shouldn't ever happen.. return no permissions/objectflags. 781 SceneObjectGroup grp = task.ParentGroup;
625 if (task == null) 782 if(grp == null)
626 return (uint)0; 783 return 0;
627 784
628 uint objflags = task.GetEffectiveObjectFlags(); 785 UUID taskOwnerID = task.OwnerID;
629 UUID objectOwner = task.OwnerID; 786 UUID spID = sp.UUID;
630 787
788 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
631 789
632 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 790 if(sp.IsGod)
633 // in the next bit of code 791 {
634 792 // do locked on objects owned by admin
635 // libomv will moan about PrimFlags.ObjectYouOfficer being 793 if(!unlocked && spID == taskOwnerID)
636 // deprecated 794 return objflags | LOCKED_GOD_FLAGS;
637#pragma warning disable 0612 795 else
638 objflags &= (uint) 796 return objflags | GOD_FLAGS;
639 ~(PrimFlags.ObjectCopy | // Tells client you can copy the object 797 }
640 PrimFlags.ObjectModify | // tells client you can modify the object 798
641 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod) 799 //bypass option == owner rights
642 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 800 if (m_bypassPermissions)
643 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
644 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
645 PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
646 PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
647 );
648#pragma warning restore 0612
649
650 // Creating the three ObjectFlags options for this method to choose from.
651 // Customize the OwnerMask
652 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
653 objectOwnerMask |= (uint)PrimFlags.ObjectYouOwner | (uint)PrimFlags.ObjectAnyOwner | (uint)PrimFlags.ObjectOwnerModify;
654
655 // Customize the GroupMask
656 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
657
658 // Customize the EveryoneMask
659 uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags);
660 if (objectOwner != UUID.Zero)
661 objectEveryoneMask |= (uint)PrimFlags.ObjectAnyOwner;
662
663 PermissionClass permissionClass = GetPermissionClass(user, task);
664
665 switch (permissionClass)
666 { 801 {
667 case PermissionClass.Owner: 802 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); //??
668 return objectOwnerMask; 803 returnMask |= EXTRAOWNERMASK;
669 case PermissionClass.Group: 804 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
670 return objectGroupMask | objectEveryoneMask; 805 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
671 case PermissionClass.Everyone: 806 return returnMask;
672 default:
673 return objectEveryoneMask;
674 } 807 }
808
809 // owner
810 if (spID == taskOwnerID)
811 {
812 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
813 returnMask |= EXTRAOWNERMASK;
814 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
815 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
816 return returnMask;
817 }
818
819 // if not god or owner, do attachments as everyone
820 if(task.ParentGroup.IsAttachment)
821 {
822 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
823 if (taskOwnerID != UUID.Zero)
824 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
825 return returnMask;
826 }
827
828 UUID taskGroupID = task.GroupID;
829 bool notGroupdOwned = taskOwnerID != taskGroupID;
830
831 // if friends with rights then owner
832 if (notGroupdOwned && IsFriendWithPerms(spID, taskOwnerID))
833 {
834 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
835 returnMask |= EXTRAOWNERMASK;
836 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
837 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
838 return returnMask;
839 }
840
841 // group owned or shared ?
842 IClientAPI client = sp.ControllingClient;
843 ulong powers = 0;
844 if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers))
845 {
846 if(notGroupdOwned)
847 {
848 // group sharing or everyone
849 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
850 if (taskOwnerID != UUID.Zero)
851 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
852 return returnMask;
853 }
854
855 // object is owned by group, check role powers
856 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
857 {
858 // group sharing or everyone
859 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
860 returnMask |=
861 (uint)PrimFlags.ObjectGroupOwned |
862 (uint)PrimFlags.ObjectAnyOwner;
863 return returnMask;
864 }
865
866 // we may have copy without transfer
867 uint grpEffectiveOwnerPerms = grp.EffectiveOwnerPerms;
868 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
869 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
870 returnMask = ApplyObjectModifyMasks(grpEffectiveOwnerPerms, objflags, unlocked);
871 returnMask |=
872 (uint)PrimFlags.ObjectGroupOwned |
873 (uint)PrimFlags.ObjectYouOwner;
874 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
875 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
876 return returnMask;
877 }
878
879 // fallback is everyone rights
880 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
881 if (taskOwnerID != UUID.Zero)
882 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
883 return returnMask;
675 } 884 }
676 885
677 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask) 886 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask, bool unlocked)
678 { 887 {
679 // We are adding the temporary objectflags to the object's objectflags based on the 888 // We are adding the temporary objectflags to the object's objectflags based on the
680 // permission flag given. These change the F flags on the client. 889 // permission flag given. These change the F flags on the client.
@@ -684,14 +893,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
684 objectFlagsMask |= (uint)PrimFlags.ObjectCopy; 893 objectFlagsMask |= (uint)PrimFlags.ObjectCopy;
685 } 894 }
686 895
687 if ((setPermissionMask & (uint)PermissionMask.Move) != 0) 896 if (unlocked)
688 { 897 {
689 objectFlagsMask |= (uint)PrimFlags.ObjectMove; 898 if ((setPermissionMask & (uint)PermissionMask.Move) != 0)
690 } 899 {
900 objectFlagsMask |= (uint)PrimFlags.ObjectMove;
901 }
691 902
692 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0) 903 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0)
693 { 904 {
694 objectFlagsMask |= (uint)PrimFlags.ObjectModify; 905 objectFlagsMask |= (uint)PrimFlags.ObjectModify;
906 }
695 } 907 }
696 908
697 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0) 909 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0)
@@ -702,6 +914,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
702 return objectFlagsMask; 914 return objectFlagsMask;
703 } 915 }
704 916
917 // OARs still need this method that handles offline users
705 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj) 918 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj)
706 { 919 {
707 if (obj == null) 920 if (obj == null)
@@ -715,136 +928,199 @@ namespace OpenSim.Region.CoreModules.World.Permissions
715 if (user == objectOwner) 928 if (user == objectOwner)
716 return PermissionClass.Owner; 929 return PermissionClass.Owner;
717 930
718 if (IsFriendWithPerms(user, objectOwner) && !obj.ParentGroup.IsAttachment)
719 return PermissionClass.Owner;
720
721 // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set
722 if (m_RegionOwnerIsGod && IsEstateManager(user) && !IsAdministrator(objectOwner))
723 return PermissionClass.Owner;
724
725 // Admin should be able to edit anything in the sim (including admin objects) 931 // Admin should be able to edit anything in the sim (including admin objects)
726 if (IsAdministrator(user)) 932 if (IsAdministrator(user))
727 return PermissionClass.Owner; 933 return PermissionClass.Owner;
728 934
729/* to review later 935 if(!obj.ParentGroup.IsAttachment)
730 // Users should be able to edit what is over their land.
731 Vector3 taskPos = obj.AbsolutePosition;
732 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
733 if (parcel != null && parcel.LandData.OwnerID == user && m_ParcelOwnerIsGod)
734 { 936 {
735 // Admin objects should not be editable by the above 937 if (IsFriendWithPerms(user, objectOwner) )
736 if (!IsAdministrator(objectOwner))
737 return PermissionClass.Owner; 938 return PermissionClass.Owner;
939
940 // Group permissions
941 if (obj.GroupID != UUID.Zero && IsGroupMember(obj.GroupID, user, 0))
942 return PermissionClass.Group;
738 } 943 }
739*/
740 // Group permissions
741 if ((obj.GroupID != UUID.Zero) && IsGroupMember(obj.GroupID, user, 0))
742 return PermissionClass.Group;
743 944
744 return PermissionClass.Everyone; 945 return PermissionClass.Everyone;
745 } 946 }
746 947
747 /// <summary> 948 // get effective object permissions using user UUID. User rights will be fixed
748 /// General permissions checks for any operation involving an object. These supplement more specific checks 949 protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked)
749 /// implemented by callers.
750 /// </summary>
751 /// <param name="currentUser"></param>
752 /// <param name="objId">This is a scene object group UUID</param>
753 /// <param name="denyOnLocked"></param>
754 /// <returns></returns>
755 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
756 { 950 {
757 // Default: deny 951 if (group == null)
758 bool permission = false; 952 return 0;
759 bool locked = false;
760 953
761 SceneObjectPart part = m_scene.GetSceneObjectPart(objId); 954 SceneObjectPart root = group.RootPart;
762 955 if (root == null)
763 if (part == null) 956 return 0;
764 return false;
765
766 SceneObjectGroup group = part.ParentGroup;
767 957
768 UUID objectOwner = group.OwnerID; 958 UUID objectOwner = group.OwnerID;
769 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 959 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
770 960
771 // People shouldn't be able to do anything with locked objects, except the Administrator 961 if (IsAdministrator(currentUser))
772 // The 'set permissions' runs through a different permission check, so when an object owner
773 // sets an object locked, the only thing that they can do is unlock it.
774 //
775 // Nobody but the object owner can set permissions on an object
776 //
777 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
778 { 962 {
779 return false; 963 // do lock on admin owned objects
964 if(locked && currentUser == objectOwner)
965 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
966 return (uint)PermissionMask.AllEffective;
780 } 967 }
781 968
782 // Object owners should be able to edit their own content 969 uint lockmask = (uint)PermissionMask.AllEffective;
970 if(locked)
971 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
972
783 if (currentUser == objectOwner) 973 if (currentUser == objectOwner)
784 { 974 return group.EffectiveOwnerPerms & lockmask;
785 // there is no way that later code can change this back to false 975
786 // so just return true immediately and short circuit the more 976 if (group.IsAttachment)
787 // expensive group checks 977 return 0;
788 return true;
789 978
790 //permission = true; 979 UUID sogGroupID = group.GroupID;
791 } 980 bool notgroudOwned = sogGroupID != objectOwner;
792 else if (group.IsAttachment)
793 {
794 permission = false;
795 }
796 981
797// m_log.DebugFormat( 982 if (notgroudOwned && IsFriendWithPerms(currentUser, objectOwner))
798// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", 983 return group.EffectiveOwnerPerms & lockmask;
799// group.GroupID,
800// m_scene.GetSceneObjectPart(objId).GroupMask,
801// IsGroupMember(group.GroupID, currentUser, 0),
802// currentUser);
803
804 // Group members should be able to edit group objects
805 if ((group.GroupID != UUID.Zero)
806 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
807 && IsGroupMember(group.GroupID, currentUser, 0))
808 {
809 // Return immediately, so that the administrator can shares group objects
810 return true;
811 }
812 984
813 // Friends with benefits should be able to edit the objects too 985 ulong powers = 0;
814 if (IsFriendWithPerms(currentUser, objectOwner)) 986 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, currentUser, ref powers))
815 { 987 {
816 // Return immediately, so that the administrator can share objects with friends 988 if(notgroudOwned)
817 return true; 989 return group.EffectiveGroupOrEveryOnePerms & lockmask;
990
991 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
992 return group.EffectiveGroupOrEveryOnePerms & lockmask;
993
994 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
995 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
996 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
997 return grpEffectiveOwnerPerms;
818 } 998 }
819 999
820 // Users should be able to edit what is over their land. 1000 return group.EffectiveEveryOnePerms & lockmask;
821 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); 1001 }
822 if ((parcel != null) && (parcel.LandData.OwnerID == currentUser)) 1002
1003 // get effective object permissions using present presence. So some may depend on requested rights (ie God)
1004 protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked)
1005 {
1006 if (sp == null || sp.IsDeleted || group == null || group.IsDeleted)
1007 return 0;
1008
1009 SceneObjectPart root = group.RootPart;
1010 if (root == null)
1011 return 0;
1012
1013 UUID spID = sp.UUID;
1014 UUID objectOwner = group.OwnerID;
1015
1016 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
1017
1018 if (sp.IsGod)
823 { 1019 {
824 permission = true; 1020 if(locked && spID == objectOwner)
1021 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
1022 return (uint)PermissionMask.AllEffective;
825 } 1023 }
826 1024
827 // Estate users should be able to edit anything in the sim 1025 uint lockmask = (uint)PermissionMask.AllEffective;
828 if (IsEstateManager(currentUser)) 1026 if(locked)
1027 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
1028
1029 if (spID == objectOwner)
1030 return group.EffectiveOwnerPerms & lockmask;
1031
1032 if (group.IsAttachment)
1033 return 0;
1034
1035 UUID sogGroupID = group.GroupID;
1036 bool notgroudOwned = sogGroupID != objectOwner;
1037
1038 if (notgroudOwned && IsFriendWithPerms(spID, objectOwner))
1039 return group.EffectiveOwnerPerms & lockmask;
1040
1041 ulong powers = 0;
1042 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, sp, ref powers))
829 { 1043 {
830 permission = true; 1044 if(notgroudOwned)
1045 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1046
1047 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
1048 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1049
1050 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
1051 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1052 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
1053 return grpEffectiveOwnerPerms;
831 } 1054 }
832 1055
833 // Admin objects should not be editable by the above 1056 return group.EffectiveEveryOnePerms & lockmask;
834 if (IsAdministrator(objectOwner)) 1057 }
1058
1059 private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti)
1060 {
1061 UUID tiOwnerID = ti.OwnerID;
1062 if(tiOwnerID == userID)
1063 return ti.CurrentPermissions;
1064
1065 if(IsAdministrator(userID))
1066 return (uint)PermissionMask.AllEffective;
1067 // ??
1068 if (IsFriendWithPerms(userID, tiOwnerID))
1069 return ti.CurrentPermissions;
1070
1071 UUID tiGroupID = ti.GroupID;
1072 if(tiGroupID != UUID.Zero)
835 { 1073 {
836 permission = false; 1074 ulong powers = 0;
1075 if(GroupMemberPowers(tiGroupID, userID, ref powers))
1076 {
1077 if(tiGroupID == ti.OwnerID)
1078 {
1079 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1080 return ti.CurrentPermissions;
1081 }
1082 return ti.GroupPermissions;
1083 }
837 } 1084 }
838 1085
839 // Admin should be able to edit anything in the sim (including admin objects) 1086 return 0;
840 if (IsAdministrator(currentUser)) 1087 }
1088
1089 private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone)
1090 {
1091 UUID tiOwnerID = ti.OwnerID;
1092 UUID spID = sp.UUID;
1093
1094 if(tiOwnerID == spID)
1095 return ti.CurrentPermissions;
1096
1097 // ??
1098 if (IsFriendWithPerms(spID, tiOwnerID))
1099 return ti.CurrentPermissions;
1100
1101 UUID tiGroupID = ti.GroupID;
1102 if(tiGroupID != UUID.Zero)
841 { 1103 {
842 permission = true; 1104 ulong powers = 0;
1105 if(GroupMemberPowers(tiGroupID, spID, ref powers))
1106 {
1107 if(tiGroupID == ti.OwnerID)
1108 {
1109 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1110 return ti.CurrentPermissions;
1111 }
1112 uint p = ti.GroupPermissions;
1113 if(!notEveryone)
1114 p |= ti.EveryonePermissions;
1115 return p;
1116 }
843 } 1117 }
844 1118
845 return permission; 1119 if(notEveryone)
846 } 1120 return 0;
847 1121
1122 return ti.EveryonePermissions;
1123 }
848 #endregion 1124 #endregion
849 1125
850 #region Generic Permissions 1126 #region Generic Permissions
@@ -869,89 +1145,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
869 1145
870 public bool GenericEstatePermission(UUID user) 1146 public bool GenericEstatePermission(UUID user)
871 { 1147 {
872 // Default: deny
873 bool permission = false;
874
875 // Estate admins should be able to use estate tools 1148 // Estate admins should be able to use estate tools
876 if (IsEstateManager(user)) 1149 if (IsEstateManager(user))
877 permission = true; 1150 return true;
878 1151
879 // Administrators always have permission 1152 // Administrators always have permission
880 if (IsAdministrator(user)) 1153 if (IsAdministrator(user))
881 permission = true; 1154 return true;
882
883 return permission;
884 }
885
886 protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
887 {
888 bool permission = false;
889
890 if (parcel.LandData.OwnerID == user)
891 {
892 permission = true;
893 }
894
895 if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
896 {
897 permission = true;
898 }
899
900 if (IsEstateManager(user))
901 {
902 permission = true;
903 }
904
905 if (IsAdministrator(user))
906 {
907 permission = true;
908 }
909
910 if (m_SimpleBuildPermissions &&
911 (parcel.LandData.Flags & (uint)ParcelFlags.UseAccessList) == 0 && parcel.IsInLandAccessList(user))
912 permission = true;
913 1155
914 return permission; 1156 return false;
915 } 1157 }
916 1158
917 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager) 1159 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager)
918 { 1160 {
919 if (parcel.LandData.OwnerID == user) 1161 if (parcel.LandData.OwnerID == user)
920 {
921 // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
922 // the subsequent redundant checks when using lParcelMediaCommandList()
923 // See http://opensimulator.org/mantis/view.php?id=3999 for more details
924 return true; 1162 return true;
925 }
926 1163
927 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers)) 1164 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
928 {
929 return true; 1165 return true;
930 }
931 1166
932 if (allowEstateManager && IsEstateManager(user)) 1167 if (allowEstateManager && IsEstateManager(user))
933 {
934 return true; 1168 return true;
935 }
936 1169
937 if (IsAdministrator(user)) 1170 if (IsAdministrator(user))
938 {
939 return true; 1171 return true;
940 }
941 1172
942 return false; 1173 return false;
943 } 1174 }
944
945 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
946 {
947 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
948 if (parcel == null) return false;
949 return GenericParcelPermission(user, parcel, groupPowers);
950 }
951#endregion 1175#endregion
952 1176
953 #region Permission Checks 1177 #region Permission Checks
954 private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) 1178 private bool CanAbandonParcel(UUID user, ILandObject parcel)
955 { 1179 {
956 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1180 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
957 if (m_bypassPermissions) return m_bypassPermissionsValue; 1181 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -959,7 +1183,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
959 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false); 1183 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false);
960 } 1184 }
961 1185
962 private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) 1186 private bool CanReclaimParcel(UUID user, ILandObject parcel)
963 { 1187 {
964 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1188 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
965 if (m_bypassPermissions) return m_bypassPermissionsValue; 1189 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -967,108 +1191,223 @@ namespace OpenSim.Region.CoreModules.World.Permissions
967 return GenericParcelOwnerPermission(user, parcel, 0,true); 1191 return GenericParcelOwnerPermission(user, parcel, 0,true);
968 } 1192 }
969 1193
970 private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) 1194 private bool CanDeedParcel(UUID user, ILandObject parcel)
971 { 1195 {
972 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1196 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
973 if (m_bypassPermissions) return m_bypassPermissionsValue; 1197 if (m_bypassPermissions) return m_bypassPermissionsValue;
974 1198
1199 if(parcel.LandData.GroupID == UUID.Zero)
1200 return false;
1201
1202 if (IsAdministrator(user))
1203 return true;
1204
975 if (parcel.LandData.OwnerID != user) // Only the owner can deed! 1205 if (parcel.LandData.OwnerID != user) // Only the owner can deed!
976 return false; 1206 return false;
977 1207
978 ScenePresence sp = scene.GetScenePresence(user); 1208 ScenePresence sp = m_scene.GetScenePresence(user);
979 IClientAPI client = sp.ControllingClient; 1209 if(sp == null)
1210 return false;
980 1211
1212 IClientAPI client = sp.ControllingClient;
981 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) 1213 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
982 return false; 1214 return false;
983 1215
984 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); 1216 return true;
985 } 1217 }
986 1218
987 private bool CanDeedObject(UUID user, UUID group, Scene scene) 1219 private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
988 { 1220 {
989 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1221 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
990 if (m_bypassPermissions) return m_bypassPermissionsValue; 1222 if (m_bypassPermissions) return m_bypassPermissionsValue;
991 1223
992 ScenePresence sp = scene.GetScenePresence(user); 1224 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted || targetGroupID == UUID.Zero)
993 IClientAPI client = sp.ControllingClient; 1225 return false;
1226
1227 // object has group already?
1228 if(sog.GroupID != targetGroupID)
1229 return false;
1230
1231 // is effectivelly shared?
1232 if(sog.EffectiveGroupPerms == 0)
1233 return false;
1234
1235 if(sp.IsGod)
1236 return true;
1237
1238 // owned by requester?
1239 if(sog.OwnerID != sp.UUID)
1240 return false;
1241
1242 // owner can transfer?
1243 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1244 return false;
1245
1246 // group member ?
1247 ulong powers = 0;
1248 if(!GroupMemberPowers(targetGroupID, sp, ref powers))
1249 return false;
994 1250
995 if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) 1251 // has group rights?
1252 if ((powers & (ulong)GroupPowers.DeedObject) == 0)
996 return false; 1253 return false;
997 1254
998 return true; 1255 return true;
999 } 1256 }
1000 1257
1001 private bool IsGod(UUID user, Scene scene) 1258 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
1002 { 1259 {
1003 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1260 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1004 if (m_bypassPermissions) return m_bypassPermissionsValue; 1261 if (m_bypassPermissions) return m_bypassPermissionsValue;
1005 1262
1006 return IsAdministrator(user); 1263 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1264 return false;
1265
1266 uint perms = GetObjectPermissions(sp, sog, false);
1267 if((perms & (uint)PermissionMask.Copy) == 0)
1268 return false;
1269
1270 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1271 return false;
1272
1273 //If they can rez, they can duplicate
1274 return CanRezObject(0, sp.UUID, sog.AbsolutePosition);
1007 } 1275 }
1008 1276
1009 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition) 1277 private bool CanDeleteObject(SceneObjectGroup sog, ScenePresence sp)
1010 { 1278 {
1279 // ignoring locked. viewers should warn and ask for confirmation
1280
1011 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1281 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1012 if (m_bypassPermissions) return m_bypassPermissionsValue; 1282 if (m_bypassPermissions) return m_bypassPermissionsValue;
1013 1283
1014 if (!GenericObjectPermission(owner, objectID, true)) 1284 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1015 {
1016 //They can't even edit the object
1017 return false; 1285 return false;
1018 }
1019 1286
1020 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1287 if(sog.IsAttachment)
1021 if (part == null)
1022 return false; 1288 return false;
1023 1289
1024 if (part.OwnerID == owner) 1290 UUID sogOwnerID = sog.OwnerID;
1291 UUID spID = sp.UUID;
1292
1293 if(sogOwnerID == spID)
1294 return true;
1295
1296 if (sp.IsGod)
1297 return true;
1298
1299 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1300 return true;
1301
1302 UUID sogGroupID = sog.GroupID;
1303 if (sogGroupID != UUID.Zero)
1025 { 1304 {
1026 if ((part.OwnerMask & PERM_COPY) == 0) 1305 ulong powers = 0;
1027 return false; 1306 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1307 {
1308 if(sogGroupID == sogOwnerID)
1309 {
1310 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1311 return true;
1312 }
1313 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1314 }
1028 } 1315 }
1029 else if (part.GroupID != UUID.Zero) 1316 return false;
1030 { 1317 }
1031 if ((part.OwnerID == part.GroupID) && ((owner != part.LastOwnerID) || ((part.GroupMask & PERM_TRANS) == 0)))
1032 return false;
1033 1318
1034 if ((part.GroupMask & PERM_COPY) == 0) 1319 private bool CanDeleteObjectByIDs(UUID objectID, UUID userID)
1035 return false; 1320 {
1036 } 1321 // ignoring locked. viewers should warn and ask for confirmation
1037 1322
1038 //If they can rez, they can duplicate 1323 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1039 return CanRezObject(objectCount, owner, objectPosition, scene); 1324 if (m_bypassPermissions) return m_bypassPermissionsValue;
1325
1326 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1327 if (sog == null)
1328 return false;
1329
1330 if(sog.IsAttachment)
1331 return false;
1332
1333 UUID sogOwnerID = sog.OwnerID;
1334
1335 if(sogOwnerID == userID)
1336 return true;
1337
1338 if (IsAdministrator(userID))
1339 return true;
1340
1341 if (IsFriendWithPerms(objectID, sogOwnerID))
1342 return true;
1343
1344 UUID sogGroupID = sog.GroupID;
1345 if (sogGroupID != UUID.Zero)
1346 {
1347 ulong powers = 0;
1348 if(GroupMemberPowers(sogGroupID, userID, ref powers))
1349 {
1350 if(sogGroupID == sogOwnerID)
1351 {
1352 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1353 return true;
1354 }
1355 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1356 }
1357 }
1358 return false;
1040 } 1359 }
1041 1360
1042 private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene) 1361 private bool CanEditObjectByIDs(UUID objectID, UUID userID)
1043 { 1362 {
1044 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1363 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1045 if (m_bypassPermissions) return m_bypassPermissionsValue; 1364 if (m_bypassPermissions) return m_bypassPermissionsValue;
1046 1365
1047 return GenericObjectPermission(deleter, objectID, false); 1366 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1367 if (sog == null)
1368 return false;
1369
1370 uint perms = GetObjectPermissions(userID, sog, true);
1371 if((perms & (uint)PermissionMask.Modify) == 0)
1372 return false;
1373 return true;
1048 } 1374 }
1049 1375
1050 private bool CanEditObject(UUID objectID, UUID editorID, Scene scene) 1376 private bool CanEditObject(SceneObjectGroup sog, ScenePresence sp)
1051 { 1377 {
1052 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1378 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1053 if (m_bypassPermissions) return m_bypassPermissionsValue; 1379 if (m_bypassPermissions) return m_bypassPermissionsValue;
1054 1380
1055 return GenericObjectPermission(editorID, objectID, false); 1381 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1382 return false;
1383
1384 uint perms = GetObjectPermissions(sp, sog, true);
1385 if((perms & (uint)PermissionMask.Modify) == 0)
1386 return false;
1387 return true;
1056 } 1388 }
1057 1389
1058 private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene) 1390 private bool CanEditObjectInventory(UUID objectID, UUID userID)
1059 { 1391 {
1060 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1392 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1061 if (m_bypassPermissions) return m_bypassPermissionsValue; 1393 if (m_bypassPermissions) return m_bypassPermissionsValue;
1062 1394
1063 return GenericObjectPermission(editorID, objectID, false); 1395 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1396 if (sog == null)
1397 return false;
1398
1399 uint perms = GetObjectPermissions(userID, sog, true);
1400 if((perms & (uint)PermissionMask.Modify) == 0)
1401 return false;
1402 return true;
1064 } 1403 }
1065 1404
1066 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager) 1405 private bool CanEditParcelProperties(UUID userID, ILandObject parcel, GroupPowers p, bool allowManager)
1067 { 1406 {
1068 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1407 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1069 if (m_bypassPermissions) return m_bypassPermissionsValue; 1408 if (m_bypassPermissions) return m_bypassPermissionsValue;
1070 1409
1071 return GenericParcelOwnerPermission(user, parcel, (ulong)p, false); 1410 return GenericParcelOwnerPermission(userID, parcel, (ulong)p, false);
1072 } 1411 }
1073 1412
1074 /// <summary> 1413 /// <summary>
@@ -1079,18 +1418,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1079 /// <param name="user"></param> 1418 /// <param name="user"></param>
1080 /// <param name="scene"></param> 1419 /// <param name="scene"></param>
1081 /// <returns></returns> 1420 /// <returns></returns>
1082 private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene) 1421 private bool CanEditScript(UUID script, UUID objectID, UUID userID)
1083 { 1422 {
1084 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1423 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1085 if (m_bypassPermissions) return m_bypassPermissionsValue; 1424 if (m_bypassPermissions) return m_bypassPermissionsValue;
1086 1425
1087 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user)) 1426 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(userID))
1088 return false; 1427 return false;
1089 1428
1090 // Ordinarily, if you can view it, you can edit it 1429 // Ordinarily, if you can view it, you can edit it
1091 // There is no viewing a no mod script 1430 // There is no viewing a no mod script
1092 // 1431 //
1093 return CanViewScript(script, objectID, user, scene); 1432 return CanViewScript(script, objectID, userID);
1094 } 1433 }
1095 1434
1096 /// <summary> 1435 /// <summary>
@@ -1101,7 +1440,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1101 /// <param name="user"></param> 1440 /// <param name="user"></param>
1102 /// <param name="scene"></param> 1441 /// <param name="scene"></param>
1103 /// <returns></returns> 1442 /// <returns></returns>
1104 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 1443 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user)
1105 { 1444 {
1106 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1445 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1107 if (m_bypassPermissions) return m_bypassPermissionsValue; 1446 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1132,69 +1471,68 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1132 } 1471 }
1133 else // Prim inventory 1472 else // Prim inventory
1134 { 1473 {
1135 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1474 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1136
1137 if (part == null) 1475 if (part == null)
1138 return false; 1476 return false;
1139 1477
1140 if (part.OwnerID != user) 1478 SceneObjectGroup sog = part.ParentGroup;
1141 { 1479 if (sog == null)
1142 if (part.GroupID == UUID.Zero) 1480 return false;
1143 return false;
1144
1145 if (!IsGroupMember(part.GroupID, user, 0))
1146 return false;
1147 1481
1148 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1482 // check object mod right
1149 return false; 1483 uint perms = GetObjectPermissions(user, sog, true);
1150 } 1484 if((perms & (uint)PermissionMask.Modify) == 0)
1151 else
1152 {
1153 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1154 return false; 1485 return false;
1155 }
1156 1486
1157 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 1487 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1158
1159 if (ti == null) 1488 if (ti == null)
1160 return false; 1489 return false;
1161 1490
1162 if (ti.OwnerID != user) 1491 if (ti.OwnerID != user)
1163 { 1492 {
1164 if (ti.GroupID == UUID.Zero) 1493 UUID tiGroupID = ti.GroupID;
1494 if (tiGroupID == UUID.Zero)
1165 return false; 1495 return false;
1166 1496
1167 if (!IsGroupMember(ti.GroupID, user, 0)) 1497 ulong powers = 0;
1498 if(!GroupMemberPowers(tiGroupID, user, ref powers))
1168 return false; 1499 return false;
1500
1501 if(tiGroupID == ti.OwnerID && (powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1502 {
1503 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1504 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1505 return true;
1506 }
1507 if ((ti.GroupPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1508 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1509 return true;
1510 return false;
1169 } 1511 }
1170 1512
1171 // Require full perms 1513 // Require full perms
1172 if ((ti.CurrentPermissions & 1514 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) !=
1173 ((uint)PermissionMask.Modify | 1515 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1174 (uint)PermissionMask.Copy)) !=
1175 ((uint)PermissionMask.Modify |
1176 (uint)PermissionMask.Copy))
1177 return false; 1516 return false;
1178 } 1517 }
1179
1180 return true; 1518 return true;
1181 } 1519 }
1182 1520
1183 private bool CanInstantMessage(UUID user, UUID target, Scene startScene) 1521 private bool CanInstantMessage(UUID user, UUID target)
1184 { 1522 {
1185 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1523 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1186 if (m_bypassPermissions) return m_bypassPermissionsValue; 1524 if (m_bypassPermissions) return m_bypassPermissionsValue;
1187 1525
1188 // If the sender is an object, check owner instead 1526 // If the sender is an object, check owner instead
1189 // 1527 //
1190 SceneObjectPart part = startScene.GetSceneObjectPart(user); 1528 SceneObjectPart part = m_scene.GetSceneObjectPart(user);
1191 if (part != null) 1529 if (part != null)
1192 user = part.OwnerID; 1530 user = part.OwnerID;
1193 1531
1194 return GenericCommunicationPermission(user, target); 1532 return GenericCommunicationPermission(user, target);
1195 } 1533 }
1196 1534
1197 private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene) 1535 private bool CanInventoryTransfer(UUID user, UUID target)
1198 { 1536 {
1199 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1537 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1200 if (m_bypassPermissions) return m_bypassPermissionsValue; 1538 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1202,7 +1540,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1202 return GenericCommunicationPermission(user, target); 1540 return GenericCommunicationPermission(user, target);
1203 } 1541 }
1204 1542
1205 private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand) 1543 private bool CanIssueEstateCommand(UUID user, bool ownerCommand)
1206 { 1544 {
1207 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1545 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1208 if (m_bypassPermissions) return m_bypassPermissionsValue; 1546 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1210,178 +1548,162 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1210 if (IsAdministrator(user)) 1548 if (IsAdministrator(user))
1211 return true; 1549 return true;
1212 1550
1213 if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
1214 return true;
1215
1216 if (ownerCommand) 1551 if (ownerCommand)
1217 return false; 1552 return m_scene.RegionInfo.EstateSettings.IsEstateOwner(user);
1218 1553
1219 return GenericEstatePermission(user); 1554 return IsEstateManager(user);
1220 } 1555 }
1221 1556
1222 private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene) 1557 private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
1223 { 1558 {
1224 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1559 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1560
1561 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1562 return false;
1563
1225 if (m_bypassPermissions) 1564 if (m_bypassPermissions)
1226 { 1565 {
1227 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1566 if (sog.OwnerID != sp.UUID && sog.IsAttachment)
1228 if (part.OwnerID != moverID) 1567 return false;
1229 {
1230 if (!part.ParentGroup.IsDeleted)
1231 {
1232 if (part.ParentGroup.IsAttachment)
1233 return false;
1234 }
1235 }
1236 return m_bypassPermissionsValue; 1568 return m_bypassPermissionsValue;
1237 } 1569 }
1238 1570
1239 bool permission = GenericObjectPermission(moverID, objectID, true); 1571 uint perms = GetObjectPermissions(sp, sog, true);
1240 if (!permission) 1572 if((perms & (uint)PermissionMask.Move) == 0)
1241 { 1573 return false;
1242 if (!m_scene.Entities.ContainsKey(objectID)) 1574 return true;
1243 { 1575 }
1244 return false;
1245 }
1246 1576
1247 // The client 1577 private bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
1248 // may request to edit linked parts, and therefore, it needs 1578 {
1249 // to also check for SceneObjectPart 1579 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1250 1580
1251 // If it's not an object, we cant edit it. 1581 float newX = newPoint.X;
1252 if ((!(m_scene.Entities[objectID] is SceneObjectGroup))) 1582 float newY = newPoint.Y;
1253 {
1254 return false;
1255 }
1256 1583
1584 // allow outside region this is needed for crossings
1585 if (newX < -1f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
1586 newY < -1f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
1587 return true;
1257 1588
1258 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1589 if(sog == null || sog.IsDeleted)
1590 return false;
1259 1591
1592 if (m_bypassPermissions)
1593 return m_bypassPermissionsValue;
1260 1594
1261 // UUID taskOwner = null; 1595 ILandObject parcel = m_scene.LandChannel.GetLandObject(newX, newY);
1262 // Added this because at this point in time it wouldn't be wise for 1596 if (parcel == null)
1263 // the administrator object permissions to take effect. 1597 return false;
1264 // UUID objectOwner = task.OwnerID;
1265 1598
1266 // Anyone can move 1599 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0)
1267 if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0) 1600 return true;
1268 permission = true;
1269 1601
1270 // Locked 1602 if (!enteringRegion)
1271 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
1272 permission = false;
1273 }
1274 else
1275 { 1603 {
1276 bool locked = false; 1604 Vector3 oldPoint = sog.AbsolutePosition;
1277 if (!m_scene.Entities.ContainsKey(objectID)) 1605 ILandObject fromparcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
1278 { 1606 if (fromparcel != null && fromparcel.Equals(parcel)) // it already entered parcel ????
1279 return false; 1607 return true;
1280 } 1608 }
1281
1282 // If it's not an object, we cant edit it.
1283 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1284 {
1285 return false;
1286 }
1287 1609
1288 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID]; 1610 UUID userID = sog.OwnerID;
1611 LandData landdata = parcel.LandData;
1289 1612
1290 UUID objectOwner = group.OwnerID; 1613 if (landdata.OwnerID == userID)
1291 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 1614 return true;
1292 1615
1293 // This is an exception to the generic object permission. 1616 if (IsAdministrator(userID))
1294 // Administrators who lock their objects should not be able to move them, 1617 return true;
1295 // however generic object permission should return true.
1296 // This keeps locked objects from being affected by random click + drag actions by accident
1297 // and allows the administrator to grab or delete a locked object.
1298 1618
1299 // Administrators and estate managers are still able to click+grab locked objects not 1619 UUID landGroupID = landdata.GroupID;
1300 // owned by them in the scene 1620 if (landGroupID != UUID.Zero)
1301 // This is by design. 1621 {
1622 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowGroupObjectEntry)) != 0)
1623 return IsGroupMember(landGroupID, userID, 0);
1302 1624
1303 if (locked && (moverID == objectOwner)) 1625 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1304 return false; 1626 return true;
1305 } 1627 }
1306 return permission; 1628
1629 //Otherwise, false!
1630 return false;
1307 } 1631 }
1308 1632
1309 private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 1633 private bool OnObjectEnterWithScripts(SceneObjectGroup sog, ILandObject parcel)
1310 { 1634 {
1311 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1635 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1312 if (m_bypassPermissions) return m_bypassPermissionsValue;
1313
1314 1636
1315 // allow outide region?? 1637 if(sog == null || sog.IsDeleted)
1316 if (newPoint.X < -1f || newPoint.Y < -1f) 1638 return false;
1317 return true;
1318 if (newPoint.X > scene.RegionInfo.RegionSizeX + 1.0f || newPoint.Y > scene.RegionInfo.RegionSizeY + 1.0f)
1319 {
1320 return true;
1321 }
1322 1639
1323 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1640 if (m_bypassPermissions)
1641 return m_bypassPermissionsValue;
1324 1642
1325 ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 1643 if (parcel == null)
1644 return true;
1326 1645
1327 if (!enteringRegion) 1646 int checkflags = ((int)ParcelFlags.AllowAPrimitiveEntry);
1328 { 1647 bool scripts = (sog.ScriptCount() > 0);
1329 ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); 1648 if(scripts)
1649 checkflags |= ((int)ParcelFlags.AllowOtherScripts);
1330 1650
1331 if (fromland == land) // Not entering 1651 if ((parcel.LandData.Flags & checkflags) == checkflags)
1332 return true; 1652 return true;
1333 }
1334 1653
1335 if (land == null) 1654 UUID userID = sog.OwnerID;
1336 { 1655 LandData landdata = parcel.LandData;
1337 return false;
1338 }
1339 1656
1340 if ((land.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0) 1657 if (landdata.OwnerID == userID)
1341 {
1342 return true; 1658 return true;
1343 }
1344 1659
1345 if (!m_scene.Entities.ContainsKey(objectID)) 1660 if (IsAdministrator(userID))
1346 { 1661 return true;
1347 return false;
1348 }
1349 1662
1350 // If it's not an object, we cant edit it. 1663 UUID landGroupID = landdata.GroupID;
1351 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1664 if (landGroupID != UUID.Zero)
1352 { 1665 {
1353 return false; 1666 checkflags = (int)ParcelFlags.AllowGroupObjectEntry;
1354 } 1667 if(scripts)
1668 checkflags |= ((int)ParcelFlags.AllowGroupScripts);
1355 1669
1670 if ((parcel.LandData.Flags & checkflags) == checkflags)
1671 return IsGroupMember(landGroupID, userID, 0);
1356 1672
1357 if (GenericParcelPermission(task.OwnerID, newPoint, 0)) 1673 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1358 { 1674 return true;
1359 return true;
1360 } 1675 }
1361 1676
1362 //Otherwise, false! 1677 //Otherwise, false!
1363 return false; 1678 return false;
1364 } 1679 }
1365 1680
1366 private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) 1681
1682 private bool CanReturnObjects(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects)
1367 { 1683 {
1368 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1684 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1369 if (m_bypassPermissions) return m_bypassPermissionsValue; 1685 if (m_bypassPermissions) return m_bypassPermissionsValue;
1370 1686
1371 GroupPowers powers; 1687 if(sp == null)
1372 ILandObject l; 1688 return true; // assuming that in this case rights are as owner
1373 1689
1374 ScenePresence sp = scene.GetScenePresence(user); 1690 UUID userID = sp.UUID;
1375 if (sp == null) 1691 bool isPrivUser = sp.IsGod || IsEstateManager(userID);
1376 return false;
1377 1692
1378 IClientAPI client = sp.ControllingClient; 1693 IClientAPI client = sp.ControllingClient;
1379 1694
1695 ulong powers = 0;
1696 ILandObject l;
1697
1380 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects)) 1698 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
1381 { 1699 {
1382 // Any user can return their own objects at any time 1700 if(g.IsAttachment)
1383 // 1701 {
1384 if (GenericObjectPermission(user, g.UUID, false)) 1702 objects.Remove(g);
1703 continue;
1704 }
1705
1706 if (isPrivUser || g.OwnerID == userID)
1385 continue; 1707 continue;
1386 1708
1387 // This is a short cut for efficiency. If land is non-null, 1709 // This is a short cut for efficiency. If land is non-null,
@@ -1395,39 +1717,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1395 else 1717 else
1396 { 1718 {
1397 Vector3 pos = g.AbsolutePosition; 1719 Vector3 pos = g.AbsolutePosition;
1398 1720 l = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1399 l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
1400 } 1721 }
1401 1722
1402 // If it's not over any land, then we can't do a thing 1723 // If it's not over any land, then we can't do a thing
1403 if (l == null) 1724 if (l == null || l.LandData == null)
1404 { 1725 {
1405 objects.Remove(g); 1726 objects.Remove(g);
1406 continue; 1727 continue;
1407 } 1728 }
1408 1729
1730 LandData ldata = l.LandData;
1409 // If we own the land outright, then allow 1731 // If we own the land outright, then allow
1410 // 1732 //
1411 if (l.LandData.OwnerID == user) 1733 if (ldata.OwnerID == userID)
1412 continue; 1734 continue;
1413 1735
1414 // Group voodoo 1736 // Group voodoo
1415 // 1737 //
1416 if (l.LandData.IsGroupOwned) 1738 if (ldata.IsGroupOwned)
1417 { 1739 {
1418 powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); 1740 UUID lGroupID = ldata.GroupID;
1419 // Not a group member, or no rights at all 1741 // Not a group member, or no rights at all
1420 // 1742 //
1421 if (powers == (GroupPowers)0) 1743 powers = client.GetGroupPowers(lGroupID);
1744 if(powers == 0)
1422 { 1745 {
1423 objects.Remove(g); 1746 objects.Remove(g);
1424 continue; 1747 continue;
1425 } 1748 }
1426 1749
1427 // Group deeded object? 1750 // Group deeded object?
1428 // 1751 //
1429 if (g.OwnerID == l.LandData.GroupID && 1752 if (g.OwnerID == lGroupID &&
1430 (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) 1753 (powers & (ulong)GroupPowers.ReturnGroupOwned) == 0)
1431 { 1754 {
1432 objects.Remove(g); 1755 objects.Remove(g);
1433 continue; 1756 continue;
@@ -1435,14 +1758,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1435 1758
1436 // Group set object? 1759 // Group set object?
1437 // 1760 //
1438 if (g.GroupID == l.LandData.GroupID && 1761 if (g.GroupID == lGroupID &&
1439 (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) 1762 (powers & (ulong)GroupPowers.ReturnGroupSet) == 0)
1440 { 1763 {
1441 objects.Remove(g); 1764 objects.Remove(g);
1442 continue; 1765 continue;
1443 } 1766 }
1444 1767
1445 if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) 1768 if ((powers & (ulong)GroupPowers.ReturnNonGroup) == 0)
1446 { 1769 {
1447 objects.Remove(g); 1770 objects.Remove(g);
1448 continue; 1771 continue;
@@ -1465,41 +1788,41 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1465 return true; 1788 return true;
1466 } 1789 }
1467 1790
1468 private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) 1791 private bool CanRezObject(int objectCount, UUID userID, Vector3 objectPosition)
1469 { 1792 {
1470 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1793 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1471 if (m_bypassPermissions) return m_bypassPermissionsValue; 1794 if (m_bypassPermissions)
1795 return m_bypassPermissionsValue;
1472 1796
1473// m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name); 1797// m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name);
1474 1798
1475 ILandObject parcel = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 1799 ILandObject parcel = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
1476 if (parcel == null) 1800 if (parcel == null || parcel.LandData == null)
1477 return false; 1801 return false;
1478 1802
1479 if ((parcel.LandData.Flags & (uint)ParcelFlags.CreateObjects) != 0) 1803 LandData landdata = parcel.LandData;
1480 { 1804 if ((userID == landdata.OwnerID))
1481 return true; 1805 return true;
1482 } 1806
1483 else if ((owner == parcel.LandData.OwnerID) || IsAdministrator(owner)) 1807 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0)
1484 {
1485 return true;
1486 }
1487 else if (((parcel.LandData.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1488 && (parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, owner, 0))
1489 {
1490 return true; 1808 return true;
1491 } 1809
1492 else if (parcel.LandData.GroupID != UUID.Zero && IsGroupMember(parcel.LandData.GroupID, owner, (ulong)GroupPowers.AllowRez)) 1810 if(IsAdministrator(userID))
1493 {
1494 return true; 1811 return true;
1495 } 1812
1496 else 1813 if(landdata.GroupID != UUID.Zero)
1497 { 1814 {
1498 return false; 1815 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1816 return IsGroupMember(landdata.GroupID, userID, 0);
1817
1818 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowRez))
1819 return true;
1499 } 1820 }
1821
1822 return false;
1500 } 1823 }
1501 1824
1502 private bool CanRunConsoleCommand(UUID user, Scene requestFromScene) 1825 private bool CanRunConsoleCommand(UUID user)
1503 { 1826 {
1504 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1827 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1505 if (m_bypassPermissions) return m_bypassPermissionsValue; 1828 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1508,15 +1831,43 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1508 return IsAdministrator(user); 1831 return IsAdministrator(user);
1509 } 1832 }
1510 1833
1511 private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene) 1834 private bool CanRunScript(TaskInventoryItem scriptitem, SceneObjectPart part)
1512 { 1835 {
1513 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1836 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1514 if (m_bypassPermissions) return m_bypassPermissionsValue; 1837 if (m_bypassPermissions) return m_bypassPermissionsValue;
1515 1838
1516 return true; 1839 if(scriptitem == null || part == null)
1840 return false;
1841
1842 SceneObjectGroup sog = part.ParentGroup;
1843 if(sog == null)
1844 return false;
1845
1846 Vector3 pos = sog.AbsolutePosition;
1847 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1848 if (parcel == null)
1849 return false;
1850
1851 LandData ldata = parcel.LandData;
1852 if(ldata == null)
1853 return false;
1854
1855 uint lflags = ldata.Flags;
1856
1857 if ((lflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
1858 return true;
1859
1860 if ((part.OwnerID == ldata.OwnerID))
1861 return true;
1862
1863 if (((lflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
1864 && (ldata.GroupID != UUID.Zero) && (ldata.GroupID == part.GroupID))
1865 return true;
1866
1867 return GenericEstatePermission(part.OwnerID);
1517 } 1868 }
1518 1869
1519 private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) 1870 private bool CanSellParcel(UUID user, ILandObject parcel)
1520 { 1871 {
1521 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1872 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1522 if (m_bypassPermissions) return m_bypassPermissionsValue; 1873 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1524,7 +1875,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1524 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true); 1875 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true);
1525 } 1876 }
1526 1877
1527 private bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 1878 private bool CanSellGroupObject(UUID userID, UUID groupID)
1528 { 1879 {
1529 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1880 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1530 if (m_bypassPermissions) return m_bypassPermissionsValue; 1881 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1532,66 +1883,159 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1532 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale); 1883 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1533 } 1884 }
1534 1885
1535 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 1886 private bool CanSellObjectByUserID(SceneObjectGroup sog, UUID userID, byte saleType)
1536 { 1887 {
1537 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1888 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1538 if (m_bypassPermissions) return m_bypassPermissionsValue; 1889 if (m_bypassPermissions) return m_bypassPermissionsValue;
1539 1890
1540 return GenericObjectPermission(stealer,objectID, false); 1891 if (sog == null || sog.IsDeleted || userID == UUID.Zero)
1892 return false;
1893
1894 // sell is not a attachment op
1895 if(sog.IsAttachment)
1896 return false;
1897
1898 if(IsAdministrator(userID))
1899 return true;
1900
1901 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1902 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1903 return false;
1904
1905 if(saleType == (byte)SaleType.Copy &&
1906 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1907 return false;
1908
1909 UUID sogOwnerID = sog.OwnerID;
1910
1911 if(sogOwnerID == userID)
1912 return true;
1913
1914 // else only group owned can be sold by members with powers
1915 UUID sogGroupID = sog.GroupID;
1916 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1917 return false;
1918
1919 return IsGroupMember(sogGroupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1541 } 1920 }
1542 1921
1543 private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene) 1922 private bool CanSellObject(SceneObjectGroup sog, ScenePresence sp, byte saleType)
1544 { 1923 {
1545 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1924 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1546 if (m_bypassPermissions) return m_bypassPermissionsValue; 1925 if (m_bypassPermissions) return m_bypassPermissionsValue;
1547 1926
1548 bool permission = GenericObjectPermission(userID, objectID, false); 1927 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1928 return false;
1549 1929
1550 SceneObjectGroup so = (SceneObjectGroup)m_scene.Entities[objectID]; 1930 // sell is not a attachment op
1931 if(sog.IsAttachment)
1932 return false;
1551 1933
1552 if (!permission) 1934 if(sp.IsGod)
1553 { 1935 return true;
1554 if (!m_scene.Entities.ContainsKey(objectID))
1555 {
1556 return false;
1557 }
1558 1936
1559 // If it's not an object, we cant edit it. 1937 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1560 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1938 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1561 { 1939 return false;
1562 return false;
1563 }
1564 1940
1565 // UUID taskOwner = null; 1941 if(saleType == (byte)SaleType.Copy &&
1566 // Added this because at this point in time it wouldn't be wise for 1942 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1567 // the administrator object permissions to take effect. 1943 return false;
1568 // UUID objectOwner = task.OwnerID;
1569 1944
1570 if ((so.RootPart.EveryoneMask & PERM_COPY) != 0) 1945 UUID userID = sp.UUID;
1571 permission = true; 1946 UUID sogOwnerID = sog.OwnerID;
1572 }
1573 1947
1574 if (so.OwnerID != userID) 1948 if(sogOwnerID == userID)
1575 { 1949 return true;
1576 if ((so.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) 1950
1577 permission = false; 1951 // else only group owned can be sold by members with powers
1578 } 1952 UUID sogGroupID = sog.GroupID;
1579 else 1953 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1954 return false;
1955
1956 ulong powers = 0;
1957 if(!GroupMemberPowers(sogGroupID, sp, ref powers))
1958 return false;
1959
1960 if((powers & (ulong)GroupPowers.ObjectSetForSale) == 0)
1961 return false;
1962
1963 return true;
1964 }
1965
1966 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
1967 {
1968 // ignore locked, viewers shell ask for confirmation
1969 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1970 if (m_bypassPermissions) return m_bypassPermissionsValue;
1971
1972 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1973 return false;
1974
1975 // take is not a attachment op
1976 if(sog.IsAttachment)
1977 return false;
1978
1979 UUID sogOwnerID = sog.OwnerID;
1980 UUID spID = sp.UUID;
1981
1982 if(sogOwnerID == spID)
1983 return true;
1984
1985 if (sp.IsGod)
1986 return true;
1987
1988 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1989 return false;
1990
1991 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1992 return true;
1993
1994 UUID sogGroupID = sog.GroupID;
1995 if (sogGroupID != UUID.Zero)
1580 { 1996 {
1581 if ((so.GetEffectivePermissions() & PERM_COPY) != PERM_COPY) 1997 ulong powers = 0;
1582 permission = false; 1998 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1999 {
2000 if(sogGroupID == sogOwnerID)
2001 {
2002 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
2003 return true;
2004 }
2005 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
2006 }
1583 } 2007 }
2008 return false;
2009 }
1584 2010
1585 return permission; 2011 private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
2012 {
2013 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2014 if (m_bypassPermissions) return m_bypassPermissionsValue;
2015
2016 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
2017 return false;
2018
2019 // refuse on attachments
2020 if(sog.IsAttachment && !sp.IsGod)
2021 return false;
2022
2023 uint perms = GetObjectPermissions(sp, sog, true);
2024 if((perms & (uint)PermissionMask.Copy) == 0)
2025 return false;
2026
2027 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
2028 return false;
2029 return true;
1586 } 2030 }
1587 2031
1588 private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene) 2032 private bool CanTerraformLand(UUID userID, Vector3 position)
1589 { 2033 {
1590 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2034 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1591 if (m_bypassPermissions) return m_bypassPermissionsValue; 2035 if (m_bypassPermissions) return m_bypassPermissionsValue;
1592 2036
1593 // Estate override 2037 // Estate override
1594 if (GenericEstatePermission(user)) 2038 if (GenericEstatePermission(userID))
1595 return true; 2039 return true;
1596 2040
1597 float X = position.X; 2041 float X = position.X;
@@ -1609,13 +2053,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1609 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); 2053 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
1610 if (parcel == null) 2054 if (parcel == null)
1611 return false; 2055 return false;
1612 2056
1613 // Others allowed to terraform? 2057 LandData landdata = parcel.LandData;
1614 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowTerraform)) != 0) 2058 if (landdata == null)
2059 return false;
2060
2061 if ((landdata.Flags & ((int)ParcelFlags.AllowTerraform)) != 0)
1615 return true; 2062 return true;
1616 2063
1617 // Land owner can terraform too 2064 if(landdata.OwnerID == userID)
1618 if (parcel != null && GenericParcelPermission(user, parcel, (ulong)GroupPowers.AllowEditLand)) 2065 return true;
2066
2067 if (landdata.IsGroupOwned && parcel.LandData.GroupID != UUID.Zero &&
2068 IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowEditLand))
1619 return true; 2069 return true;
1620 2070
1621 return false; 2071 return false;
@@ -1629,15 +2079,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1629 /// <param name="user"></param> 2079 /// <param name="user"></param>
1630 /// <param name="scene"></param> 2080 /// <param name="scene"></param>
1631 /// <returns></returns> 2081 /// <returns></returns>
1632 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) 2082 private bool CanViewScript(UUID script, UUID objectID, UUID userID)
1633 { 2083 {
1634 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2084 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1635 if (m_bypassPermissions) return m_bypassPermissionsValue; 2085 if (m_bypassPermissions) return m_bypassPermissionsValue;
1636 2086
2087 // A god is a god is a god
2088 if (IsAdministrator(userID))
2089 return true;
2090
1637 if (objectID == UUID.Zero) // User inventory 2091 if (objectID == UUID.Zero) // User inventory
1638 { 2092 {
1639 IInventoryService invService = m_scene.InventoryService; 2093 IInventoryService invService = m_scene.InventoryService;
1640 InventoryItemBase assetRequestItem = invService.GetItem(user, script); 2094 InventoryItemBase assetRequestItem = invService.GetItem(userID, script);
1641 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2095 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1642 { 2096 {
1643 assetRequestItem = LibraryRootFolder.FindItem(script); 2097 assetRequestItem = LibraryRootFolder.FindItem(script);
@@ -1657,60 +2111,53 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1657 // readable only if it's really full perms 2111 // readable only if it's really full perms
1658 // 2112 //
1659 if ((assetRequestItem.CurrentPermissions & 2113 if ((assetRequestItem.CurrentPermissions &
2114/*
1660 ((uint)PermissionMask.Modify | 2115 ((uint)PermissionMask.Modify |
1661 (uint)PermissionMask.Copy | 2116 (uint)PermissionMask.Copy |
1662 (uint)PermissionMask.Transfer)) != 2117 (uint)PermissionMask.Transfer)) !=
1663 ((uint)PermissionMask.Modify | 2118 ((uint)PermissionMask.Modify |
1664 (uint)PermissionMask.Copy | 2119 (uint)PermissionMask.Copy |
1665 (uint)PermissionMask.Transfer)) 2120 (uint)PermissionMask.Transfer))
2121*/
2122 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2123 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1666 return false; 2124 return false;
1667 } 2125 }
1668 else // Prim inventory 2126 else // Prim inventory
1669 { 2127 {
1670 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2128 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1671
1672 if (part == null) 2129 if (part == null)
1673 return false; 2130 return false;
1674 2131
1675 if (part.OwnerID != user) 2132 SceneObjectGroup sog = part.ParentGroup;
1676 { 2133 if (sog == null)
1677 if (part.GroupID == UUID.Zero) 2134 return false;
1678 return false;
1679
1680 if (!IsGroupMember(part.GroupID, user, 0))
1681 return false;
1682 2135
1683 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 2136 uint perms = GetObjectPermissions(userID, sog, true);
1684 return false; 2137 if((perms & (uint)PermissionMask.Modify) == 0)
1685 } 2138 return false;
1686 else
1687 {
1688 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1689 return false;
1690 }
1691 2139
1692 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); 2140 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
1693 2141
1694 if (ti == null) 2142// if (ti == null || ti.InvType != (int)InventoryType.LSL)
2143 if (ti == null) // legacy may not have type
1695 return false; 2144 return false;
1696 2145
1697 if (ti.OwnerID != user) 2146 uint itperms = GetObjectItemPermissions(userID, ti);
1698 {
1699 if (ti.GroupID == UUID.Zero)
1700 return false;
1701
1702 if (!IsGroupMember(ti.GroupID, user, 0))
1703 return false;
1704 }
1705 2147
1706 // Require full perms 2148 // Require full perms
1707 if ((ti.CurrentPermissions & 2149
1708 ((uint)PermissionMask.Modify | 2150 if ((itperms &
2151/*
2152 ((uint)(PermissionMask.Modify |
1709 (uint)PermissionMask.Copy | 2153 (uint)PermissionMask.Copy |
1710 (uint)PermissionMask.Transfer)) != 2154 (uint)PermissionMask.Transfer)) !=
1711 ((uint)PermissionMask.Modify | 2155 ((uint)PermissionMask.Modify |
1712 (uint)PermissionMask.Copy | 2156 (uint)PermissionMask.Copy |
1713 (uint)PermissionMask.Transfer)) 2157 (uint)PermissionMask.Transfer))
2158*/
2159 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2160 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1714 return false; 2161 return false;
1715 } 2162 }
1716 2163
@@ -1725,15 +2172,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1725 /// <param name="user"></param> 2172 /// <param name="user"></param>
1726 /// <param name="scene"></param> 2173 /// <param name="scene"></param>
1727 /// <returns></returns> 2174 /// <returns></returns>
1728 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 2175 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID userID)
1729 { 2176 {
1730 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2177 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1731 if (m_bypassPermissions) return m_bypassPermissionsValue; 2178 if (m_bypassPermissions) return m_bypassPermissionsValue;
1732 2179
2180 // A god is a god is a god
2181 if (IsAdministrator(userID))
2182 return true;
2183
1733 if (objectID == UUID.Zero) // User inventory 2184 if (objectID == UUID.Zero) // User inventory
1734 { 2185 {
1735 IInventoryService invService = m_scene.InventoryService; 2186 IInventoryService invService = m_scene.InventoryService;
1736 InventoryItemBase assetRequestItem = invService.GetItem(user, notecard); 2187 InventoryItemBase assetRequestItem = invService.GetItem(userID, notecard);
1737 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2188 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1738 { 2189 {
1739 assetRequestItem = LibraryRootFolder.FindItem(notecard); 2190 assetRequestItem = LibraryRootFolder.FindItem(notecard);
@@ -1751,40 +2202,29 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1751 } 2202 }
1752 else // Prim inventory 2203 else // Prim inventory
1753 { 2204 {
1754 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2205 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1755
1756 if (part == null) 2206 if (part == null)
1757 return false; 2207 return false;
1758 2208
1759 if (part.OwnerID != user) 2209 SceneObjectGroup sog = part.ParentGroup;
1760 { 2210 if (sog == null)
1761 if (part.GroupID == UUID.Zero) 2211 return false;
1762 return false;
1763
1764 if (!IsGroupMember(part.GroupID, user, 0))
1765 return false;
1766 }
1767 2212
1768 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 2213 uint perms = GetObjectPermissions(userID, sog, true);
2214 if((perms & (uint)PermissionMask.Modify) == 0)
1769 return false; 2215 return false;
1770 2216
1771 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 2217 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1772 2218
2219// if (ti == null || ti.InvType != (int)InventoryType.Notecard)
1773 if (ti == null) 2220 if (ti == null)
1774 return false; 2221 return false;
1775 2222
1776 if (ti.OwnerID != user) 2223 uint itperms = GetObjectItemPermissions(userID, ti);
1777 {
1778 if (ti.GroupID == UUID.Zero)
1779 return false;
1780
1781 if (!IsGroupMember(ti.GroupID, user, 0))
1782 return false;
1783 }
1784 2224
1785 // Notecards are always readable unless no copy 2225 // Notecards are always readable unless no copy
1786 // 2226 //
1787 if ((ti.CurrentPermissions & 2227 if ((itperms &
1788 (uint)PermissionMask.Copy) != 2228 (uint)PermissionMask.Copy) !=
1789 (uint)PermissionMask.Copy) 2229 (uint)PermissionMask.Copy)
1790 return false; 2230 return false;
@@ -1800,7 +2240,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1800 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2240 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1801 if (m_bypassPermissions) return m_bypassPermissionsValue; 2241 if (m_bypassPermissions) return m_bypassPermissionsValue;
1802 2242
1803 return GenericObjectPermission(userID, objectID, false); 2243 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2244 if (sog == null)
2245 return false;
2246
2247 uint perms = GetObjectPermissions(userID, sog, true);
2248 if((perms & (uint)PermissionMask.Modify) == 0)
2249 return false;
2250 return true;
1804 } 2251 }
1805 2252
1806 private bool CanDelinkObject(UUID userID, UUID objectID) 2253 private bool CanDelinkObject(UUID userID, UUID objectID)
@@ -1808,10 +2255,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1808 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2255 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1809 if (m_bypassPermissions) return m_bypassPermissionsValue; 2256 if (m_bypassPermissions) return m_bypassPermissionsValue;
1810 2257
1811 return GenericObjectPermission(userID, objectID, false); 2258 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2259 if (sog == null)
2260 return false;
2261
2262 uint perms = GetObjectPermissions(userID, sog, true);
2263 if((perms & (uint)PermissionMask.Modify) == 0)
2264 return false;
2265 return true;
1812 } 2266 }
1813 2267
1814 private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene) 2268 private bool CanBuyLand(UUID userID, ILandObject parcel)
1815 { 2269 {
1816 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2270 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1817 if (m_bypassPermissions) return m_bypassPermissionsValue; 2271 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1824,6 +2278,130 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1824 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2278 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1825 if (m_bypassPermissions) return m_bypassPermissionsValue; 2279 if (m_bypassPermissions) return m_bypassPermissionsValue;
1826 2280
2281 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2282 if (part == null)
2283 return false;
2284
2285 SceneObjectGroup sog = part.ParentGroup;
2286 if (sog == null)
2287 return false;
2288
2289 uint perms = GetObjectPermissions(userID, sog, true);
2290 if((perms & (uint)PermissionMask.Modify) == 0)
2291 return false;
2292
2293 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2294 if(ti == null)
2295 return false;
2296
2297 uint itperms = GetObjectItemPermissions(userID, ti);
2298
2299 if((itperms & (uint)PermissionMask.Copy) == 0)
2300 return false;
2301
2302 if(sog.OwnerID != userID && (itperms & (uint)PermissionMask.Transfer) == 0)
2303 return false;
2304
2305 return true;
2306 }
2307
2308 // object inventory to object inventory item drag and drop
2309 private bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
2310 {
2311 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2312
2313 if (sourcePart == null || destPart == null || item == null)
2314 return false;
2315
2316 if (m_bypassPermissions)
2317 return m_bypassPermissionsValue;
2318
2319 SceneObjectGroup srcsog = sourcePart.ParentGroup;
2320 SceneObjectGroup destsog = destPart.ParentGroup;
2321 if (srcsog == null || destsog == null)
2322 return false;
2323
2324 // dest is locked
2325 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2326 return false;
2327
2328 uint itperms = item.CurrentPermissions;
2329
2330 // if item is no copy the source is modifed
2331 if((itperms & (uint)PermissionMask.Copy) == 0 && (srcsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2332 return false;
2333
2334 UUID srcOwner = srcsog.OwnerID;
2335 UUID destOwner = destsog.OwnerID;
2336 bool notSameOwner = srcOwner != destOwner;
2337
2338 if(notSameOwner)
2339 {
2340 if((itperms & (uint)PermissionMask.Transfer) == 0)
2341 return false;
2342
2343 // scripts can't be droped
2344 if(item.InvType == (int)InventoryType.LSL)
2345 return false;
2346
2347 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
2348 return false;
2349 }
2350 else
2351 {
2352 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0 &&
2353 (destsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2354 return false;
2355 }
2356
2357 return true;
2358 }
2359
2360 private bool CanDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart)
2361 {
2362 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2363
2364 if (sp == null || sp.IsDeleted || destPart == null || item == null)
2365 return false;
2366
2367 SceneObjectGroup destsog = destPart.ParentGroup;
2368 if (destsog == null || destsog.IsDeleted)
2369 return false;
2370
2371 if (m_bypassPermissions)
2372 return m_bypassPermissionsValue;
2373
2374 if(sp.IsGod)
2375 return true;
2376
2377 // dest is locked
2378 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2379 return false;
2380
2381 UUID destOwner = destsog.OwnerID;
2382 UUID spID = sp.UUID;
2383 bool spNotOwner = spID != destOwner;
2384
2385 // scripts can't be droped
2386 if(spNotOwner && item.InvType == (int)InventoryType.LSL)
2387 return false;
2388
2389 if(spNotOwner || item.Owner != destOwner)
2390 {
2391 // no copy item will be moved if it has transfer
2392 uint itperms = item.CurrentPermissions;
2393 if((itperms & (uint)PermissionMask.Transfer) == 0)
2394 return false;
2395 }
2396
2397 // allowdrop is a root part thing and does bypass modify rights
2398 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
2399 return true;
2400
2401 uint perms = GetObjectPermissions(spID, destsog, true);
2402 if((perms & (uint)PermissionMask.Modify) == 0)
2403 return false;
2404
1827 return true; 2405 return true;
1828 } 2406 }
1829 2407
@@ -1832,6 +2410,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1832 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2410 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1833 if (m_bypassPermissions) return m_bypassPermissionsValue; 2411 if (m_bypassPermissions) return m_bypassPermissionsValue;
1834 2412
2413 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2414 if (part == null)
2415 return false;
2416
2417 SceneObjectGroup sog = part.ParentGroup;
2418 if (sog == null)
2419 return false;
2420
2421 uint perms = GetObjectPermissions(userID, sog, true);
2422 if((perms & (uint)PermissionMask.Modify) == 0)
2423 return false;
2424
2425 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2426 if(ti == null)
2427 return false;
2428
2429 //TODO item perm ?
1835 return true; 2430 return true;
1836 } 2431 }
1837 2432
@@ -1848,26 +2443,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1848 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2443 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1849 if (m_bypassPermissions) return m_bypassPermissionsValue; 2444 if (m_bypassPermissions) return m_bypassPermissionsValue;
1850 2445
1851 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1852 ScenePresence p = m_scene.GetScenePresence(userID); 2446 ScenePresence p = m_scene.GetScenePresence(userID);
1853 2447
1854 if (part == null || p == null) 2448 if (p == null)
2449 return false;
2450
2451 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2452 if (sog == null)
2453 return false;
2454
2455 uint perms = GetObjectPermissions(userID, sog, true);
2456 if((perms & (uint)PermissionMask.Modify) == 0)
1855 return false; 2457 return false;
1856 2458
1857 if (!IsAdministrator(userID)) 2459 if ((int)InventoryType.LSL == invType)
1858 { 2460 {
1859 if (part.OwnerID != userID) 2461 if (m_allowedScriptCreators == UserSet.Administrators)
1860 { 2462 return false;
1861 // Group permissions
1862 if ((part.GroupID == UUID.Zero) || (p.ControllingClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
1863 return false;
1864 } else {
1865 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1866 return false;
1867 }
1868 if ((int)InventoryType.LSL == invType)
1869 if (m_allowedScriptCreators == UserSet.Administrators)
1870 return false;
1871 } 2463 }
1872 2464
1873 return true; 2465 return true;
@@ -1941,22 +2533,22 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1941 return true; 2533 return true;
1942 } 2534 }
1943 2535
1944 private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene) 2536 private bool CanResetScript(UUID primID, UUID script, UUID agentID)
1945 { 2537 {
1946 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2538 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1947 if (m_bypassPermissions) return m_bypassPermissionsValue; 2539 if (m_bypassPermissions) return m_bypassPermissionsValue;
1948 2540
1949 SceneObjectPart part = m_scene.GetSceneObjectPart(prim); 2541 SceneObjectGroup sog = m_scene.GetGroupByPrim(primID);
1950 2542 if (sog == null)
1951 // If we selected a sub-prim to reset, prim won't represent the object, but only a part. 2543 return false;
1952 // We have to check the permissions of the object, though.
1953 if (part.ParentID != 0) prim = part.ParentUUID;
1954 2544
1955 // You can reset the scripts in any object you can edit 2545 uint perms = GetObjectPermissions(agentID, sog, false);
1956 return GenericObjectPermission(agentID, prim, false); 2546 if((perms & (uint)PermissionMask.Modify) == 0) // ??
2547 return false;
2548 return true;
1957 } 2549 }
1958 2550
1959 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) 2551 private bool CanCompileScript(UUID ownerUUID, int scriptType)
1960 { 2552 {
1961 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); 2553 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
1962 switch (scriptType) { 2554 switch (scriptType) {
@@ -2014,7 +2606,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2014// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 2606// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
2015// agentID, primID, face, me.ControlPermissions); 2607// agentID, primID, face, me.ControlPermissions);
2016 2608
2017 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true); 2609 SceneObjectGroup sog = part.ParentGroup;
2610 if (sog == null)
2611 return false;
2612
2613 uint perms = GetObjectPermissions(agentID, sog, false);
2614 if((perms & (uint)PermissionMask.Modify) == 0)
2615 return false;
2616 return true;
2018 } 2617 }
2019 2618
2020 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 2619 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index 8bac9e6..bb3b860 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.World.Region
61 protected IDialogModule m_DialogModule = null; 61 protected IDialogModule m_DialogModule = null;
62 protected string m_MarkerPath = String.Empty; 62 protected string m_MarkerPath = String.Empty;
63 private int[] m_CurrentAlerts = null; 63 private int[] m_CurrentAlerts = null;
64 protected bool m_shortCircuitDelays = false;
65 protected bool m_rebootAll = false;
64 66
65 public void Initialise(IConfigSource config) 67 public void Initialise(IConfigSource config)
66 { 68 {
@@ -69,6 +71,9 @@ namespace OpenSim.Region.CoreModules.World.Region
69 { 71 {
70 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); 72 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
71 } 73 }
74 IConfig startupConfig = config.Configs["Startup"];
75 m_shortCircuitDelays = startupConfig.GetBoolean("SkipDelayOnEmptyRegion", false);
76 m_rebootAll = startupConfig.GetBoolean("InworldRestartShutsDown", false);
72 } 77 }
73 78
74 public void AddRegion(Scene scene) 79 public void AddRegion(Scene scene)
@@ -250,6 +255,14 @@ namespace OpenSim.Region.CoreModules.World.Region
250 private void OnTimer(object source, ElapsedEventArgs e) 255 private void OnTimer(object source, ElapsedEventArgs e)
251 { 256 {
252 int nextInterval = DoOneNotice(true); 257 int nextInterval = DoOneNotice(true);
258 if (m_shortCircuitDelays)
259 {
260 if (CountAgents() == 0)
261 {
262 m_Scene.RestartNow();
263 return;
264 }
265 }
253 266
254 SetTimer(nextInterval); 267 SetTimer(nextInterval);
255 } 268 }
@@ -349,5 +362,35 @@ namespace OpenSim.Region.CoreModules.World.Region
349 { 362 {
350 } 363 }
351 } 364 }
365
366 int CountAgents()
367 {
368 m_log.Info("[RESTART MODULE]: Counting affected avatars");
369 int agents = 0;
370
371 if (m_rebootAll)
372 {
373 foreach (Scene s in SceneManager.Instance.Scenes)
374 {
375 foreach (ScenePresence sp in s.GetScenePresences())
376 {
377 if (!sp.IsChildAgent && !sp.IsNPC)
378 agents++;
379 }
380 }
381 }
382 else
383 {
384 foreach (ScenePresence sp in m_Scene.GetScenePresences())
385 {
386 if (!sp.IsChildAgent && !sp.IsNPC)
387 agents++;
388 }
389 }
390
391 m_log.InfoFormat("[RESTART MODULE]: Avatars in region: {0}", agents);
392
393 return agents;
394 }
352 } 395 }
353} 396}
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index 04b6f00..167f6b5 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -105,8 +105,9 @@ namespace OpenSim.Region.CoreModules.World.Vegetation
105 if (rootPart.Shape.PCode != (byte)PCode.Grass) 105 if (rootPart.Shape.PCode != (byte)PCode.Grass)
106 AdaptTree(ref shape); 106 AdaptTree(ref shape);
107 107
108 m_scene.AddNewSceneObject(sceneObject, true);
109 sceneObject.SetGroup(groupID, null); 108 sceneObject.SetGroup(groupID, null);
109 m_scene.AddNewSceneObject(sceneObject, true);
110 sceneObject.AggregatePerms();
110 111
111 return sceneObject; 112 return sceneObject;
112 } 113 }