From ba2318bd6143fb465ca641647d44a3c6e1ffc8c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 15:59:09 -0800 Subject: One more module converted: PermissionsModule. --- .../World/Permissions/PermissionsModule.cs | 267 ++++++++++++--------- 1 file changed, 155 insertions(+), 112 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 7a8a57c..ddaa227 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -37,13 +37,17 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.World.Permissions { - public class PermissionsModule : IRegionModule, IPermissionsModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PermissionsModule")] + public class PermissionsModule : INonSharedRegionModule, IPermissionsModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_scene; + protected bool m_Enabled; private InventoryFolderImpl m_libraryRootFolder; protected InventoryFolderImpl LibraryRootFolder @@ -114,18 +118,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions private Dictionary GrantVB = new Dictionary(); private Dictionary GrantJS = new Dictionary(); private Dictionary GrantYP = new Dictionary(); + private IFriendsModule m_friendsModule; + private IFriendsModule FriendsModule + { + get + { + if (m_friendsModule == null) + m_friendsModule = m_scene.RequestModuleInterface(); + return m_friendsModule; + } + } private IGroupsModule m_groupsModule; - private IMoapModule m_moapModule; + private IGroupsModule GroupsModule + { + get + { + if (m_groupsModule == null) + m_groupsModule = m_scene.RequestModuleInterface(); + return m_groupsModule; + } + } + private IMoapModule m_moapModule; + private IMoapModule MoapModule + { + get + { + if (m_moapModule == null) + m_moapModule = m_scene.RequestModuleInterface(); + return m_moapModule; + } + } #endregion - #region IRegionModule Members + #region INonSharedRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; - IConfig myConfig = config.Configs["Startup"]; string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); @@ -135,6 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (!modules.Contains("DefaultPermissionsModule")) return; + m_Enabled = true; + m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false); m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true); m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); @@ -144,7 +176,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_SimpleBuildPermissions = myConfig.GetBoolean("simple_build_permissions", false); - m_allowedScriptCreators + m_allowedScriptCreators = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators); m_allowedScriptEditors = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); @@ -154,6 +186,64 @@ namespace OpenSim.Region.CoreModules.World.Permissions else m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); + string grant = myConfig.GetString("GrantLSL", ""); + if (grant.Length > 0) + { + foreach (string uuidl in grant.Split(',')) + { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantLSL.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantCS", ""); + if (grant.Length > 0) + { + foreach (string uuidl in grant.Split(',')) + { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantCS.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantVB", ""); + if (grant.Length > 0) + { + foreach (string uuidl in grant.Split(',')) + { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantVB.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantJS", ""); + if (grant.Length > 0) + { + foreach (string uuidl in grant.Split(',')) + { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantJS.Add(uuid, true); + } + } + + grant = myConfig.GetString("GrantYP", ""); + if (grant.Length > 0) + { + foreach (string uuidl in grant.Split(',')) + { + string uuid = uuidl.Trim(" \t".ToCharArray()); + GrantYP.Add(uuid, true); + } + } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_scene = scene; + scene.RegisterModuleInterface(this); //Register functions with Scene External Checks! @@ -169,44 +259,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnIsGridGod += IsGridGod; m_scene.Permissions.OnIsAdministrator += IsAdministrator; m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; - m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED - m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED - m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED + m_scene.Permissions.OnDeleteObject += CanDeleteObject; + m_scene.Permissions.OnEditObject += CanEditObject; + m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; m_scene.Permissions.OnInstantMessage += CanInstantMessage; - m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; //NOT YET IMPLEMENTED - m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED - m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED + m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; + m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; + m_scene.Permissions.OnMoveObject += CanMoveObject; m_scene.Permissions.OnObjectEntry += CanObjectEntry; - m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED - m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED + m_scene.Permissions.OnReturnObjects += CanReturnObjects; + m_scene.Permissions.OnRezObject += CanRezObject; m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; - m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED + m_scene.Permissions.OnRunScript += CanRunScript; m_scene.Permissions.OnCompileScript += CanCompileScript; m_scene.Permissions.OnSellParcel += CanSellParcel; m_scene.Permissions.OnTakeObject += CanTakeObject; m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; m_scene.Permissions.OnTerraformLand += CanTerraformLand; - m_scene.Permissions.OnLinkObject += CanLinkObject; //NOT YET IMPLEMENTED - m_scene.Permissions.OnDelinkObject += CanDelinkObject; //NOT YET IMPLEMENTED - m_scene.Permissions.OnBuyLand += CanBuyLand; //NOT YET IMPLEMENTED + m_scene.Permissions.OnLinkObject += CanLinkObject; + m_scene.Permissions.OnDelinkObject += CanDelinkObject; + m_scene.Permissions.OnBuyLand += CanBuyLand; - m_scene.Permissions.OnViewNotecard += CanViewNotecard; //NOT YET IMPLEMENTED - m_scene.Permissions.OnViewScript += CanViewScript; //NOT YET IMPLEMENTED - m_scene.Permissions.OnEditNotecard += CanEditNotecard; //NOT YET IMPLEMENTED - m_scene.Permissions.OnEditScript += CanEditScript; //NOT YET IMPLEMENTED + m_scene.Permissions.OnViewNotecard += CanViewNotecard; + m_scene.Permissions.OnViewScript += CanViewScript; + m_scene.Permissions.OnEditNotecard += CanEditNotecard; + m_scene.Permissions.OnEditScript += CanEditScript; m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; - m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED - m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; //NOT YET IMPLEMENTED - m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; //NOT YET IMPLEMENTED + m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; + m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; + m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; m_scene.Permissions.OnResetScript += CanResetScript; - m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; //NOT YET IMPLEMENTED - m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; //NOT YET IMPLEMENTED - m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; //NOT YET IMPLEMENTED - m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED + m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; + m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; + m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; + m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; - m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED + m_scene.Permissions.OnTeleport += CanTeleport; m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; @@ -226,52 +316,38 @@ namespace OpenSim.Region.CoreModules.World.Permissions "Turn on permissions debugging", HandleDebugPermissions); - string grant = myConfig.GetString("GrantLSL",""); - if (grant.Length > 0) { - foreach (string uuidl in grant.Split(',')) { - string uuid = uuidl.Trim(" \t".ToCharArray()); - GrantLSL.Add(uuid, true); - } - } + } - grant = myConfig.GetString("GrantCS",""); - if (grant.Length > 0) { - foreach (string uuidl in grant.Split(',')) { - string uuid = uuidl.Trim(" \t".ToCharArray()); - GrantCS.Add(uuid, true); - } - } + public void RegionLoaded(Scene scene) + { + } - grant = myConfig.GetString("GrantVB",""); - if (grant.Length > 0) { - foreach (string uuidl in grant.Split(',')) { - string uuid = uuidl.Trim(" \t".ToCharArray()); - GrantVB.Add(uuid, true); - } - } + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; - grant = myConfig.GetString("GrantJS", ""); - if (grant.Length > 0) - { - foreach (string uuidl in grant.Split(',')) - { - string uuid = uuidl.Trim(" \t".ToCharArray()); - GrantJS.Add(uuid, true); - } - } + m_scene.UnregisterModuleInterface(this); + } - grant = myConfig.GetString("GrantYP", ""); - if (grant.Length > 0) - { - foreach (string uuidl in grant.Split(',')) - { - string uuid = uuidl.Trim(" \t".ToCharArray()); - GrantYP.Add(uuid, true); - } - } + public void Close() + { + } + + public string Name + { + get { return "PermissionsModule"; } + } + public Type ReplaceableInterface + { + get { return null; } } + #endregion + + #region Console command handlers + public void HandleBypassPermissions(string module, string[] args) { if (m_scene.ConsoleScene() != null && @@ -290,7 +366,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_bypassPermissions = val; m_log.InfoFormat( - "[PERMISSIONS]: Set permissions bypass to {0} for {1}", + "[PERMISSIONS]: Set permissions bypass to {0} for {1}", m_bypassPermissions, m_scene.RegionInfo.RegionName); } } @@ -343,39 +419,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions } } - public void PostInitialise() - { - m_friendsModule = m_scene.RequestModuleInterface(); - - if (m_friendsModule == null) - m_log.Debug("[PERMISSIONS]: Friends module not found, friend permissions will not work"); - - m_groupsModule = m_scene.RequestModuleInterface(); - - if (m_groupsModule == null) - m_log.Debug("[PERMISSIONS]: Groups module not found, group permissions will not work"); - - m_moapModule = m_scene.RequestModuleInterface(); - - // This log line will be commented out when no longer required for debugging -// if (m_moapModule == null) -// m_log.Warn("[PERMISSIONS]: Media on a prim module not found, media on a prim permissions will not work"); - } - - public void Close() - { - } - - public string Name - { - get { return "PermissionsModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - #endregion #region Helper Functions @@ -400,10 +443,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions /// protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) { - if (null == m_groupsModule) + if (null == GroupsModule) return false; - GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); + GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID); if (gmd != null) { @@ -503,10 +546,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (user == UUID.Zero) return false; - if (m_friendsModule == null) + if (FriendsModule == null) return false; - int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner); + int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner); return (friendPerms & (int)FriendRights.CanModifyObjects) != 0; } @@ -1915,14 +1958,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions // "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}", // agentID, primID, face); - if (null == m_moapModule) + if (null == MoapModule) return false; SceneObjectPart part = m_scene.GetSceneObjectPart(primID); if (null == part) return false; - MediaEntry me = m_moapModule.GetMediaEntry(part, face); + MediaEntry me = MoapModule.GetMediaEntry(part, face); // If there is no existing media entry then it can be controlled (in this context, created). if (null == me) @@ -1941,14 +1984,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions // "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}", // agentID, primID, face); - if (null == m_moapModule) + if (null == MoapModule) return false; SceneObjectPart part = m_scene.GetSceneObjectPart(primID); if (null == part) return false; - MediaEntry me = m_moapModule.GetMediaEntry(part, face); + MediaEntry me = MoapModule.GetMediaEntry(part, face); // If there is no existing media entry then it can be controlled (in this context, created). if (null == me) -- cgit v1.1