aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2017-03-30 17:39:21 +0100
committerUbitUmarov2017-03-30 17:39:21 +0100
commit9a01fddd1cefea0508b6b1616771e6ef8eabef87 (patch)
tree2e98a32008bb69965b9be3ef417b56cb60a49e25
parentmantis 8131: make the new Offline IM code optional and disabled by default, s... (diff)
downloadopensim-SC-9a01fddd1cefea0508b6b1616771e6ef8eabef87.zip
opensim-SC-9a01fddd1cefea0508b6b1616771e6ef8eabef87.tar.gz
opensim-SC-9a01fddd1cefea0508b6b1616771e6ef8eabef87.tar.bz2
opensim-SC-9a01fddd1cefea0508b6b1616771e6ef8eabef87.tar.xz
add CanSellObject() permitions check functions
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs21
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs87
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs106
4 files changed, 151 insertions, 66 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 9d84e66..2b5cb31 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -1649,8 +1649,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1649 { 1649 {
1650 foreach (SceneObjectGroup obj in primsOverMe) 1650 foreach (SceneObjectGroup obj in primsOverMe)
1651 { 1651 {
1652 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero && 1652 if(m_scene.Permissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original))
1653 (obj.EffectiveOwnerPerms & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0)
1654 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0); 1653 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0);
1655 } 1654 }
1656 } 1655 }
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 142c8b7..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)) 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 }
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 279b966..7f2b29a 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -300,6 +300,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
300 scenePermissions.OnDelinkObject += CanDelinkObject; 300 scenePermissions.OnDelinkObject += CanDelinkObject;
301 scenePermissions.OnDeedObject += CanDeedObject; 301 scenePermissions.OnDeedObject += CanDeedObject;
302 scenePermissions.OnSellGroupObject += CanSellGroupObject; 302 scenePermissions.OnSellGroupObject += CanSellGroupObject;
303 scenePermissions.OnSellObjectByUserID += CanSellObjectByUserID;
304 scenePermissions.OnSellObject += CanSellObject;
303 305
304 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory; 306 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory;
305 scenePermissions.OnEditObjectInventory += CanEditObjectInventory; 307 scenePermissions.OnEditObjectInventory += CanEditObjectInventory;
@@ -393,7 +395,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
393 scenePermissions.OnLinkObject -= CanLinkObject; 395 scenePermissions.OnLinkObject -= CanLinkObject;
394 scenePermissions.OnDelinkObject -= CanDelinkObject; 396 scenePermissions.OnDelinkObject -= CanDelinkObject;
395 scenePermissions.OnDeedObject -= CanDeedObject; 397 scenePermissions.OnDeedObject -= CanDeedObject;
398
396 scenePermissions.OnSellGroupObject -= CanSellGroupObject; 399 scenePermissions.OnSellGroupObject -= CanSellGroupObject;
400 scenePermissions.OnSellObjectByUserID -= CanSellObjectByUserID;
401 scenePermissions.OnSellObject -= CanSellObject;
397 402
398 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory; 403 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory;
399 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory; 404 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory;
@@ -1826,6 +1831,86 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1826 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale); 1831 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1827 } 1832 }
1828 1833
1834 private bool CanSellObjectByUserID(SceneObjectGroup sog, UUID userID, byte saleType)
1835 {
1836 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1837 if (m_bypassPermissions) return m_bypassPermissionsValue;
1838
1839 if (sog == null || sog.IsDeleted || userID == UUID.Zero)
1840 return false;
1841
1842 // sell is not a attachment op
1843 if(sog.IsAttachment)
1844 return false;
1845
1846 if(IsAdministrator(userID))
1847 return true;
1848
1849 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1850 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1851 return false;
1852
1853 if(saleType == (byte)SaleType.Copy &&
1854 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1855 return false;
1856
1857 UUID sogOwnerID = sog.OwnerID;
1858
1859 if(sogOwnerID == userID)
1860 return true;
1861
1862 // else only group owned can be sold by members with powers
1863 UUID sogGroupID = sog.GroupID;
1864 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1865 return false;
1866
1867 return IsGroupMember(sogGroupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1868 }
1869
1870 private bool CanSellObject(SceneObjectGroup sog, ScenePresence sp, byte saleType)
1871 {
1872 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1873 if (m_bypassPermissions) return m_bypassPermissionsValue;
1874
1875 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1876 return false;
1877
1878 // sell is not a attachment op
1879 if(sog.IsAttachment)
1880 return false;
1881
1882 if(sp.IsGod)
1883 return true;
1884
1885 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1886 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1887 return false;
1888
1889 if(saleType == (byte)SaleType.Copy &&
1890 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1891 return false;
1892
1893 UUID userID = sp.UUID;
1894 UUID sogOwnerID = sog.OwnerID;
1895
1896 if(sogOwnerID == userID)
1897 return true;
1898
1899 // else only group owned can be sold by members with powers
1900 UUID sogGroupID = sog.GroupID;
1901 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1902 return false;
1903
1904 ulong powers = 0;
1905 if(!GroupMemberPowers(sogGroupID, sp, ref powers))
1906 return false;
1907
1908 if((powers & (ulong)GroupPowers.ObjectSetForSale) == 0)
1909 return false;
1910
1911 return true;
1912 }
1913
1829 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) 1914 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
1830 { 1915 {
1831 // ignore locked, viewers shell ask for confirmation 1916 // ignore locked, viewers shell ask for confirmation
@@ -1835,7 +1920,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1835 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted) 1920 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1836 return false; 1921 return false;
1837 1922
1838 // take is not a attachment op 1923 // take is not a attachment op
1839 if(sog.IsAttachment) 1924 if(sog.IsAttachment)
1840 return false; 1925 return false;
1841 1926
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 6d3b82f..7d69a9b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Region.Framework.Scenes
47 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient); 47 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient);
48 public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp); 48 public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp);
49 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID); 49 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID);
50 public delegate bool SellObjectHandlerByUserID(SceneObjectGroup sog, UUID userID, byte saleType);
51 public delegate bool SellObjectHandler(SceneObjectGroup sog, ScenePresence sp, byte saleType);
50 public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp); 52 public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp);
51 public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp); 53 public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp);
52 public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID); 54 public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID);
@@ -121,7 +123,11 @@ namespace OpenSim.Region.Framework.Scenes
121 public event DeleteObjectHandler OnDeleteObject; 123 public event DeleteObjectHandler OnDeleteObject;
122 public event TransferObjectHandler OnTransferObject; 124 public event TransferObjectHandler OnTransferObject;
123 public event TakeObjectHandler OnTakeObject; 125 public event TakeObjectHandler OnTakeObject;
126
124 public event SellGroupObjectHandler OnSellGroupObject; 127 public event SellGroupObjectHandler OnSellGroupObject;
128 public event SellObjectHandlerByUserID OnSellObjectByUserID;
129 public event SellObjectHandler OnSellObject;
130
125 public event TakeCopyObjectHandler OnTakeCopyObject; 131 public event TakeCopyObjectHandler OnTakeCopyObject;
126 public event DuplicateObjectHandler OnDuplicateObject; 132 public event DuplicateObjectHandler OnDuplicateObject;
127 public event EditObjectByIDsHandler OnEditObjectByIDs; 133 public event EditObjectByIDsHandler OnEditObjectByIDs;
@@ -281,14 +287,11 @@ namespace OpenSim.Region.Framework.Scenes
281 } 287 }
282 } 288 }
283 } 289 }
284
285 return result; 290 return result;
286 } 291 }
287 292
288 public bool CanDeleteObject(SceneObjectGroup sog, IClientAPI client) 293 public bool CanDeleteObject(SceneObjectGroup sog, IClientAPI client)
289 { 294 {
290 bool result = true;
291
292 DeleteObjectHandler handler = OnDeleteObject; 295 DeleteObjectHandler handler = OnDeleteObject;
293 if (handler != null) 296 if (handler != null)
294 { 297 {
@@ -301,20 +304,15 @@ namespace OpenSim.Region.Framework.Scenes
301 foreach (DeleteObjectHandler h in list) 304 foreach (DeleteObjectHandler h in list)
302 { 305 {
303 if (h(sog, sp) == false) 306 if (h(sog, sp) == false)
304 { 307 return false;
305 result = false;
306 break;
307 }
308 } 308 }
309 } 309 }
310 310
311 return result; 311 return true;
312 } 312 }
313 313
314 public bool CanTransferObject(UUID objectID, UUID recipient) 314 public bool CanTransferObject(UUID objectID, UUID recipient)
315 { 315 {
316 bool result = true;
317
318 TransferObjectHandler handler = OnTransferObject; 316 TransferObjectHandler handler = OnTransferObject;
319 if (handler != null) 317 if (handler != null)
320 { 318 {
@@ -322,14 +320,10 @@ namespace OpenSim.Region.Framework.Scenes
322 foreach (TransferObjectHandler h in list) 320 foreach (TransferObjectHandler h in list)
323 { 321 {
324 if (h(objectID, recipient) == false) 322 if (h(objectID, recipient) == false)
325 { 323 return false;
326 result = false;
327 break;
328 }
329 } 324 }
330 } 325 }
331 326 return true;
332 return result;
333 } 327 }
334 328
335 #endregion 329 #endregion
@@ -337,8 +331,6 @@ namespace OpenSim.Region.Framework.Scenes
337 #region TAKE OBJECT 331 #region TAKE OBJECT
338 public bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) 332 public bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
339 { 333 {
340 bool result = true;
341
342 TakeObjectHandler handler = OnTakeObject; 334 TakeObjectHandler handler = OnTakeObject;
343 if (handler != null) 335 if (handler != null)
344 { 336 {
@@ -349,18 +341,13 @@ namespace OpenSim.Region.Framework.Scenes
349 foreach (TakeObjectHandler h in list) 341 foreach (TakeObjectHandler h in list)
350 { 342 {
351 if (h(sog, sp) == false) 343 if (h(sog, sp) == false)
352 { 344 return false;
353 result = false;
354 break;
355 }
356 } 345 }
357 } 346 }
358
359// m_log.DebugFormat( 347// m_log.DebugFormat(
360// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}", 348// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}",
361// objectID, AvatarTakingUUID, result); 349// objectID, AvatarTakingUUID, result);
362 350 return true;
363 return result;
364 } 351 }
365 352
366 #endregion 353 #endregion
@@ -368,8 +355,6 @@ namespace OpenSim.Region.Framework.Scenes
368 #region SELL GROUP OBJECT 355 #region SELL GROUP OBJECT
369 public bool CanSellGroupObject(UUID userID, UUID groupID) 356 public bool CanSellGroupObject(UUID userID, UUID groupID)
370 { 357 {
371 bool result = true;
372
373 SellGroupObjectHandler handler = OnSellGroupObject; 358 SellGroupObjectHandler handler = OnSellGroupObject;
374 if (handler != null) 359 if (handler != null)
375 { 360 {
@@ -377,18 +362,52 @@ namespace OpenSim.Region.Framework.Scenes
377 foreach (SellGroupObjectHandler h in list) 362 foreach (SellGroupObjectHandler h in list)
378 { 363 {
379 if (h(userID, groupID) == false) 364 if (h(userID, groupID) == false)
380 { 365 return false;
381 result = false;
382 break;
383 }
384 } 366 }
385 } 367 }
386
387 //m_log.DebugFormat( 368 //m_log.DebugFormat(
388 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}", 369 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}",
389 // userID, groupID, result); 370 // userID, groupID, result);
371 return true;
372 }
390 373
391 return result; 374 #endregion
375
376 #region SELL OBJECT
377 public bool CanSellObject(IClientAPI client, SceneObjectGroup sog, byte saleType)
378 {
379 SellObjectHandler handler = OnSellObject;
380 if (handler != null)
381 {
382 if(sog == null || client == null || client.SceneAgent == null)
383 return false;
384
385 ScenePresence sp = client.SceneAgent as ScenePresence;
386 Delegate[] list = handler.GetInvocationList();
387 foreach (SellObjectHandler h in list)
388 {
389 if (h(sog, sp, saleType) == false)
390 return false;
391 }
392 }
393 return true;
394 }
395
396 public bool CanSellObject(UUID userID, SceneObjectGroup sog, byte saleType)
397 {
398 SellObjectHandlerByUserID handler = OnSellObjectByUserID;
399 if (handler != null)
400 {
401 if(sog == null)
402 return false;
403 Delegate[] list = handler.GetInvocationList();
404 foreach (SellObjectHandlerByUserID h in list)
405 {
406 if (h(sog, userID, saleType) == false)
407 return false;
408 }
409 }
410 return true;
392 } 411 }
393 412
394 #endregion 413 #endregion
@@ -397,8 +416,6 @@ namespace OpenSim.Region.Framework.Scenes
397 #region TAKE COPY OBJECT 416 #region TAKE COPY OBJECT
398 public bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp) 417 public bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
399 { 418 {
400 bool result = true;
401
402 TakeCopyObjectHandler handler = OnTakeCopyObject; 419 TakeCopyObjectHandler handler = OnTakeCopyObject;
403 if (handler != null) 420 if (handler != null)
404 { 421 {
@@ -408,18 +425,13 @@ namespace OpenSim.Region.Framework.Scenes
408 foreach (TakeCopyObjectHandler h in list) 425 foreach (TakeCopyObjectHandler h in list)
409 { 426 {
410 if (h(sog, sp) == false) 427 if (h(sog, sp) == false)
411 { 428 return false;
412 result = false;
413 break;
414 }
415 } 429 }
416 } 430 }
417
418// m_log.DebugFormat( 431// m_log.DebugFormat(
419// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}", 432// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}",
420// objectID, userID, result); 433// objectID, userID, result);
421 434 return true;
422 return result;
423 } 435 }
424 436
425 #endregion 437 #endregion
@@ -558,8 +570,6 @@ namespace OpenSim.Region.Framework.Scenes
558 #region RETURN OBJECT 570 #region RETURN OBJECT
559 public bool CanReturnObjects(ILandObject land, IClientAPI client, List<SceneObjectGroup> objects) 571 public bool CanReturnObjects(ILandObject land, IClientAPI client, List<SceneObjectGroup> objects)
560 { 572 {
561 bool result = true;
562
563 ReturnObjectsHandler handler = OnReturnObjects; 573 ReturnObjectsHandler handler = OnReturnObjects;
564 if (handler != null) 574 if (handler != null)
565 { 575 {
@@ -574,18 +584,14 @@ namespace OpenSim.Region.Framework.Scenes
574 foreach (ReturnObjectsHandler h in list) 584 foreach (ReturnObjectsHandler h in list)
575 { 585 {
576 if (h(land, sp, objects) == false) 586 if (h(land, sp, objects) == false)
577 { 587 return false;
578 result = false;
579 break;
580 }
581 } 588 }
582 } 589 }
583
584// m_log.DebugFormat( 590// m_log.DebugFormat(
585// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}", 591// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}",
586// user, objects.Count, land.LandData.Name, result); 592// user, objects.Count, land.LandData.Name, result);
587 593
588 return result; 594 return true;
589 } 595 }
590 596
591 #endregion 597 #endregion