From dfc553d0a4c25d6c1f491b228e89402c0415acda Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 15 Aug 2008 13:13:39 +0000 Subject: [PATCH] Fix up master avatar handling for estate owners. Introduces a new hierarchical rights structure. MasterAvatar: Owner of the region server (may be null), net gods (users with GodLevel 200), Estate owner (from database). Look at Opensim.ini.example to enable net gods. Estate owner will default to master avatar. --- .../Rest/Regions/RegionDetails.cs | 5 ++++- .../ClientStack/LindenUDP/LLClientView.cs | 7 ++++++- .../Region/ClientStack/RegionApplicationBase.cs | 5 ++++- .../Communications/OGS1/OGS1GridServices.cs | 13 ++++--------- OpenSim/Region/DataSnapshot/EstateSnapshot.cs | 14 ++++++++++---- .../World/Archiver/ArchiveReadRequest.cs | 2 ++ .../World/Estate/EstateManagementModule.cs | 9 ++++++++- .../Modules/World/Land/LandManagementModule.cs | 15 ++++++++++++--- .../World/Permissions/PermissionsModule.cs | 13 +++++++------ .../Environment/Scenes/Scene.Inventory.cs | 2 ++ OpenSim/Region/Environment/Scenes/Scene.cs | 17 +++++++++++++++++ .../Region/Environment/Scenes/ScenePresence.cs | 10 +++++++++- 12 files changed, 85 insertions(+), 27 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs index 67af7b5a31..74cf35475c 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs @@ -58,7 +58,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions region_id = regInfo.RegionID.ToString(); region_x = regInfo.RegionLocX; region_y = regInfo.RegionLocY; - region_owner_id = regInfo.MasterAvatarAssignedUUID.ToString(); + if (regInfo.EstateSettings.EstateOwner != LLUUID.Zero) + region_owner_id = regInfo.EstateSettings.EstateOwner.ToString(); + else + region_owner_id = regInfo.MasterAvatarAssignedUUID.ToString(); region_http_port = regInfo.HttpPort; region_server_uri = regInfo.ServerURI; region_external_hostname = regInfo.ExternalHostName; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 74f4d4467a..212567fd24 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2693,7 +2693,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP //Sending Estate Settings returnblock[0].Parameter = Helpers.StringToField(estateName); - returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString()); + // TODO: remove this cruft once MasterAvatar is fully deprecated + // + if(m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.EstateOwner.ToString()); + else + returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString()); returnblock[2].Parameter = Helpers.StringToField(estateID.ToString()); returnblock[3].Parameter = Helpers.StringToField(estateFlags.ToString()); diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 3e941cfd02..7a552a6790 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -135,11 +135,14 @@ namespace OpenSim.Region.ClientStack scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); scene.PhysicsScene.SetWaterLevel((float)regionInfo.RegionSettings.WaterHeight); + // TODO: Remove this cruft once MasterAvatar is fully deprecated //Master Avatar Setup UserProfileData masterAvatar; if (scene.RegionInfo.MasterAvatarAssignedUUID != LLUUID.Zero) { masterAvatar = m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarAssignedUUID); + scene.RegionInfo.MasterAvatarFirstName = masterAvatar.FirstName; + scene.RegionInfo.MasterAvatarLastName = masterAvatar.SurName; } else { @@ -151,7 +154,7 @@ namespace OpenSim.Region.ClientStack if (masterAvatar != null) { - m_log.Info("[PARCEL]: Found master avatar [" + masterAvatar.ID.ToString() + "]"); + m_log.InfoFormat("[PARCEL]: Found master avatar {0} {1} [" + masterAvatar.ID.ToString() + "]", scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName); scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.ID; } else diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 410b4acb30..f1e420e8b7 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -123,15 +123,10 @@ namespace OpenSim.Region.Communications.OGS1 GridParams["server_uri"] = regionInfo.ServerURI; GridParams["region_secret"] = regionInfo.regionSecret; - // part of an initial brutish effort to provide accurate information (as per the xml region spec) - // wrt the ownership of a given region - // the (very bad) assumption is that this value is being read and handled inconsistently or - // not at all. Current strategy is to put the code in place to support the validity of this information - // and to roll forward debugging any issues from that point - // - // this particular section of the mod attempts to supply a value from the region's xml file to the grid - // server for the UUID of the region's owner (master avatar) - GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); + if(regionInfo.MasterAvatarAssignedUUID != LLUUID.Zero) + GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); + else + GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); diff --git a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs index 99a4a0d1aa..eccdcf167e 100644 --- a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs @@ -28,6 +28,7 @@ using System; using System.Xml; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.DataSnapshot.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -50,15 +51,20 @@ namespace OpenSim.Region.DataSnapshot.Providers public XmlNode RequestSnapshotData(XmlDocument factory) { //Estate data section - contains who owns a set of sims and the name of the set. - //In Opensim all the estate names are the same as the Master Avatar (owner of the sim) //Now in DataSnapshotProvider module form! XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); LLUUID ownerid = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if (m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner; + + // Can't fail because if it weren't in cache, we wouldn't be here + // + UserProfileData userProfile = m_scene.CommsManager.UserService.GetUserProfile(ownerid); //TODO: Change to query userserver about the master avatar UUID ? - String firstname = m_scene.RegionInfo.MasterAvatarFirstName; - String lastname = m_scene.RegionInfo.MasterAvatarLastName; + String firstname = userProfile.FirstName; + String lastname = userProfile.SurName; //TODO: Fix the marshalling system to have less copypasta gruntwork XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", ""); @@ -113,4 +119,4 @@ namespace OpenSim.Region.DataSnapshot.Providers #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 2b1a4edcf0..e6597c3986 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -137,6 +137,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver // Try to retain the original creator/owner/lastowner if their uuid is present on this grid // otherwise, use the master avatar uuid instead LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if (m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + masterAvatarId = m_scene.RegionInfo.EstateSettings.EstateOwner; foreach (SceneObjectPart part in sceneObject.Children.Values) { if (!resolveUserUuid(part.CreatorID)) diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index d22aac615f..1e622be7ff 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -212,6 +212,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate { // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. + if (user == m_scene.RegionInfo.EstateSettings.EstateOwner) + return; // never process EO if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID) return; // never process owner @@ -557,7 +559,10 @@ namespace OpenSim.Region.Environment.Modules.World.Estate args.regionFlags = GetRegionFlags(); args.regionName = m_scene.RegionInfo.RegionName; - args.SimOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if (m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; + else + args.SimOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID; args.terrainBase0 = LLUUID.Zero; args.terrainBase1 = LLUUID.Zero; args.terrainBase2 = LLUUID.Zero; @@ -811,6 +816,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate { if (avatarID == m_scene.RegionInfo.MasterAvatarAssignedUUID) return true; + if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner) + return true; List ems = new List(m_scene.RegionInfo.EstateSettings.EstateManagers); if (ems.Contains(avatarID)) diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index ca03035fd2..d5cb0eb095 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs @@ -162,7 +162,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); - fullSimParcel.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if(m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + fullSimParcel.landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; + else + fullSimParcel.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; fullSimParcel.landData.ClaimDate = Util.UnixTimeSinceEpoch(); AddLandObject(fullSimParcel); } @@ -931,7 +934,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land { if (m_scene.ExternalChecks.ExternalChecksCanAbandonParcel(remote_client.AgentId, landList[local_id])) { - landList[local_id].landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if(m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + landList[local_id].landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; + else + landList[local_id].landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; m_scene.Broadcast(SendParcelOverlay); landList[local_id].sendLandUpdateToClient(remote_client); } @@ -945,7 +951,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land { if (m_scene.ExternalChecks.ExternalChecksCanReclaimParcel(remote_client.AgentId, landList[local_id])) { - landList[local_id].landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + if(m_scene.RegionInfo.EstateSettings.EstateOwner != LLUUID.Zero) + landList[local_id].landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; + else + landList[local_id].landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; landList[local_id].landData.ClaimDate = Util.UnixTimeSinceEpoch(); m_scene.Broadcast(SendParcelOverlay); landList[local_id].sendLandUpdateToClient(remote_client); diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 0fbd4fb752..6f72767f73 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -32,6 +32,7 @@ using System.Collections; using System.Collections.Generic; using System.Reflection; using log4net; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules.Framework; using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; @@ -63,6 +64,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions private bool m_bypassPermissions = false; private bool m_bypassPermissionsValue = true; private bool m_debugPermissions = false; + private bool m_allowGridGods = false; #endregion @@ -136,6 +138,8 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions if (!modules.Contains("DefaultPermissionsModule")) return; + m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false); + m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true); if (m_bypassPermissions) @@ -231,11 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions protected bool IsAdministrator(LLUUID user) { -// m_log.DebugFormat( -// "[PERMISSIONS]: Is adminstrator called for {0} where region master avatar is {1}", -// user, m_scene.RegionInfo.MasterAvatarAssignedUUID); - - // If there is no master avatar, return false if (m_scene.RegionInfo.MasterAvatarAssignedUUID != LLUUID.Zero) { if (m_scene.RegionInfo.MasterAvatarAssignedUUID == user) @@ -246,7 +245,9 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions if (m_scene.RegionInfo.EstateSettings.EstateOwner == user) return true; } - + UserProfileData userProfile = m_scene.CommsManager.UserService.GetUserProfile(user); + if((userProfile.GodLevel) >= 200 && m_allowGridGods) + return true; return false; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index ca77f2b7cc..3f62610024 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -116,6 +116,8 @@ namespace OpenSim.Region.Environment.Scenes { userlevel = 1; } + // TODO: remove this cruft once MasterAvatar is fully deprecated + // if (m_regInfo.MasterAvatarAssignedUUID == AgentID) { userlevel = 2; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 22251e969a..00d829807e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -3777,5 +3777,22 @@ namespace OpenSim.Region.Environment.Scenes //Console.WriteLine("Terrain packet unacked, resending patch: " + patchX + " , " + patchY); client.SendLayerData(patchX, patchY, Heightmap.GetFloatsSerialised()); } + +// public bool IsAdministrator(LLUUID user) +// { +// if(RegionInfo.MasterAvatarAssignedUUID != LLUUID.Zero) +// { +// if(RegionInfo.MasterAvatarAssignedUUID == user) +// return true; +// } +// +// UserProfileData userProfile = +// CommsManager.UserService.GetUserProfile(user); +// +// if(userProfile.GodLevel >= 200) +// return true; +// +// return false; +// } } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index d8d534ebcb..b4cf70a5dc 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -2017,7 +2017,15 @@ namespace OpenSim.Region.Environment.Scenes { if (godStatus) { - m_godlevel = 250; + // TODO: remove this cruft once the master avatar is fully + // deprecated. For now, assign god level 200 to anyone + // who is granted god powers, but has no god level set. + // + UserProfileData userProfile = m_scene.CommsManager.UserService.GetUserProfile(agentID); + if(userProfile.GodLevel > 0) + m_godlevel = userProfile.GodLevel; + else + m_godlevel = 200; } else {