mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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 = "<p> New Account created </p>";
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace OpenSim
|
||||
{
|
||||
public IAssetServer AssetServer;
|
||||
public IGridServer GridServer;
|
||||
public IUserServer UserServer;
|
||||
public string AssetDll = "";
|
||||
public string GridDll = "";
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<include name="Grid.cs" />
|
||||
<include name="OpenSimMain.cs" />
|
||||
<include name="OpenSimNetworkHandler.cs" />
|
||||
<include name="OpenSimRoot.cs" />
|
||||
<include name="QueItem.cs" />
|
||||
<include name="SimClient.cs" />
|
||||
<include name="SimConsole.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);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,20 @@ namespace OpenSim
|
||||
private Dictionary<uint, SimClient> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user