aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2012-11-11 15:59:09 -0800
committerDiva Canto2012-11-11 15:59:09 -0800
commitba2318bd6143fb465ca641647d44a3c6e1ffc8c1 (patch)
treef6ad7f51932350094a0956eb50eb1a508f841d5a
parentOne more module converted: XMLRPCModule. Removed it from the special loading ... (diff)
downloadopensim-SC_OLD-ba2318bd6143fb465ca641647d44a3c6e1ffc8c1.zip
opensim-SC_OLD-ba2318bd6143fb465ca641647d44a3c6e1ffc8c1.tar.gz
opensim-SC_OLD-ba2318bd6143fb465ca641647d44a3c6e1ffc8c1.tar.bz2
opensim-SC_OLD-ba2318bd6143fb465ca641647d44a3c6e1ffc8c1.tar.xz
One more module converted: PermissionsModule.
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs267
1 files changed, 155 insertions, 112 deletions
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;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39 39
40using Mono.Addins;
41
40namespace OpenSim.Region.CoreModules.World.Permissions 42namespace OpenSim.Region.CoreModules.World.Permissions
41{ 43{
42 public class PermissionsModule : IRegionModule, IPermissionsModule 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PermissionsModule")]
45 public class PermissionsModule : INonSharedRegionModule, IPermissionsModule
43 { 46 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 48
46 protected Scene m_scene; 49 protected Scene m_scene;
50 protected bool m_Enabled;
47 51
48 private InventoryFolderImpl m_libraryRootFolder; 52 private InventoryFolderImpl m_libraryRootFolder;
49 protected InventoryFolderImpl LibraryRootFolder 53 protected InventoryFolderImpl LibraryRootFolder
@@ -114,18 +118,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions
114 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); 118 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
115 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); 119 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
116 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); 120 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
121
117 private IFriendsModule m_friendsModule; 122 private IFriendsModule m_friendsModule;
123 private IFriendsModule FriendsModule
124 {
125 get
126 {
127 if (m_friendsModule == null)
128 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
129 return m_friendsModule;
130 }
131 }
118 private IGroupsModule m_groupsModule; 132 private IGroupsModule m_groupsModule;
119 private IMoapModule m_moapModule; 133 private IGroupsModule GroupsModule
134 {
135 get
136 {
137 if (m_groupsModule == null)
138 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
139 return m_groupsModule;
140 }
141 }
120 142
143 private IMoapModule m_moapModule;
144 private IMoapModule MoapModule
145 {
146 get
147 {
148 if (m_moapModule == null)
149 m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();
150 return m_moapModule;
151 }
152 }
121 #endregion 153 #endregion
122 154
123 #region IRegionModule Members 155 #region INonSharedRegionModule Members
124 156
125 public void Initialise(Scene scene, IConfigSource config) 157 public void Initialise(IConfigSource config)
126 { 158 {
127 m_scene = scene;
128
129 IConfig myConfig = config.Configs["Startup"]; 159 IConfig myConfig = config.Configs["Startup"];
130 160
131 string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); 161 string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule");
@@ -135,6 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
135 if (!modules.Contains("DefaultPermissionsModule")) 165 if (!modules.Contains("DefaultPermissionsModule"))
136 return; 166 return;
137 167
168 m_Enabled = true;
169
138 m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false); 170 m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false);
139 m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true); 171 m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true);
140 m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); 172 m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true);
@@ -144,7 +176,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
144 176
145 m_SimpleBuildPermissions = myConfig.GetBoolean("simple_build_permissions", false); 177 m_SimpleBuildPermissions = myConfig.GetBoolean("simple_build_permissions", false);
146 178
147 m_allowedScriptCreators 179 m_allowedScriptCreators
148 = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators); 180 = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators);
149 m_allowedScriptEditors 181 m_allowedScriptEditors
150 = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); 182 = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors);
@@ -154,6 +186,64 @@ namespace OpenSim.Region.CoreModules.World.Permissions
154 else 186 else
155 m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); 187 m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks");
156 188
189 string grant = myConfig.GetString("GrantLSL", "");
190 if (grant.Length > 0)
191 {
192 foreach (string uuidl in grant.Split(','))
193 {
194 string uuid = uuidl.Trim(" \t".ToCharArray());
195 GrantLSL.Add(uuid, true);
196 }
197 }
198
199 grant = myConfig.GetString("GrantCS", "");
200 if (grant.Length > 0)
201 {
202 foreach (string uuidl in grant.Split(','))
203 {
204 string uuid = uuidl.Trim(" \t".ToCharArray());
205 GrantCS.Add(uuid, true);
206 }
207 }
208
209 grant = myConfig.GetString("GrantVB", "");
210 if (grant.Length > 0)
211 {
212 foreach (string uuidl in grant.Split(','))
213 {
214 string uuid = uuidl.Trim(" \t".ToCharArray());
215 GrantVB.Add(uuid, true);
216 }
217 }
218
219 grant = myConfig.GetString("GrantJS", "");
220 if (grant.Length > 0)
221 {
222 foreach (string uuidl in grant.Split(','))
223 {
224 string uuid = uuidl.Trim(" \t".ToCharArray());
225 GrantJS.Add(uuid, true);
226 }
227 }
228
229 grant = myConfig.GetString("GrantYP", "");
230 if (grant.Length > 0)
231 {
232 foreach (string uuidl in grant.Split(','))
233 {
234 string uuid = uuidl.Trim(" \t".ToCharArray());
235 GrantYP.Add(uuid, true);
236 }
237 }
238 }
239
240 public void AddRegion(Scene scene)
241 {
242 if (!m_Enabled)
243 return;
244
245 m_scene = scene;
246
157 scene.RegisterModuleInterface<IPermissionsModule>(this); 247 scene.RegisterModuleInterface<IPermissionsModule>(this);
158 248
159 //Register functions with Scene External Checks! 249 //Register functions with Scene External Checks!
@@ -169,44 +259,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions
169 m_scene.Permissions.OnIsGridGod += IsGridGod; 259 m_scene.Permissions.OnIsGridGod += IsGridGod;
170 m_scene.Permissions.OnIsAdministrator += IsAdministrator; 260 m_scene.Permissions.OnIsAdministrator += IsAdministrator;
171 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 261 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
172 m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED 262 m_scene.Permissions.OnDeleteObject += CanDeleteObject;
173 m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED 263 m_scene.Permissions.OnEditObject += CanEditObject;
174 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED 264 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties;
175 m_scene.Permissions.OnInstantMessage += CanInstantMessage; 265 m_scene.Permissions.OnInstantMessage += CanInstantMessage;
176 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; //NOT YET IMPLEMENTED 266 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer;
177 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED 267 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand;
178 m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED 268 m_scene.Permissions.OnMoveObject += CanMoveObject;
179 m_scene.Permissions.OnObjectEntry += CanObjectEntry; 269 m_scene.Permissions.OnObjectEntry += CanObjectEntry;
180 m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED 270 m_scene.Permissions.OnReturnObjects += CanReturnObjects;
181 m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED 271 m_scene.Permissions.OnRezObject += CanRezObject;
182 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; 272 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand;
183 m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED 273 m_scene.Permissions.OnRunScript += CanRunScript;
184 m_scene.Permissions.OnCompileScript += CanCompileScript; 274 m_scene.Permissions.OnCompileScript += CanCompileScript;
185 m_scene.Permissions.OnSellParcel += CanSellParcel; 275 m_scene.Permissions.OnSellParcel += CanSellParcel;
186 m_scene.Permissions.OnTakeObject += CanTakeObject; 276 m_scene.Permissions.OnTakeObject += CanTakeObject;
187 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; 277 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject;
188 m_scene.Permissions.OnTerraformLand += CanTerraformLand; 278 m_scene.Permissions.OnTerraformLand += CanTerraformLand;
189 m_scene.Permissions.OnLinkObject += CanLinkObject; //NOT YET IMPLEMENTED 279 m_scene.Permissions.OnLinkObject += CanLinkObject;
190 m_scene.Permissions.OnDelinkObject += CanDelinkObject; //NOT YET IMPLEMENTED 280 m_scene.Permissions.OnDelinkObject += CanDelinkObject;
191 m_scene.Permissions.OnBuyLand += CanBuyLand; //NOT YET IMPLEMENTED 281 m_scene.Permissions.OnBuyLand += CanBuyLand;
192 282
193 m_scene.Permissions.OnViewNotecard += CanViewNotecard; //NOT YET IMPLEMENTED 283 m_scene.Permissions.OnViewNotecard += CanViewNotecard;
194 m_scene.Permissions.OnViewScript += CanViewScript; //NOT YET IMPLEMENTED 284 m_scene.Permissions.OnViewScript += CanViewScript;
195 m_scene.Permissions.OnEditNotecard += CanEditNotecard; //NOT YET IMPLEMENTED 285 m_scene.Permissions.OnEditNotecard += CanEditNotecard;
196 m_scene.Permissions.OnEditScript += CanEditScript; //NOT YET IMPLEMENTED 286 m_scene.Permissions.OnEditScript += CanEditScript;
197 287
198 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; 288 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory;
199 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED 289 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory;
200 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; //NOT YET IMPLEMENTED 290 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory;
201 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; //NOT YET IMPLEMENTED 291 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
202 m_scene.Permissions.OnResetScript += CanResetScript; 292 m_scene.Permissions.OnResetScript += CanResetScript;
203 293
204 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; //NOT YET IMPLEMENTED 294 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory;
205 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; //NOT YET IMPLEMENTED 295 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory;
206 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; //NOT YET IMPLEMENTED 296 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory;
207 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED 297 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory;
208 298
209 m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED 299 m_scene.Permissions.OnTeleport += CanTeleport;
210 300
211 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; 301 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia;
212 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; 302 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
@@ -226,52 +316,38 @@ namespace OpenSim.Region.CoreModules.World.Permissions
226 "Turn on permissions debugging", 316 "Turn on permissions debugging",
227 HandleDebugPermissions); 317 HandleDebugPermissions);
228 318
229 string grant = myConfig.GetString("GrantLSL",""); 319 }
230 if (grant.Length > 0) {
231 foreach (string uuidl in grant.Split(',')) {
232 string uuid = uuidl.Trim(" \t".ToCharArray());
233 GrantLSL.Add(uuid, true);
234 }
235 }
236 320
237 grant = myConfig.GetString("GrantCS",""); 321 public void RegionLoaded(Scene scene)
238 if (grant.Length > 0) { 322 {
239 foreach (string uuidl in grant.Split(',')) { 323 }
240 string uuid = uuidl.Trim(" \t".ToCharArray());
241 GrantCS.Add(uuid, true);
242 }
243 }
244 324
245 grant = myConfig.GetString("GrantVB",""); 325 public void RemoveRegion(Scene scene)
246 if (grant.Length > 0) { 326 {
247 foreach (string uuidl in grant.Split(',')) { 327 if (!m_Enabled)
248 string uuid = uuidl.Trim(" \t".ToCharArray()); 328 return;
249 GrantVB.Add(uuid, true);
250 }
251 }
252 329
253 grant = myConfig.GetString("GrantJS", ""); 330 m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
254 if (grant.Length > 0) 331 }
255 {
256 foreach (string uuidl in grant.Split(','))
257 {
258 string uuid = uuidl.Trim(" \t".ToCharArray());
259 GrantJS.Add(uuid, true);
260 }
261 }
262 332
263 grant = myConfig.GetString("GrantYP", ""); 333 public void Close()
264 if (grant.Length > 0) 334 {
265 { 335 }
266 foreach (string uuidl in grant.Split(',')) 336
267 { 337 public string Name
268 string uuid = uuidl.Trim(" \t".ToCharArray()); 338 {
269 GrantYP.Add(uuid, true); 339 get { return "PermissionsModule"; }
270 } 340 }
271 }
272 341
342 public Type ReplaceableInterface
343 {
344 get { return null; }
273 } 345 }
274 346
347 #endregion
348
349 #region Console command handlers
350
275 public void HandleBypassPermissions(string module, string[] args) 351 public void HandleBypassPermissions(string module, string[] args)
276 { 352 {
277 if (m_scene.ConsoleScene() != null && 353 if (m_scene.ConsoleScene() != null &&
@@ -290,7 +366,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
290 m_bypassPermissions = val; 366 m_bypassPermissions = val;
291 367
292 m_log.InfoFormat( 368 m_log.InfoFormat(
293 "[PERMISSIONS]: Set permissions bypass to {0} for {1}", 369 "[PERMISSIONS]: Set permissions bypass to {0} for {1}",
294 m_bypassPermissions, m_scene.RegionInfo.RegionName); 370 m_bypassPermissions, m_scene.RegionInfo.RegionName);
295 } 371 }
296 } 372 }
@@ -343,39 +419,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
343 } 419 }
344 } 420 }
345 421
346 public void PostInitialise()
347 {
348 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
349
350 if (m_friendsModule == null)
351 m_log.Debug("[PERMISSIONS]: Friends module not found, friend permissions will not work");
352
353 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
354
355 if (m_groupsModule == null)
356 m_log.Debug("[PERMISSIONS]: Groups module not found, group permissions will not work");
357
358 m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();
359
360 // This log line will be commented out when no longer required for debugging
361// if (m_moapModule == null)
362// m_log.Warn("[PERMISSIONS]: Media on a prim module not found, media on a prim permissions will not work");
363 }
364
365 public void Close()
366 {
367 }
368
369 public string Name
370 {
371 get { return "PermissionsModule"; }
372 }
373
374 public bool IsSharedModule
375 {
376 get { return false; }
377 }
378
379 #endregion 422 #endregion
380 423
381 #region Helper Functions 424 #region Helper Functions
@@ -400,10 +443,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
400 /// <returns></returns> 443 /// <returns></returns>
401 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) 444 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
402 { 445 {
403 if (null == m_groupsModule) 446 if (null == GroupsModule)
404 return false; 447 return false;
405 448
406 GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); 449 GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID);
407 450
408 if (gmd != null) 451 if (gmd != null)
409 { 452 {
@@ -503,10 +546,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
503 if (user == UUID.Zero) 546 if (user == UUID.Zero)
504 return false; 547 return false;
505 548
506 if (m_friendsModule == null) 549 if (FriendsModule == null)
507 return false; 550 return false;
508 551
509 int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner); 552 int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner);
510 return (friendPerms & (int)FriendRights.CanModifyObjects) != 0; 553 return (friendPerms & (int)FriendRights.CanModifyObjects) != 0;
511 } 554 }
512 555
@@ -1915,14 +1958,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1915// "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}", 1958// "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}",
1916// agentID, primID, face); 1959// agentID, primID, face);
1917 1960
1918 if (null == m_moapModule) 1961 if (null == MoapModule)
1919 return false; 1962 return false;
1920 1963
1921 SceneObjectPart part = m_scene.GetSceneObjectPart(primID); 1964 SceneObjectPart part = m_scene.GetSceneObjectPart(primID);
1922 if (null == part) 1965 if (null == part)
1923 return false; 1966 return false;
1924 1967
1925 MediaEntry me = m_moapModule.GetMediaEntry(part, face); 1968 MediaEntry me = MoapModule.GetMediaEntry(part, face);
1926 1969
1927 // If there is no existing media entry then it can be controlled (in this context, created). 1970 // If there is no existing media entry then it can be controlled (in this context, created).
1928 if (null == me) 1971 if (null == me)
@@ -1941,14 +1984,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1941// "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}", 1984// "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}",
1942// agentID, primID, face); 1985// agentID, primID, face);
1943 1986
1944 if (null == m_moapModule) 1987 if (null == MoapModule)
1945 return false; 1988 return false;
1946 1989
1947 SceneObjectPart part = m_scene.GetSceneObjectPart(primID); 1990 SceneObjectPart part = m_scene.GetSceneObjectPart(primID);
1948 if (null == part) 1991 if (null == part)
1949 return false; 1992 return false;
1950 1993
1951 MediaEntry me = m_moapModule.GetMediaEntry(part, face); 1994 MediaEntry me = MoapModule.GetMediaEntry(part, face);
1952 1995
1953 // If there is no existing media entry then it can be controlled (in this context, created). 1996 // If there is no existing media entry then it can be controlled (in this context, created).
1954 if (null == me) 1997 if (null == me)