From 35fa85069e792579ebd44a974053d6dce288ea0a Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 28 Mar 2007 18:10:52 +0000 Subject: After hours of searching for a bug, it works - User accounts in sandbox mode, currently they are not persistent between restarts (ie restarting opensim.exe) but should be persistent between sessions (login/ logout). Use the -account command line arg to enable them and then create new accounts through the web interface --- OpenSim.RegionServer/AgentAssetUpload.cs | 1 + OpenSim.RegionServer/Assets/InventoryCache.cs | 27 ++++++++++-- OpenSim.RegionServer/CAPS/AdminWebFront.cs | 33 +++++++++++++-- OpenSim.RegionServer/Grid.cs | 1 + .../OpenSim.RegionServer.dll.build | 1 - OpenSim.RegionServer/OpenSimMain.cs | 22 ++++++++-- OpenSim.RegionServer/SimClient.cs | 48 ++++++++++++++++++---- .../UserServer/LocalUserProfileManager.cs | 14 ++++--- OpenSim.RegionServer/UserServer/LoginServer.cs | 17 +++++++- 9 files changed, 139 insertions(+), 25 deletions(-) (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim.RegionServer/AgentAssetUpload.cs index 9f85598..d346647 100644 --- a/OpenSim.RegionServer/AgentAssetUpload.cs +++ b/OpenSim.RegionServer/AgentAssetUpload.cs @@ -201,6 +201,7 @@ namespace OpenSim { //already complete so we can add it to the inventory m_assetCache.AddAsset(trans.Asset); + Console.WriteLine("creating inventory item"); Console.WriteLine( "ITem created is " +m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset).ToStringHyphenated()); } else diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs index 3a4aa36..1090940 100644 --- a/OpenSim.RegionServer/Assets/InventoryCache.cs +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs @@ -33,6 +33,7 @@ using libsecondlife.Packets; //using OpenSim.GridServers; using OpenSim.Framework.Inventory; using OpenSim.Framework.Assets; +using OpenSim.Framework.Interfaces; namespace OpenSim.Assets { @@ -54,7 +55,21 @@ namespace OpenSim.Assets public void AddNewAgentsInventory(AgentInventory agentInventory) { - this._agentsInventory.Add(agentInventory.AgentID, agentInventory); + if (!this._agentsInventory.ContainsKey(agentInventory.AgentID)) + { + this._agentsInventory.Add(agentInventory.AgentID, agentInventory); + } + } + + public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver) + { + AgentInventory res = null; + if (!this._agentsInventory.ContainsKey(agentID)) + { + res = userserver.RequestAgentsInventory(agentID); + this._agentsInventory.Add(agentID,res); + } + return res; } public AgentInventory GetAgentsInventory(LLUUID agentID) @@ -67,13 +82,16 @@ namespace OpenSim.Assets return null; } - public void ClientLeaving(LLUUID clientID) - { + public void ClientLeaving(LLUUID clientID, IUserServer userserver) + { if (this._agentsInventory.ContainsKey(clientID)) { + if (userserver != null) + { + userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]); + } this._agentsInventory.Remove(clientID); } - } public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID) @@ -171,6 +189,7 @@ namespace OpenSim.Assets Descend.ItemData[i].Type = Item.Type; Descend.ItemData[i].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); } + userInfo.OutPacket(Descend); } diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs index 03f8692..8224050 100644 --- a/OpenSim.RegionServer/CAPS/AdminWebFront.cs +++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.IO; using OpenSim.world; +using OpenSim.UserServer; namespace OpenSim.CAPS { @@ -13,9 +14,11 @@ namespace OpenSim.CAPS private string LoginForm; private string passWord = "Admin"; private World m_world; + private LoginServer _userServer; - public AdminWebFront(string password, World world) + public AdminWebFront(string password, World world, LoginServer userserver) { + _userServer = userserver; m_world = world; passWord = password; LoadAdminPage(); @@ -63,8 +66,12 @@ namespace OpenSim.CAPS case "/Admin/NewAccount": if (requestMethod == "POST") { - string[] comp = new string[10]; - string[] passw = new string[3]; + string firstName = ""; + string secondName = ""; + string userPasswd = ""; + string[] comp; + string[] passw; + string[] line; string delimStr = "&"; char[] delimiter = delimStr.ToCharArray(); string delimStr2 = "="; @@ -75,6 +82,26 @@ namespace OpenSim.CAPS passw = comp[3].Split(delimiter2); if (passw[1] == passWord) { + + line = comp[0].Split(delimiter2); //split firstname + if (line.Length > 1) + { + firstName = line[1]; + } + line = comp[1].Split(delimiter2); //split secondname + if (line.Length > 1) + { + secondName = line[1]; + } + line = comp[2].Split(delimiter2); //split user password + if (line.Length > 1) + { + userPasswd = line[1]; + } + if (this._userServer != null) + { + this._userServer.CreateUserAccount(firstName, secondName, userPasswd); + } responseString = "

New Account created

"; } else diff --git a/OpenSim.RegionServer/Grid.cs b/OpenSim.RegionServer/Grid.cs index b0df6a8..db5b8fe 100644 --- a/OpenSim.RegionServer/Grid.cs +++ b/OpenSim.RegionServer/Grid.cs @@ -11,6 +11,7 @@ namespace OpenSim { public IAssetServer AssetServer; public IGridServer GridServer; + public IUserServer UserServer; public string AssetDll = ""; public string GridDll = ""; diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index b67db54..ef7dce9 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build @@ -16,7 +16,6 @@ - diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index ed3e732..07a2d6d 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -75,6 +75,7 @@ namespace OpenSim public string m_physicsEngine; public bool m_sandbox = false; public bool m_loginserver; + public bool user_accounts = false; protected ConsoleBase m_console; @@ -145,12 +146,22 @@ namespace OpenSim m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); - HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld)); - if ( m_loginserver && m_sandbox) + LoginServer loginServer = null; + if (m_loginserver && m_sandbox) { - LoginServer loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort); + loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); loginServer.Startup(); + + } + if((m_loginserver) && (m_sandbox) && (user_accounts)) + { + this.GridServers.UserServer = loginServer; + HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); + } + else + { + HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); } MainServerListener(); @@ -210,6 +221,11 @@ namespace OpenSim UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); + if ((this.GridServers.UserServer != null) && (user_accounts)) + { + Console.WriteLine("setting userserver"); + newuser.UserServer = this.GridServers.UserServer; + } //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); } diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index e013b63..6eb48fb 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs @@ -75,10 +75,20 @@ namespace OpenSim private Dictionary m_clientThreads; private AssetCache m_assetCache; private IGridServer m_gridServer; + private IUserServer m_userServer = null; private OpenSimNetworkHandler m_application; private InventoryCache m_inventoryCache; private bool m_sandboxMode; + + public IUserServer UserServer + { + set + { + this.m_userServer = value; + } + } + private void ack_pack(Packet Pack) { //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); @@ -241,6 +251,15 @@ namespace OpenSim { client.OutPacket(kill); } + if (this.m_userServer != null) + { + this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); + } + else + { + this.m_inventoryCache.ClientLeaving(this.AgentID, null); + } + m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); lock (m_world.Entities) { @@ -657,12 +676,16 @@ namespace OpenSim // Create Inventory, currently only works for sandbox mode if (m_sandboxMode) { + AgentInventory inventory = null; if (sessionInfo.LoginInfo.InventoryFolder != null) { - this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); + inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); if (sessionInfo.LoginInfo.BaseFolder != null) { - m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); + if (!inventory.HasFolder(sessionInfo.LoginInfo.BaseFolder)) + { + m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); + } this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder; AssetBase[] inventorySet = m_assetCache.CreateNewInventorySet(this.AgentID); if (inventorySet != null) @@ -683,12 +706,23 @@ namespace OpenSim } } - private void CreateInventory(LLUUID baseFolder) + private AgentInventory CreateInventory(LLUUID baseFolder) { - AgentInventory inventory = new AgentInventory(); - inventory.AgentID = this.AgentID; - m_inventoryCache.AddNewAgentsInventory(inventory); - m_inventoryCache.CreateNewInventoryFolder(this, baseFolder); + AgentInventory inventory = null; + if (this.m_userServer != null) + { + // a user server is set so request the inventory from it + inventory = m_inventoryCache.FetchAgentsInventory(this.AgentID, m_userServer); + } + else + { + inventory = new AgentInventory(); + inventory.AgentID = this.AgentID; + inventory.CreateRootFolder(this.AgentID, false); + m_inventoryCache.AddNewAgentsInventory(inventory); + m_inventoryCache.CreateNewInventoryFolder(this, baseFolder); + } + return inventory; } } } diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs index eee1c3a..b31feda 100644 --- a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs +++ b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs @@ -30,8 +30,8 @@ namespace OpenSim.UserServer public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser) { - uint circode = (uint)response["circuit_code"]; - theUser.AddSimCircuit(circode, LLUUID.Random()); + Int32 circode = (Int32)response["circuit_code"]; + theUser.AddSimCircuit((uint)circode, LLUUID.Random()); response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; response["sim_port"] = m_port; response["sim_ip"] = m_ipAddr; @@ -40,18 +40,18 @@ namespace OpenSim.UserServer string first; string last; - if (response.Contains("first")) + if (response.Contains("first_name")) { - first = (string)response["first"]; + first = (string)response["first_name"]; } else { first = "test"; } - if (response.Contains("last")) + if (response.Contains("last_name")) { - last = (string)response["last"]; + last = (string)response["last_name"]; } else { @@ -67,12 +67,14 @@ namespace OpenSim.UserServer _login.Last = last; _login.Agent = new LLUUID((string)response["agent_id"]) ; _login.Session = new LLUUID((string)response["session_id"]); + _login.SecureSession = new LLUUID((string)response["secure_session_id"]); _login.BaseFolder = null; _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]); //working on local computer if so lets add to the gridserver's list of sessions? if (m_gridServer.GetName() == "Local") { + Console.WriteLine("adding login data to gridserver"); ((LocalGridBase)this.m_gridServer).AddNewSession(_login); } } diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs index 0bbe0b0..7b4c1f0 100644 --- a/OpenSim.RegionServer/UserServer/LoginServer.cs +++ b/OpenSim.RegionServer/UserServer/LoginServer.cs @@ -66,11 +66,12 @@ namespace OpenSim.UserServer private int m_simPort; private string m_simAddr; - public LoginServer(IGridServer gridServer, string simAddr, int simPort) + public LoginServer(IGridServer gridServer, string simAddr, int simPort , bool useAccounts) { m_gridServer = gridServer; m_simPort = simPort; m_simAddr = simAddr; + this.userAccounts = useAccounts; } // InitializeLogin: initialize the login @@ -395,6 +396,15 @@ namespace OpenSim.UserServer return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); } + public bool CreateUserAccount(string firstName, string lastName, string password) + { + Console.WriteLine("creating new user account"); + string mdPassword = EncodePassword(password); + Console.WriteLine("with password: " + mdPassword); + this.userManager.CreateNewProfile(firstName, lastName, mdPassword); + return true; + } + //IUserServer implementation public AgentInventory RequestAgentsInventory(LLUUID agentID) { @@ -407,6 +417,11 @@ namespace OpenSim.UserServer return aInventory; } + public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory) + { + return true; + } + public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) { -- cgit v1.1