One more module converted: PermissionsModule.
parent
571f6a0300
commit
ba2318bd61
|
@ -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<string, bool> GrantVB = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
|
||||
private IFriendsModule m_friendsModule;
|
||||
private IGroupsModule m_groupsModule;
|
||||
private IMoapModule m_moapModule;
|
||||
|
||||
private IFriendsModule m_friendsModule;
|
||||
private IFriendsModule FriendsModule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_friendsModule == null)
|
||||
m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
|
||||
return m_friendsModule;
|
||||
}
|
||||
}
|
||||
private IGroupsModule m_groupsModule;
|
||||
private IGroupsModule GroupsModule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_groupsModule == null)
|
||||
m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
|
||||
return m_groupsModule;
|
||||
}
|
||||
}
|
||||
|
||||
private IMoapModule m_moapModule;
|
||||
private IMoapModule MoapModule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_moapModule == null)
|
||||
m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();
|
||||
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);
|
||||
|
@ -154,97 +186,31 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
|||
else
|
||||
m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks");
|
||||
|
||||
scene.RegisterModuleInterface<IPermissionsModule>(this);
|
||||
|
||||
//Register functions with Scene External Checks!
|
||||
m_scene.Permissions.OnBypassPermissions += BypassPermissions;
|
||||
m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions;
|
||||
m_scene.Permissions.OnPropagatePermissions += PropagatePermissions;
|
||||
m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags;
|
||||
m_scene.Permissions.OnAbandonParcel += CanAbandonParcel;
|
||||
m_scene.Permissions.OnReclaimParcel += CanReclaimParcel;
|
||||
m_scene.Permissions.OnDeedParcel += CanDeedParcel;
|
||||
m_scene.Permissions.OnDeedObject += CanDeedObject;
|
||||
m_scene.Permissions.OnIsGod += IsGod;
|
||||
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.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.OnObjectEntry += CanObjectEntry;
|
||||
m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED
|
||||
m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED
|
||||
m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand;
|
||||
m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED
|
||||
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.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.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.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.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED
|
||||
|
||||
m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia;
|
||||
m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
|
||||
|
||||
m_scene.AddCommand("Users", this, "bypass permissions",
|
||||
"bypass permissions <true / false>",
|
||||
"Bypass permission checks",
|
||||
HandleBypassPermissions);
|
||||
|
||||
m_scene.AddCommand("Users", this, "force permissions",
|
||||
"force permissions <true / false>",
|
||||
"Force permissions on or off",
|
||||
HandleForcePermissions);
|
||||
|
||||
m_scene.AddCommand("Debug", this, "debug permissions",
|
||||
"debug permissions <true / false>",
|
||||
"Turn on permissions debugging",
|
||||
HandleDebugPermissions);
|
||||
|
||||
string grant = myConfig.GetString("GrantLSL", "");
|
||||
if (grant.Length > 0) {
|
||||
foreach (string uuidl in grant.Split(',')) {
|
||||
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(',')) {
|
||||
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(',')) {
|
||||
if (grant.Length > 0)
|
||||
{
|
||||
foreach (string uuidl in grant.Split(','))
|
||||
{
|
||||
string uuid = uuidl.Trim(" \t".ToCharArray());
|
||||
GrantVB.Add(uuid, true);
|
||||
}
|
||||
|
@ -269,9 +235,119 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
|||
GrantYP.Add(uuid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_scene = scene;
|
||||
|
||||
scene.RegisterModuleInterface<IPermissionsModule>(this);
|
||||
|
||||
//Register functions with Scene External Checks!
|
||||
m_scene.Permissions.OnBypassPermissions += BypassPermissions;
|
||||
m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions;
|
||||
m_scene.Permissions.OnPropagatePermissions += PropagatePermissions;
|
||||
m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags;
|
||||
m_scene.Permissions.OnAbandonParcel += CanAbandonParcel;
|
||||
m_scene.Permissions.OnReclaimParcel += CanReclaimParcel;
|
||||
m_scene.Permissions.OnDeedParcel += CanDeedParcel;
|
||||
m_scene.Permissions.OnDeedObject += CanDeedObject;
|
||||
m_scene.Permissions.OnIsGod += IsGod;
|
||||
m_scene.Permissions.OnIsGridGod += IsGridGod;
|
||||
m_scene.Permissions.OnIsAdministrator += IsAdministrator;
|
||||
m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
|
||||
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;
|
||||
m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand;
|
||||
m_scene.Permissions.OnMoveObject += CanMoveObject;
|
||||
m_scene.Permissions.OnObjectEntry += CanObjectEntry;
|
||||
m_scene.Permissions.OnReturnObjects += CanReturnObjects;
|
||||
m_scene.Permissions.OnRezObject += CanRezObject;
|
||||
m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand;
|
||||
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;
|
||||
m_scene.Permissions.OnDelinkObject += CanDelinkObject;
|
||||
m_scene.Permissions.OnBuyLand += CanBuyLand;
|
||||
|
||||
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;
|
||||
m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory;
|
||||
m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
|
||||
m_scene.Permissions.OnResetScript += CanResetScript;
|
||||
|
||||
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;
|
||||
|
||||
m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia;
|
||||
m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
|
||||
|
||||
m_scene.AddCommand("Users", this, "bypass permissions",
|
||||
"bypass permissions <true / false>",
|
||||
"Bypass permission checks",
|
||||
HandleBypassPermissions);
|
||||
|
||||
m_scene.AddCommand("Users", this, "force permissions",
|
||||
"force permissions <true / false>",
|
||||
"Force permissions on or off",
|
||||
HandleForcePermissions);
|
||||
|
||||
m_scene.AddCommand("Debug", this, "debug permissions",
|
||||
"debug permissions <true / false>",
|
||||
"Turn on permissions debugging",
|
||||
HandleDebugPermissions);
|
||||
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
|
||||
}
|
||||
|
||||
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 &&
|
||||
|
@ -343,39 +419,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
|||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
|
||||
|
||||
if (m_friendsModule == null)
|
||||
m_log.Debug("[PERMISSIONS]: Friends module not found, friend permissions will not work");
|
||||
|
||||
m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
|
||||
|
||||
if (m_groupsModule == null)
|
||||
m_log.Debug("[PERMISSIONS]: Groups module not found, group permissions will not work");
|
||||
|
||||
m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();
|
||||
|
||||
// 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
|
|||
/// <returns></returns>
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue