PermissionsModule.cs 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using log4net;
  31. using Nini.Config;
  32. using OpenMetaverse;
  33. using OpenSim.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. using OpenSim.Region.Framework.Scenes;
  36. using OpenSim.Services.Interfaces;
  37. // Temporary fix of wrong GroupPowers constants in OpenMetaverse library
  38. enum GroupPowers : long
  39. {
  40. None = 0,
  41. LandEjectAndFreeze = 1,
  42. Invite = 2,
  43. ReturnGroupSet = 2,
  44. Eject = 4,
  45. ReturnNonGroup = 4,
  46. ChangeOptions = 8,
  47. LandGardening = 8,
  48. CreateRole = 16,
  49. DeedObject = 16,
  50. ModerateChat = 32,
  51. DeleteRole = 32,
  52. RoleProperties = 64,
  53. ObjectManipulate = 64,
  54. ObjectSetForSale = 128,
  55. AssignMemberLimited = 128,
  56. AssignMember = 256,
  57. Accountable = 256,
  58. RemoveMember = 512,
  59. SendNotices = 1024,
  60. ChangeActions = 1024,
  61. ChangeIdentity = 2048,
  62. ReceiveNotices = 2048,
  63. StartProposal = 4096,
  64. LandDeed = 4096,
  65. VoteOnProposal = 8192,
  66. LandRelease = 8192,
  67. LandSetSale = 16384,
  68. LandDivideJoin = 32768,
  69. ReturnGroupOwned = 65536,
  70. JoinChat = 65536,
  71. FindPlaces = 131072,
  72. LandChangeIdentity = 262144,
  73. SetLandingPoint = 524288,
  74. ChangeMedia = 1048576,
  75. LandEdit = 2097152,
  76. LandOptions = 4194304,
  77. AllowEditLand = 8388608,
  78. AllowFly = 16777216,
  79. AllowRez = 33554432,
  80. AllowLandmark = 67108864,
  81. AllowVoiceChat = 134217728,
  82. AllowSetHome = 268435456,
  83. LandManageAllowed = 536870912,
  84. LandManageBanned = 1073741824
  85. }
  86. namespace OpenSim.Region.CoreModules.World.Permissions
  87. {
  88. public class PermissionsModule : IRegionModule
  89. {
  90. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  91. protected Scene m_scene;
  92. private InventoryFolderImpl m_libraryRootFolder;
  93. protected InventoryFolderImpl LibraryRootFolder
  94. {
  95. get
  96. {
  97. if (m_libraryRootFolder != null)
  98. return m_libraryRootFolder;
  99. ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
  100. if (lib != null)
  101. {
  102. m_libraryRootFolder = lib.LibraryRootFolder;
  103. }
  104. return m_libraryRootFolder;
  105. }
  106. }
  107. #region Constants
  108. // These are here for testing. They will be taken out
  109. //private uint PERM_ALL = (uint)2147483647;
  110. private uint PERM_COPY = (uint)32768;
  111. //private uint PERM_MODIFY = (uint)16384;
  112. private uint PERM_MOVE = (uint)524288;
  113. private uint PERM_TRANS = (uint)8192;
  114. private uint PERM_LOCKED = (uint)540672;
  115. /// <value>
  116. /// Different user set names that come in from the configuration file.
  117. /// </value>
  118. enum UserSet
  119. {
  120. All,
  121. Administrators
  122. };
  123. #endregion
  124. #region Bypass Permissions / Debug Permissions Stuff
  125. // Bypasses the permissions engine
  126. private bool m_bypassPermissions = true;
  127. private bool m_bypassPermissionsValue = true;
  128. private bool m_propagatePermissions = false;
  129. private bool m_debugPermissions = false;
  130. private bool m_allowGridGods = false;
  131. private bool m_RegionOwnerIsGod = false;
  132. private bool m_RegionManagerIsGod = false;
  133. private bool m_ParcelOwnerIsGod = false;
  134. /// <value>
  135. /// The set of users that are allowed to create scripts. This is only active if permissions are not being
  136. /// bypassed. This overrides normal permissions.
  137. /// </value>
  138. private UserSet m_allowedScriptCreators = UserSet.All;
  139. /// <value>
  140. /// The set of users that are allowed to edit (save) scripts. This is only active if
  141. /// permissions are not being bypassed. This overrides normal permissions.-
  142. /// </value>
  143. private UserSet m_allowedScriptEditors = UserSet.All;
  144. private Dictionary<string, bool> GrantLSL = new Dictionary<string, bool>();
  145. private Dictionary<string, bool> GrantCS = new Dictionary<string, bool>();
  146. private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
  147. private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
  148. private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
  149. private IFriendsModule m_friendsModule;
  150. private IGroupsModule m_groupsModule;
  151. #endregion
  152. #region IRegionModule Members
  153. public void Initialise(Scene scene, IConfigSource config)
  154. {
  155. m_scene = scene;
  156. IConfig myConfig = config.Configs["Startup"];
  157. string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule");
  158. List<string> modules=new List<string>(permissionModules.Split(','));
  159. if (!modules.Contains("DefaultPermissionsModule"))
  160. return;
  161. m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false);
  162. m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", false);
  163. m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true);
  164. m_RegionOwnerIsGod = myConfig.GetBoolean("region_owner_is_god", true);
  165. m_RegionManagerIsGod = myConfig.GetBoolean("region_manager_is_god", false);
  166. m_ParcelOwnerIsGod = myConfig.GetBoolean("parcel_owner_is_god", true);
  167. m_allowedScriptCreators
  168. = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators);
  169. m_allowedScriptEditors
  170. = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors);
  171. if (m_bypassPermissions)
  172. m_log.Info("[PERMISSIONS]: serviceside_object_permissions = false in ini file so disabling all region service permission checks");
  173. else
  174. m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks");
  175. //Register functions with Scene External Checks!
  176. m_scene.Permissions.OnBypassPermissions += BypassPermissions;
  177. m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions;
  178. m_scene.Permissions.OnPropagatePermissions += PropagatePermissions;
  179. m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags;
  180. m_scene.Permissions.OnAbandonParcel += CanAbandonParcel;
  181. m_scene.Permissions.OnReclaimParcel += CanReclaimParcel;
  182. m_scene.Permissions.OnDeedParcel += CanDeedParcel;
  183. m_scene.Permissions.OnDeedObject += CanDeedObject;
  184. m_scene.Permissions.OnIsGod += IsGod;
  185. m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
  186. m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED
  187. m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED
  188. m_scene.Permissions.OnEditParcel += CanEditParcel; //MAYBE FULLY IMPLEMENTED
  189. m_scene.Permissions.OnInstantMessage += CanInstantMessage;
  190. m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; //NOT YET IMPLEMENTED
  191. m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED
  192. m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED
  193. m_scene.Permissions.OnObjectEntry += CanObjectEntry;
  194. m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED
  195. m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED
  196. m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand;
  197. m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED
  198. m_scene.Permissions.OnCompileScript += CanCompileScript;
  199. m_scene.Permissions.OnSellParcel += CanSellParcel;
  200. m_scene.Permissions.OnTakeObject += CanTakeObject;
  201. m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject;
  202. m_scene.Permissions.OnTerraformLand += CanTerraformLand;
  203. m_scene.Permissions.OnLinkObject += CanLinkObject; //NOT YET IMPLEMENTED
  204. m_scene.Permissions.OnDelinkObject += CanDelinkObject; //NOT YET IMPLEMENTED
  205. m_scene.Permissions.OnBuyLand += CanBuyLand; //NOT YET IMPLEMENTED
  206. m_scene.Permissions.OnViewNotecard += CanViewNotecard; //NOT YET IMPLEMENTED
  207. m_scene.Permissions.OnViewScript += CanViewScript; //NOT YET IMPLEMENTED
  208. m_scene.Permissions.OnEditNotecard += CanEditNotecard; //NOT YET IMPLEMENTED
  209. m_scene.Permissions.OnEditScript += CanEditScript; //NOT YET IMPLEMENTED
  210. m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; //NOT IMPLEMENTED HERE
  211. m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED
  212. m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; //NOT YET IMPLEMENTED
  213. m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; //NOT YET IMPLEMENTED
  214. m_scene.Permissions.OnResetScript += CanResetScript;
  215. m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; //NOT YET IMPLEMENTED
  216. m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; //NOT YET IMPLEMENTED
  217. m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; //NOT YET IMPLEMENTED
  218. m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED
  219. m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED
  220. m_scene.AddCommand(this, "bypass permissions",
  221. "bypass permissions <true / false>",
  222. "Bypass permission checks",
  223. HandleBypassPermissions);
  224. m_scene.AddCommand(this, "force permissions",
  225. "force permissions <true / false>",
  226. "Force permissions on or off",
  227. HandleForcePermissions);
  228. m_scene.AddCommand(this, "debug permissions",
  229. "debug permissions <true / false>",
  230. "Enable permissions debugging",
  231. HandleDebugPermissions);
  232. string grant = myConfig.GetString("GrantLSL","");
  233. if (grant.Length > 0) {
  234. foreach (string uuidl in grant.Split(',')) {
  235. string uuid = uuidl.Trim(" \t".ToCharArray());
  236. GrantLSL.Add(uuid, true);
  237. }
  238. }
  239. grant = myConfig.GetString("GrantCS","");
  240. if (grant.Length > 0) {
  241. foreach (string uuidl in grant.Split(',')) {
  242. string uuid = uuidl.Trim(" \t".ToCharArray());
  243. GrantCS.Add(uuid, true);
  244. }
  245. }
  246. grant = myConfig.GetString("GrantVB","");
  247. if (grant.Length > 0) {
  248. foreach (string uuidl in grant.Split(',')) {
  249. string uuid = uuidl.Trim(" \t".ToCharArray());
  250. GrantVB.Add(uuid, true);
  251. }
  252. }
  253. grant = myConfig.GetString("GrantJS", "");
  254. if (grant.Length > 0)
  255. {
  256. foreach (string uuidl in grant.Split(','))
  257. {
  258. string uuid = uuidl.Trim(" \t".ToCharArray());
  259. GrantJS.Add(uuid, true);
  260. }
  261. }
  262. grant = myConfig.GetString("GrantYP", "");
  263. if (grant.Length > 0)
  264. {
  265. foreach (string uuidl in grant.Split(','))
  266. {
  267. string uuid = uuidl.Trim(" \t".ToCharArray());
  268. GrantYP.Add(uuid, true);
  269. }
  270. }
  271. }
  272. public void HandleBypassPermissions(string module, string[] args)
  273. {
  274. if (m_scene.ConsoleScene() != null &&
  275. m_scene.ConsoleScene() != m_scene)
  276. {
  277. return;
  278. }
  279. if (args.Length > 2)
  280. {
  281. bool val;
  282. if (!bool.TryParse(args[2], out val))
  283. return;
  284. m_bypassPermissions = val;
  285. m_log.InfoFormat(
  286. "[PERMISSIONS]: Set permissions bypass to {0} for {1}",
  287. m_bypassPermissions, m_scene.RegionInfo.RegionName);
  288. }
  289. }
  290. public void HandleForcePermissions(string module, string[] args)
  291. {
  292. if (m_scene.ConsoleScene() != null &&
  293. m_scene.ConsoleScene() != m_scene)
  294. {
  295. return;
  296. }
  297. if (!m_bypassPermissions)
  298. {
  299. m_log.Error("[PERMISSIONS] Permissions can't be forced unless they are bypassed first");
  300. return;
  301. }
  302. if (args.Length > 2)
  303. {
  304. bool val;
  305. if (!bool.TryParse(args[2], out val))
  306. return;
  307. m_bypassPermissionsValue = val;
  308. m_log.InfoFormat("[PERMISSIONS] Forced permissions to {0} in {1}", m_bypassPermissionsValue, m_scene.RegionInfo.RegionName);
  309. }
  310. }
  311. public void HandleDebugPermissions(string module, string[] args)
  312. {
  313. if (m_scene.ConsoleScene() != null &&
  314. m_scene.ConsoleScene() != m_scene)
  315. {
  316. return;
  317. }
  318. if (args.Length > 2)
  319. {
  320. bool val;
  321. if (!bool.TryParse(args[2], out val))
  322. return;
  323. m_debugPermissions = val;
  324. m_log.InfoFormat("[PERMISSIONS] Set permissions debugging to {0} in {1}", m_debugPermissions, m_scene.RegionInfo.RegionName);
  325. }
  326. }
  327. public void PostInitialise()
  328. {
  329. m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
  330. if (m_friendsModule == null)
  331. m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work");
  332. m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
  333. if (m_groupsModule == null)
  334. m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work");
  335. }
  336. public void Close()
  337. {
  338. }
  339. public string Name
  340. {
  341. get { return "PermissionsModule"; }
  342. }
  343. public bool IsSharedModule
  344. {
  345. get { return false; }
  346. }
  347. #endregion
  348. #region Helper Functions
  349. protected void SendPermissionError(UUID user, string reason)
  350. {
  351. m_scene.EventManager.TriggerPermissionError(user, reason);
  352. }
  353. protected void DebugPermissionInformation(string permissionCalled)
  354. {
  355. if (m_debugPermissions)
  356. m_log.Debug("[PERMISSIONS]: " + permissionCalled + " was called from " + m_scene.RegionInfo.RegionName);
  357. }
  358. // Checks if the given group is active and if the user is a group member
  359. // with the powers requested (powers = 0 for no powers check)
  360. protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
  361. {
  362. if (null == m_groupsModule)
  363. return false;
  364. GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
  365. if (gmd != null)
  366. {
  367. if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
  368. return true;
  369. }
  370. return false;
  371. }
  372. /// <summary>
  373. /// Parse a user set configuration setting
  374. /// </summary>
  375. /// <param name="config"></param>
  376. /// <param name="settingName"></param>
  377. /// <param name="defaultValue">The default value for this attribute</param>
  378. /// <returns>The parsed value</returns>
  379. private static UserSet ParseUserSetConfigSetting(IConfig config, string settingName, UserSet defaultValue)
  380. {
  381. UserSet userSet = defaultValue;
  382. string rawSetting = config.GetString(settingName, defaultValue.ToString());
  383. // Temporary measure to allow 'gods' to be specified in config for consistency's sake. In the long term
  384. // this should disappear.
  385. if ("gods" == rawSetting.ToLower())
  386. rawSetting = UserSet.Administrators.ToString();
  387. // Doing it this was so that we can do a case insensitive conversion
  388. try
  389. {
  390. userSet = (UserSet)Enum.Parse(typeof(UserSet), rawSetting, true);
  391. }
  392. catch
  393. {
  394. m_log.ErrorFormat(
  395. "[PERMISSIONS]: {0} is not a valid {1} value, setting to {2}",
  396. rawSetting, settingName, userSet);
  397. }
  398. m_log.DebugFormat("[PERMISSIONS]: {0} {1}", settingName, userSet);
  399. return userSet;
  400. }
  401. /// <summary>
  402. /// Is the given user an administrator (in other words, a god)?
  403. /// </summary>
  404. /// <param name="user"></param>
  405. /// <returns></returns>
  406. protected bool IsAdministrator(UUID user)
  407. {
  408. if (user == UUID.Zero) return false;
  409. if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
  410. {
  411. if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod)
  412. return true;
  413. }
  414. if (IsEstateManager(user) && m_RegionManagerIsGod)
  415. return true;
  416. if (m_allowGridGods)
  417. {
  418. ScenePresence sp = m_scene.GetScenePresence(user);
  419. if (sp != null)
  420. {
  421. if (sp.UserLevel >= 200)
  422. return true;
  423. return false;
  424. }
  425. UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user);
  426. if (account != null)
  427. {
  428. if (account.UserLevel >= 200)
  429. return true;
  430. }
  431. }
  432. return false;
  433. }
  434. protected bool IsFriendWithPerms(UUID user,UUID objectOwner)
  435. {
  436. if (user == UUID.Zero)
  437. return false;
  438. if (m_friendsModule == null)
  439. return false;
  440. uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner);
  441. if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0)
  442. return true;
  443. return false;
  444. }
  445. protected bool IsEstateManager(UUID user)
  446. {
  447. if (user == UUID.Zero) return false;
  448. return m_scene.RegionInfo.EstateSettings.IsEstateManager(user);
  449. }
  450. #endregion
  451. public bool PropagatePermissions()
  452. {
  453. if (m_bypassPermissions)
  454. return false;
  455. return m_propagatePermissions;
  456. }
  457. public bool BypassPermissions()
  458. {
  459. return m_bypassPermissions;
  460. }
  461. public void SetBypassPermissions(bool value)
  462. {
  463. m_bypassPermissions=value;
  464. }
  465. #region Object Permissions
  466. public uint GenerateClientFlags(UUID user, UUID objID)
  467. {
  468. // Here's the way this works,
  469. // ObjectFlags and Permission flags are two different enumerations
  470. // ObjectFlags, however, tells the client to change what it will allow the user to do.
  471. // So, that means that all of the permissions type ObjectFlags are /temporary/ and only
  472. // supposed to be set when customizing the objectflags for the client.
  473. // These temporary objectflags get computed and added in this function based on the
  474. // Permission mask that's appropriate!
  475. // Outside of this method, they should never be added to objectflags!
  476. // -teravus
  477. SceneObjectPart task = m_scene.GetSceneObjectPart(objID);
  478. // this shouldn't ever happen.. return no permissions/objectflags.
  479. if (task == null)
  480. return (uint)0;
  481. uint objflags = task.GetEffectiveObjectFlags();
  482. UUID objectOwner = task.OwnerID;
  483. // Remove any of the objectFlags that are temporary. These will get added back if appropriate
  484. // in the next bit of code
  485. // libomv will moan about PrimFlags.ObjectYouOfficer being
  486. // deprecated
  487. #pragma warning disable 0612
  488. objflags &= (uint)
  489. ~(PrimFlags.ObjectCopy | // Tells client you can copy the object
  490. PrimFlags.ObjectModify | // tells client you can modify the object
  491. PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
  492. PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
  493. PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
  494. PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
  495. PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
  496. PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
  497. );
  498. #pragma warning restore 0612
  499. // Creating the three ObjectFlags options for this method to choose from.
  500. // Customize the OwnerMask
  501. uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
  502. objectOwnerMask |= (uint)PrimFlags.ObjectYouOwner | (uint)PrimFlags.ObjectAnyOwner | (uint)PrimFlags.ObjectOwnerModify;
  503. // Customize the GroupMask
  504. uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
  505. // Customize the EveryoneMask
  506. uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags);
  507. if (objectOwner != UUID.Zero)
  508. objectEveryoneMask |= (uint)PrimFlags.ObjectAnyOwner;
  509. if (m_bypassPermissions)
  510. return objectOwnerMask;
  511. // Object owners should be able to edit their own content
  512. if (user == objectOwner)
  513. return objectOwnerMask;
  514. if (IsFriendWithPerms(user, objectOwner))
  515. return objectOwnerMask;
  516. // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set
  517. if (m_RegionOwnerIsGod && IsEstateManager(user) && !IsAdministrator(objectOwner))
  518. return objectOwnerMask;
  519. // Admin should be able to edit anything in the sim (including admin objects)
  520. if (IsAdministrator(user))
  521. return objectOwnerMask;
  522. // Users should be able to edit what is over their land.
  523. Vector3 taskPos = task.AbsolutePosition;
  524. ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
  525. if (parcel != null && parcel.LandData.OwnerID == user && m_ParcelOwnerIsGod)
  526. {
  527. // Admin objects should not be editable by the above
  528. if (!IsAdministrator(objectOwner))
  529. return objectOwnerMask;
  530. }
  531. // Group permissions
  532. if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0))
  533. return objectGroupMask | objectEveryoneMask;
  534. return objectEveryoneMask;
  535. }
  536. private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask)
  537. {
  538. // We are adding the temporary objectflags to the object's objectflags based on the
  539. // permission flag given. These change the F flags on the client.
  540. if ((setPermissionMask & (uint)PermissionMask.Copy) != 0)
  541. {
  542. objectFlagsMask |= (uint)PrimFlags.ObjectCopy;
  543. }
  544. if ((setPermissionMask & (uint)PermissionMask.Move) != 0)
  545. {
  546. objectFlagsMask |= (uint)PrimFlags.ObjectMove;
  547. }
  548. if ((setPermissionMask & (uint)PermissionMask.Modify) != 0)
  549. {
  550. objectFlagsMask |= (uint)PrimFlags.ObjectModify;
  551. }
  552. if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0)
  553. {
  554. objectFlagsMask |= (uint)PrimFlags.ObjectTransfer;
  555. }
  556. return objectFlagsMask;
  557. }
  558. /// <summary>
  559. /// General permissions checks for any operation involving an object. These supplement more specific checks
  560. /// implemented by callers.
  561. /// </summary>
  562. /// <param name="currentUser"></param>
  563. /// <param name="objId"></param>
  564. /// <param name="denyOnLocked"></param>
  565. /// <returns></returns>
  566. protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
  567. {
  568. // Default: deny
  569. bool permission = false;
  570. bool locked = false;
  571. if (!m_scene.Entities.ContainsKey(objId))
  572. {
  573. return false;
  574. }
  575. // If it's not an object, we cant edit it.
  576. if ((!(m_scene.Entities[objId] is SceneObjectGroup)))
  577. {
  578. return false;
  579. }
  580. SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objId];
  581. UUID objectOwner = group.OwnerID;
  582. locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
  583. // People shouldn't be able to do anything with locked objects, except the Administrator
  584. // The 'set permissions' runs through a different permission check, so when an object owner
  585. // sets an object locked, the only thing that they can do is unlock it.
  586. //
  587. // Nobody but the object owner can set permissions on an object
  588. //
  589. if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
  590. {
  591. return false;
  592. }
  593. // Object owners should be able to edit their own content
  594. if (currentUser == objectOwner)
  595. {
  596. permission = true;
  597. }
  598. else if (group.IsAttachment)
  599. {
  600. permission = false;
  601. }
  602. // m_log.DebugFormat(
  603. // "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}",
  604. // group.GroupID,
  605. // m_scene.GetSceneObjectPart(objId).GroupMask,
  606. // IsGroupMember(group.GroupID, currentUser, 0),
  607. // currentUser);
  608. // Group members should be able to edit group objects
  609. if ((group.GroupID != UUID.Zero)
  610. && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
  611. && IsGroupMember(group.GroupID, currentUser, 0))
  612. {
  613. // Return immediately, so that the administrator can shares group objects
  614. return true;
  615. }
  616. // Users should be able to edit what is over their land.
  617. ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y);
  618. if ((parcel != null) && (parcel.LandData.OwnerID == currentUser))
  619. {
  620. permission = true;
  621. }
  622. // Estate users should be able to edit anything in the sim
  623. if (IsEstateManager(currentUser))
  624. {
  625. permission = true;
  626. }
  627. // Admin objects should not be editable by the above
  628. if (IsAdministrator(objectOwner))
  629. {
  630. permission = false;
  631. }
  632. // Admin should be able to edit anything in the sim (including admin objects)
  633. if (IsAdministrator(currentUser))
  634. {
  635. permission = true;
  636. }
  637. return permission;
  638. }
  639. #endregion
  640. #region Generic Permissions
  641. protected bool GenericCommunicationPermission(UUID user, UUID target)
  642. {
  643. // Setting this to true so that cool stuff can happen until we define what determines Generic Communication Permission
  644. bool permission = true;
  645. string reason = "Only registered users may communicate with another account.";
  646. // Uhh, we need to finish this before we enable it.. because it's blocking all sorts of goodies and features
  647. if (IsAdministrator(user))
  648. permission = true;
  649. if (IsEstateManager(user))
  650. permission = true;
  651. if (!permission)
  652. SendPermissionError(user, reason);
  653. return permission;
  654. }
  655. public bool GenericEstatePermission(UUID user)
  656. {
  657. // Default: deny
  658. bool permission = false;
  659. // Estate admins should be able to use estate tools
  660. if (IsEstateManager(user))
  661. permission = true;
  662. // Administrators always have permission
  663. if (IsAdministrator(user))
  664. permission = true;
  665. return permission;
  666. }
  667. protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
  668. {
  669. bool permission = false;
  670. if (parcel.LandData.OwnerID == user)
  671. {
  672. permission = true;
  673. }
  674. if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
  675. {
  676. permission = true;
  677. }
  678. if (IsEstateManager(user))
  679. {
  680. permission = true;
  681. }
  682. if (IsAdministrator(user))
  683. {
  684. permission = true;
  685. }
  686. return permission;
  687. }
  688. protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers)
  689. {
  690. if (parcel.LandData.OwnerID == user)
  691. {
  692. // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
  693. // the subsequent redundant checks when using lParcelMediaCommandList()
  694. // See http://opensimulator.org/mantis/view.php?id=3999 for more details
  695. return true;
  696. }
  697. if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
  698. {
  699. return true;
  700. }
  701. if (IsEstateManager(user))
  702. {
  703. return true;
  704. }
  705. if (IsAdministrator(user))
  706. {
  707. return true;
  708. }
  709. return false;
  710. }
  711. protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
  712. {
  713. ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
  714. if (parcel == null) return false;
  715. return GenericParcelPermission(user, parcel, groupPowers);
  716. }
  717. #endregion
  718. #region Permission Checks
  719. private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene)
  720. {
  721. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  722. if (m_bypassPermissions) return m_bypassPermissionsValue;
  723. return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease);
  724. }
  725. private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene)
  726. {
  727. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  728. if (m_bypassPermissions) return m_bypassPermissionsValue;
  729. return GenericParcelOwnerPermission(user, parcel, 0);
  730. }
  731. private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene)
  732. {
  733. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  734. if (m_bypassPermissions) return m_bypassPermissionsValue;
  735. if (parcel.LandData.OwnerID != user) // Only the owner can deed!
  736. return false;
  737. ScenePresence sp = scene.GetScenePresence(user);
  738. IClientAPI client = sp.ControllingClient;
  739. if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
  740. return false;
  741. return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed);
  742. }
  743. private bool CanDeedObject(UUID user, UUID group, Scene scene)
  744. {
  745. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  746. if (m_bypassPermissions) return m_bypassPermissionsValue;
  747. ScenePresence sp = scene.GetScenePresence(user);
  748. IClientAPI client = sp.ControllingClient;
  749. if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0)
  750. return false;
  751. return true;
  752. }
  753. private bool IsGod(UUID user, Scene scene)
  754. {
  755. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  756. if (m_bypassPermissions) return m_bypassPermissionsValue;
  757. return IsAdministrator(user);
  758. }
  759. private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition)
  760. {
  761. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  762. if (m_bypassPermissions) return m_bypassPermissionsValue;
  763. if (!GenericObjectPermission(owner, objectID, true))
  764. {
  765. //They can't even edit the object
  766. return false;
  767. }
  768. SceneObjectPart part = scene.GetSceneObjectPart(objectID);
  769. if (part == null)
  770. return false;
  771. if (part.OwnerID == owner)
  772. return ((part.OwnerMask & PERM_COPY) != 0);
  773. if (part.GroupID != UUID.Zero)
  774. {
  775. if ((part.OwnerID == part.GroupID) && ((owner != part.LastOwnerID) || ((part.GroupMask & PERM_TRANS) == 0)))
  776. return false;
  777. if ((part.GroupMask & PERM_COPY) == 0)
  778. return false;
  779. }
  780. //If they can rez, they can duplicate
  781. return CanRezObject(objectCount, owner, objectPosition, scene);
  782. }
  783. private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene)
  784. {
  785. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  786. if (m_bypassPermissions) return m_bypassPermissionsValue;
  787. return GenericObjectPermission(deleter, objectID, false);
  788. }
  789. private bool CanEditObject(UUID objectID, UUID editorID, Scene scene)
  790. {
  791. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  792. if (m_bypassPermissions) return m_bypassPermissionsValue;
  793. return GenericObjectPermission(editorID, objectID, false);
  794. }
  795. private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene)
  796. {
  797. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  798. if (m_bypassPermissions) return m_bypassPermissionsValue;
  799. SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
  800. // If we selected a sub-prim to edit, the objectID won't represent the object, but only a part.
  801. // We have to check the permissions of the group, though.
  802. if (part.ParentID != 0)
  803. {
  804. objectID = part.ParentUUID;
  805. part = m_scene.GetSceneObjectPart(objectID);
  806. }
  807. return GenericObjectPermission(editorID, objectID, false);
  808. }
  809. private bool CanEditParcel(UUID user, ILandObject parcel, Scene scene)
  810. {
  811. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  812. if (m_bypassPermissions) return m_bypassPermissionsValue;
  813. return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDivideJoin);
  814. }
  815. /// <summary>
  816. /// Check whether the specified user can edit the given script
  817. /// </summary>
  818. /// <param name="script"></param>
  819. /// <param name="objectID"></param>
  820. /// <param name="user"></param>
  821. /// <param name="scene"></param>
  822. /// <returns></returns>
  823. private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene)
  824. {
  825. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  826. if (m_bypassPermissions) return m_bypassPermissionsValue;
  827. if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user))
  828. return false;
  829. // Ordinarily, if you can view it, you can edit it
  830. // There is no viewing a no mod script
  831. //
  832. return CanViewScript(script, objectID, user, scene);
  833. }
  834. /// <summary>
  835. /// Check whether the specified user can edit the given notecard
  836. /// </summary>
  837. /// <param name="notecard"></param>
  838. /// <param name="objectID"></param>
  839. /// <param name="user"></param>
  840. /// <param name="scene"></param>
  841. /// <returns></returns>
  842. private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene)
  843. {
  844. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  845. if (m_bypassPermissions) return m_bypassPermissionsValue;
  846. if (objectID == UUID.Zero) // User inventory
  847. {
  848. IInventoryService invService = m_scene.InventoryService;
  849. InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
  850. assetRequestItem = invService.GetItem(assetRequestItem);
  851. if (assetRequestItem == null && LibraryRootFolder != null) // Library item
  852. {
  853. assetRequestItem = LibraryRootFolder.FindItem(notecard);
  854. if (assetRequestItem != null) // Implicitly readable
  855. return true;
  856. }
  857. // Notecards must be both mod and copy to be saveable
  858. // This is because of they're not copy, you can't read
  859. // them, and if they're not mod, well, then they're
  860. // not mod. Duh.
  861. //
  862. if ((assetRequestItem.CurrentPermissions &
  863. ((uint)PermissionMask.Modify |
  864. (uint)PermissionMask.Copy)) !=
  865. ((uint)PermissionMask.Modify |
  866. (uint)PermissionMask.Copy))
  867. return false;
  868. }
  869. else // Prim inventory
  870. {
  871. SceneObjectPart part = scene.GetSceneObjectPart(objectID);
  872. if (part == null)
  873. return false;
  874. if (part.OwnerID != user)
  875. {
  876. if (part.GroupID == UUID.Zero)
  877. return false;
  878. if (!IsGroupMember(part.GroupID, user, 0))
  879. return false;
  880. if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
  881. return false;
  882. }
  883. else
  884. {
  885. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  886. return false;
  887. }
  888. TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
  889. if (ti == null)
  890. return false;
  891. if (ti.OwnerID != user)
  892. {
  893. if (ti.GroupID == UUID.Zero)
  894. return false;
  895. if (!IsGroupMember(ti.GroupID, user, 0))
  896. return false;
  897. }
  898. // Require full perms
  899. if ((ti.CurrentPermissions &
  900. ((uint)PermissionMask.Modify |
  901. (uint)PermissionMask.Copy)) !=
  902. ((uint)PermissionMask.Modify |
  903. (uint)PermissionMask.Copy))
  904. return false;
  905. }
  906. return true;
  907. }
  908. private bool CanInstantMessage(UUID user, UUID target, Scene startScene)
  909. {
  910. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  911. if (m_bypassPermissions) return m_bypassPermissionsValue;
  912. // If the sender is an object, check owner instead
  913. //
  914. SceneObjectPart part = startScene.GetSceneObjectPart(user);
  915. if (part != null)
  916. user = part.OwnerID;
  917. return GenericCommunicationPermission(user, target);
  918. }
  919. private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene)
  920. {
  921. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  922. if (m_bypassPermissions) return m_bypassPermissionsValue;
  923. return GenericCommunicationPermission(user, target);
  924. }
  925. private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand)
  926. {
  927. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  928. if (m_bypassPermissions) return m_bypassPermissionsValue;
  929. if (IsAdministrator(user))
  930. return true;
  931. if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
  932. return true;
  933. if (ownerCommand)
  934. return false;
  935. return GenericEstatePermission(user);
  936. }
  937. private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene)
  938. {
  939. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  940. if (m_bypassPermissions)
  941. {
  942. SceneObjectPart part = scene.GetSceneObjectPart(objectID);
  943. if (part.OwnerID != moverID)
  944. {
  945. if (part.ParentGroup != null && !part.ParentGroup.IsDeleted)
  946. {
  947. if (part.ParentGroup.IsAttachment)
  948. return false;
  949. }
  950. }
  951. return m_bypassPermissionsValue;
  952. }
  953. bool permission = GenericObjectPermission(moverID, objectID, true);
  954. if (!permission)
  955. {
  956. if (!m_scene.Entities.ContainsKey(objectID))
  957. {
  958. return false;
  959. }
  960. // The client
  961. // may request to edit linked parts, and therefore, it needs
  962. // to also check for SceneObjectPart
  963. // If it's not an object, we cant edit it.
  964. if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
  965. {
  966. return false;
  967. }
  968. SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
  969. // UUID taskOwner = null;
  970. // Added this because at this point in time it wouldn't be wise for
  971. // the administrator object permissions to take effect.
  972. // UUID objectOwner = task.OwnerID;
  973. // Anyone can move
  974. if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0)
  975. permission = true;
  976. // Locked
  977. if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
  978. permission = false;
  979. }
  980. else
  981. {
  982. bool locked = false;
  983. if (!m_scene.Entities.ContainsKey(objectID))
  984. {
  985. return false;
  986. }
  987. // If it's not an object, we cant edit it.
  988. if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
  989. {
  990. return false;
  991. }
  992. SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID];
  993. UUID objectOwner = group.OwnerID;
  994. locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
  995. // This is an exception to the generic object permission.
  996. // Administrators who lock their objects should not be able to move them,
  997. // however generic object permission should return true.
  998. // This keeps locked objects from being affected by random click + drag actions by accident
  999. // and allows the administrator to grab or delete a locked object.
  1000. // Administrators and estate managers are still able to click+grab locked objects not
  1001. // owned by them in the scene
  1002. // This is by design.
  1003. if (locked && (moverID == objectOwner))
  1004. return false;
  1005. }
  1006. return permission;
  1007. }
  1008. private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
  1009. {
  1010. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1011. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1012. if ((newPoint.X > 257f || newPoint.X < -1f || newPoint.Y > 257f || newPoint.Y < -1f))
  1013. {
  1014. return true;
  1015. }
  1016. SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
  1017. ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
  1018. if (!enteringRegion)
  1019. {
  1020. ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y);
  1021. if (fromland == land) // Not entering
  1022. return true;
  1023. }
  1024. if (land == null)
  1025. {
  1026. return false;
  1027. }
  1028. if ((land.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0)
  1029. {
  1030. return true;
  1031. }
  1032. if (!m_scene.Entities.ContainsKey(objectID))
  1033. {
  1034. return false;
  1035. }
  1036. // If it's not an object, we cant edit it.
  1037. if (!(m_scene.Entities[objectID] is SceneObjectGroup))
  1038. {
  1039. return false;
  1040. }
  1041. if (GenericParcelPermission(task.OwnerID, newPoint, 0))
  1042. {
  1043. return true;
  1044. }
  1045. //Otherwise, false!
  1046. return false;
  1047. }
  1048. private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene)
  1049. {
  1050. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1051. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1052. GroupPowers powers;
  1053. ILandObject l;
  1054. ScenePresence sp = scene.GetScenePresence(user);
  1055. if (sp == null)
  1056. return false;
  1057. IClientAPI client = sp.ControllingClient;
  1058. foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
  1059. {
  1060. // Any user can return their own objects at any time
  1061. //
  1062. if (GenericObjectPermission(user, g.UUID, false))
  1063. continue;
  1064. // This is a short cut for efficiency. If land is non-null,
  1065. // then all objects are on that parcel and we can save
  1066. // ourselves the checking for each prim. Much faster.
  1067. //
  1068. if (land != null)
  1069. {
  1070. l = land;
  1071. }
  1072. else
  1073. {
  1074. Vector3 pos = g.AbsolutePosition;
  1075. l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
  1076. }
  1077. // If it's not over any land, then we can't do a thing
  1078. if (l == null)
  1079. {
  1080. objects.Remove(g);
  1081. continue;
  1082. }
  1083. // If we own the land outright, then allow
  1084. //
  1085. if (l.LandData.OwnerID == user)
  1086. continue;
  1087. // Group voodoo
  1088. //
  1089. if (l.LandData.IsGroupOwned)
  1090. {
  1091. powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID);
  1092. // Not a group member, or no rights at all
  1093. //
  1094. if (powers == (GroupPowers)0)
  1095. {
  1096. objects.Remove(g);
  1097. continue;
  1098. }
  1099. // Group deeded object?
  1100. //
  1101. if (g.OwnerID == l.LandData.GroupID &&
  1102. (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0)
  1103. {
  1104. objects.Remove(g);
  1105. continue;
  1106. }
  1107. // Group set object?
  1108. //
  1109. if (g.GroupID == l.LandData.GroupID &&
  1110. (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0)
  1111. {
  1112. objects.Remove(g);
  1113. continue;
  1114. }
  1115. if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0)
  1116. {
  1117. objects.Remove(g);
  1118. continue;
  1119. }
  1120. // So we can remove all objects from this group land.
  1121. // Fine.
  1122. //
  1123. continue;
  1124. }
  1125. // By default, we can't remove
  1126. //
  1127. objects.Remove(g);
  1128. }
  1129. if (objects.Count == 0)
  1130. return false;
  1131. return true;
  1132. }
  1133. private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene)
  1134. {
  1135. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1136. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1137. bool permission = false;
  1138. ILandObject land = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
  1139. if (land == null) return false;
  1140. if ((land.LandData.Flags & ((int)ParcelFlags.CreateObjects)) ==
  1141. (int)ParcelFlags.CreateObjects)
  1142. permission = true;
  1143. if (IsAdministrator(owner))
  1144. {
  1145. permission = true;
  1146. }
  1147. // Powers are zero, because GroupPowers.AllowRez is not a precondition for rezzing objects
  1148. if (GenericParcelPermission(owner, objectPosition, 0))
  1149. {
  1150. permission = true;
  1151. }
  1152. return permission;
  1153. }
  1154. private bool CanRunConsoleCommand(UUID user, Scene requestFromScene)
  1155. {
  1156. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1157. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1158. return IsAdministrator(user);
  1159. }
  1160. private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene)
  1161. {
  1162. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1163. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1164. return true;
  1165. }
  1166. private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene)
  1167. {
  1168. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1169. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1170. return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale);
  1171. }
  1172. private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene)
  1173. {
  1174. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1175. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1176. return GenericObjectPermission(stealer,objectID, false);
  1177. }
  1178. private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene)
  1179. {
  1180. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1181. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1182. bool permission = GenericObjectPermission(userID, objectID, false);
  1183. if (!permission)
  1184. {
  1185. if (!m_scene.Entities.ContainsKey(objectID))
  1186. {
  1187. return false;
  1188. }
  1189. // If it's not an object, we cant edit it.
  1190. if (!(m_scene.Entities[objectID] is SceneObjectGroup))
  1191. {
  1192. return false;
  1193. }
  1194. SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
  1195. // UUID taskOwner = null;
  1196. // Added this because at this point in time it wouldn't be wise for
  1197. // the administrator object permissions to take effect.
  1198. // UUID objectOwner = task.OwnerID;
  1199. if ((task.RootPart.EveryoneMask & PERM_COPY) != 0)
  1200. permission = true;
  1201. if (task.OwnerID != userID)
  1202. {
  1203. if ((task.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS))
  1204. permission = false;
  1205. }
  1206. else
  1207. {
  1208. if ((task.GetEffectivePermissions() & PERM_COPY) != PERM_COPY)
  1209. permission = false;
  1210. }
  1211. }
  1212. else
  1213. {
  1214. SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
  1215. if ((task.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS))
  1216. permission = false;
  1217. }
  1218. return permission;
  1219. }
  1220. private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene)
  1221. {
  1222. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1223. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1224. // Estate override
  1225. if (GenericEstatePermission(user))
  1226. return true;
  1227. float X = position.X;
  1228. float Y = position.Y;
  1229. if (X > ((int)Constants.RegionSize - 1))
  1230. X = ((int)Constants.RegionSize - 1);
  1231. if (Y > ((int)Constants.RegionSize - 1))
  1232. Y = ((int)Constants.RegionSize - 1);
  1233. if (X < 0)
  1234. X = 0;
  1235. if (Y < 0)
  1236. Y = 0;
  1237. ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
  1238. if (parcel == null)
  1239. return false;
  1240. // Others allowed to terraform?
  1241. if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowTerraform)) != 0)
  1242. return true;
  1243. // Land owner can terraform too
  1244. if (parcel != null && GenericParcelPermission(user, parcel, (ulong)GroupPowers.AllowEditLand))
  1245. return true;
  1246. return false;
  1247. }
  1248. /// <summary>
  1249. /// Check whether the specified user can view the given script
  1250. /// </summary>
  1251. /// <param name="script"></param>
  1252. /// <param name="objectID"></param>
  1253. /// <param name="user"></param>
  1254. /// <param name="scene"></param>
  1255. /// <returns></returns>
  1256. private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene)
  1257. {
  1258. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1259. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1260. if (objectID == UUID.Zero) // User inventory
  1261. {
  1262. IInventoryService invService = m_scene.InventoryService;
  1263. InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
  1264. assetRequestItem = invService.GetItem(assetRequestItem);
  1265. if (assetRequestItem == null && LibraryRootFolder != null) // Library item
  1266. {
  1267. assetRequestItem = LibraryRootFolder.FindItem(script);
  1268. if (assetRequestItem != null) // Implicitly readable
  1269. return true;
  1270. }
  1271. // SL is rather harebrained here. In SL, a script you
  1272. // have mod/copy no trans is readable. This subverts
  1273. // permissions, but is used in some products, most
  1274. // notably Hippo door plugin and HippoRent 5 networked
  1275. // prim counter.
  1276. // To enable this broken SL-ism, remove Transfer from
  1277. // the below expressions.
  1278. // Trying to improve on SL perms by making a script
  1279. // readable only if it's really full perms
  1280. //
  1281. if ((assetRequestItem.CurrentPermissions &
  1282. ((uint)PermissionMask.Modify |
  1283. (uint)PermissionMask.Copy |
  1284. (uint)PermissionMask.Transfer)) !=
  1285. ((uint)PermissionMask.Modify |
  1286. (uint)PermissionMask.Copy |
  1287. (uint)PermissionMask.Transfer))
  1288. return false;
  1289. }
  1290. else // Prim inventory
  1291. {
  1292. SceneObjectPart part = scene.GetSceneObjectPart(objectID);
  1293. if (part == null)
  1294. return false;
  1295. if (part.OwnerID != user)
  1296. {
  1297. if (part.GroupID == UUID.Zero)
  1298. return false;
  1299. if (!IsGroupMember(part.GroupID, user, 0))
  1300. return false;
  1301. if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
  1302. return false;
  1303. }
  1304. else
  1305. {
  1306. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  1307. return false;
  1308. }
  1309. TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
  1310. if (ti == null)
  1311. return false;
  1312. if (ti.OwnerID != user)
  1313. {
  1314. if (ti.GroupID == UUID.Zero)
  1315. return false;
  1316. if (!IsGroupMember(ti.GroupID, user, 0))
  1317. return false;
  1318. }
  1319. // Require full perms
  1320. if ((ti.CurrentPermissions &
  1321. ((uint)PermissionMask.Modify |
  1322. (uint)PermissionMask.Copy |
  1323. (uint)PermissionMask.Transfer)) !=
  1324. ((uint)PermissionMask.Modify |
  1325. (uint)PermissionMask.Copy |
  1326. (uint)PermissionMask.Transfer))
  1327. return false;
  1328. }
  1329. return true;
  1330. }
  1331. /// <summary>
  1332. /// Check whether the specified user can view the given notecard
  1333. /// </summary>
  1334. /// <param name="script"></param>
  1335. /// <param name="objectID"></param>
  1336. /// <param name="user"></param>
  1337. /// <param name="scene"></param>
  1338. /// <returns></returns>
  1339. private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene)
  1340. {
  1341. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1342. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1343. if (objectID == UUID.Zero) // User inventory
  1344. {
  1345. IInventoryService invService = m_scene.InventoryService;
  1346. InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
  1347. assetRequestItem = invService.GetItem(assetRequestItem);
  1348. if (assetRequestItem == null && LibraryRootFolder != null) // Library item
  1349. {
  1350. assetRequestItem = LibraryRootFolder.FindItem(notecard);
  1351. if (assetRequestItem != null) // Implicitly readable
  1352. return true;
  1353. }
  1354. // Notecards are always readable unless no copy
  1355. //
  1356. if ((assetRequestItem.CurrentPermissions &
  1357. (uint)PermissionMask.Copy) !=
  1358. (uint)PermissionMask.Copy)
  1359. return false;
  1360. }
  1361. else // Prim inventory
  1362. {
  1363. SceneObjectPart part = scene.GetSceneObjectPart(objectID);
  1364. if (part == null)
  1365. return false;
  1366. if (part.OwnerID != user)
  1367. {
  1368. if (part.GroupID == UUID.Zero)
  1369. return false;
  1370. if (!IsGroupMember(part.GroupID, user, 0))
  1371. return false;
  1372. }
  1373. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  1374. return false;
  1375. TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
  1376. if (ti == null)
  1377. return false;
  1378. if (ti.OwnerID != user)
  1379. {
  1380. if (ti.GroupID == UUID.Zero)
  1381. return false;
  1382. if (!IsGroupMember(ti.GroupID, user, 0))
  1383. return false;
  1384. }
  1385. // Notecards are always readable unless no copy
  1386. //
  1387. if ((ti.CurrentPermissions &
  1388. (uint)PermissionMask.Copy) !=
  1389. (uint)PermissionMask.Copy)
  1390. return false;
  1391. }
  1392. return true;
  1393. }
  1394. #endregion
  1395. private bool CanLinkObject(UUID userID, UUID objectID)
  1396. {
  1397. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1398. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1399. return GenericObjectPermission(userID, objectID, false);
  1400. }
  1401. private bool CanDelinkObject(UUID userID, UUID objectID)
  1402. {
  1403. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1404. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1405. return GenericObjectPermission(userID, objectID, false);
  1406. }
  1407. private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene)
  1408. {
  1409. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1410. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1411. return true;
  1412. }
  1413. private bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
  1414. {
  1415. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1416. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1417. return true;
  1418. }
  1419. private bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
  1420. {
  1421. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1422. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1423. return true;
  1424. }
  1425. /// <summary>
  1426. /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
  1427. /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
  1428. /// </summary>
  1429. /// <param name="invType"></param>
  1430. /// <param name="objectID"></param>
  1431. /// <param name="userID"></param>
  1432. /// <returns></returns>
  1433. private bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
  1434. {
  1435. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1436. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1437. if ((int)InventoryType.LSL == invType)
  1438. if (m_allowedScriptCreators == UserSet.Administrators && !IsAdministrator(userID))
  1439. return false;
  1440. return true;
  1441. }
  1442. /// <summary>
  1443. /// Check whether the specified user is allowed to create the given inventory type in their inventory.
  1444. /// </summary>
  1445. /// <param name="invType"></param>
  1446. /// <param name="userID"></param>
  1447. /// <returns></returns>
  1448. private bool CanCreateUserInventory(int invType, UUID userID)
  1449. {
  1450. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1451. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1452. if ((int)InventoryType.LSL == invType)
  1453. if (m_allowedScriptCreators == UserSet.Administrators && !IsAdministrator(userID))
  1454. return false;
  1455. return true;
  1456. }
  1457. /// <summary>
  1458. /// Check whether the specified user is allowed to copy the given inventory type in their inventory.
  1459. /// </summary>
  1460. /// <param name="itemID"></param>
  1461. /// <param name="userID"></param>
  1462. /// <returns></returns>
  1463. private bool CanCopyUserInventory(UUID itemID, UUID userID)
  1464. {
  1465. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1466. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1467. return true;
  1468. }
  1469. /// <summary>
  1470. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  1471. /// </summary>
  1472. /// <param name="itemID"></param>
  1473. /// <param name="userID"></param>
  1474. /// <returns></returns>
  1475. private bool CanEditUserInventory(UUID itemID, UUID userID)
  1476. {
  1477. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1478. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1479. return true;
  1480. }
  1481. /// <summary>
  1482. /// Check whether the specified user is allowed to delete the given inventory item from their own inventory.
  1483. /// </summary>
  1484. /// <param name="itemID"></param>
  1485. /// <param name="userID"></param>
  1486. /// <returns></returns>
  1487. private bool CanDeleteUserInventory(UUID itemID, UUID userID)
  1488. {
  1489. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1490. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1491. return true;
  1492. }
  1493. private bool CanTeleport(UUID userID, Scene scene)
  1494. {
  1495. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1496. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1497. return true;
  1498. }
  1499. private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene)
  1500. {
  1501. DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
  1502. if (m_bypassPermissions) return m_bypassPermissionsValue;
  1503. SceneObjectPart part = m_scene.GetSceneObjectPart(prim);
  1504. // If we selected a sub-prim to reset, prim won't represent the object, but only a part.
  1505. // We have to check the permissions of the object, though.
  1506. if (part.ParentID != 0) prim = part.ParentUUID;
  1507. // You can reset the scripts in any object you can edit
  1508. return GenericObjectPermission(agentID, prim, false);
  1509. }
  1510. private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene)
  1511. {
  1512. //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
  1513. switch (scriptType) {
  1514. case 0:
  1515. if (GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) {
  1516. return(true);
  1517. }
  1518. break;
  1519. case 1:
  1520. if (GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) {
  1521. return(true);
  1522. }
  1523. break;
  1524. case 2:
  1525. if (GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) {
  1526. return(true);
  1527. }
  1528. break;
  1529. case 3:
  1530. if (GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString()))
  1531. {
  1532. return (true);
  1533. }
  1534. break;
  1535. case 4:
  1536. if (GrantYP.Count == 0 || GrantYP.ContainsKey(ownerUUID.ToString()))
  1537. {
  1538. return (true);
  1539. }
  1540. break;
  1541. }
  1542. return(false);
  1543. }
  1544. }
  1545. }