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
tourmaline
MW 2007-03-28 18:10:52 +00:00
parent c3ae2a721b
commit 35fa85069e
15 changed files with 216 additions and 33 deletions

View File

@ -11,7 +11,7 @@ namespace OpenSim.Framework.Inventory
//Holds the local copy of Inventory info for a agent
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
public Dictionary<LLUUID, InventoryItem> InventoryItems;
public InventoryFolder InventoryRoot;
public InventoryFolder InventoryRoot = new InventoryFolder();
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
@ -36,8 +36,10 @@ namespace OpenSim.Framework.Inventory
InventoryRoot.ParentID = new LLUUID();
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
}
public bool CreateNewFolder(LLUUID folderID, ushort type)
@ -47,10 +49,61 @@ namespace OpenSim.Framework.Inventory
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
this.AgentID = newAgentID;
/* InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = new LLUUID();
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.FolderName = "My Inventory-";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);*/
InventoryRoot.OwnerID = this.AgentID;
if (createTextures)
{
this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parent;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
return true;
}
return false;
}
public bool UpdateItem(LLUUID itemID, AssetBase asset)
{
if(this.InventoryItems.ContainsKey(itemID))
@ -96,7 +149,7 @@ namespace OpenSim.Framework.Inventory
//public List<InventoryFolder> Subfolders;
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ParentID;
public LLUUID ParentID = LLUUID.Zero;
public string FolderName;
public ushort DefaultType;
public ushort Version;

View File

@ -10,5 +10,6 @@ namespace OpenSim.Framework.Interfaces
{
AgentInventory RequestAgentsInventory(LLUUID agentID);
void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
}
}

View File

@ -32,6 +32,7 @@ namespace OpenSim.Framework.User
Circuits = new Dictionary<LLUUID, uint>();
Inventory = new AgentInventory();
homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ;
}
public void InitSessionData()

View File

@ -68,6 +68,7 @@ namespace OpenSim.Framework.User
UserProfile TheUser = GetProfileByName(firstname, lastname);
/*
if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null)))
{
XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
@ -78,7 +79,7 @@ namespace OpenSim.Framework.User
PresenceErrorResp.Value = PresenceErrorRespData;
return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""));
}
}*/
try
{
@ -116,6 +117,7 @@ namespace OpenSim.Framework.User
ArrayList ClassifiedCategories = new ArrayList();
ClassifiedCategories.Add(ClassifiedCategoriesHash);
Console.WriteLine("copying inventory data to response");
ArrayList AgentInventory = new ArrayList();
foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values)
{
@ -142,7 +144,7 @@ namespace OpenSim.Framework.User
uint circode = (uint)(Util.RandomClass.Next());
//TheUser.AddSimCircuit(circode, SimInfo.UUID);
LoginGoodData["last_name"] = "\"" + TheUser.firstname + "\"";
LoginGoodData["last_name"] = "\"" + TheUser.lastname + "\"";
LoginGoodData["ui-config"] = ui_config;
LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
LoginGoodData["login-flags"] = LoginFlags;
@ -160,7 +162,7 @@ namespace OpenSim.Framework.User
LoginGoodData["start_location"] = "last";
LoginGoodData["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() + "]}";
LoginGoodData["message"] = DefaultStartupMsg;
LoginGoodData["first_name"] = "\"" + firstname + "\"";
LoginGoodData["first_name"] = "\"" + TheUser.firstname + "\"";
LoginGoodData["circuit_code"] = (Int32)circode;
LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port;
LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated();
@ -196,8 +198,8 @@ namespace OpenSim.Framework.User
SimProfile SimInfo = new SimProfile();
//get siminfo from grid server
SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
uint circode = (uint)response["circuit_code"];
theUser.AddSimCircuit(circode, SimInfo.UUID);
Int32 circode = (Int32)response["circuit_code"];
theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 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_ip"] = SimInfo.sim_ip.ToString();
response["sim_port"] = (Int32)SimInfo.sim_port;

View File

@ -41,19 +41,23 @@ namespace OpenSim.Framework.User
public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
{
UserProfile TheUser = GetProfileByName(firstname, lastname);
passwd = passwd.Remove(0, 3); //remove $1$
if (TheUser != null)
{
if (TheUser.MD5passwd == passwd)
{
Console.WriteLine("UserProfile - authorised ");
return true;
}
else
{
Console.WriteLine("UserProfile - not authorised, password not match "+ TheUser.MD5passwd +" and "+ passwd);
return false;
}
}
else
{
Console.WriteLine("UserProfile - not authorised , unkown: "+ firstname +" , " + lastname);
return false;
}
@ -66,12 +70,14 @@ namespace OpenSim.Framework.User
public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
{
Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
UserProfile newprofile = new UserProfile();
newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
newprofile.firstname = firstname;
newprofile.lastname = lastname;
newprofile.MD5passwd = MD5passwd;
newprofile.UUID = LLUUID.Random();
newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
this.UserProfiles.Add(newprofile.UUID, newprofile);
return newprofile;
}

View File

@ -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

View File

@ -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
{
@ -53,9 +54,23 @@ namespace OpenSim.Assets
}
public void AddNewAgentsInventory(AgentInventory 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);
}

View File

@ -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

View File

@ -11,6 +11,7 @@ namespace OpenSim
{
public IAssetServer AssetServer;
public IGridServer GridServer;
public IUserServer UserServer;
public string AssetDll = "";
public string GridDll = "";

View File

@ -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" />

View File

@ -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));
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);
}

View File

@ -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)
{
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();
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;
}
}
}

View File

@ -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);
}
}

View File

@ -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)
{

View File

@ -18,6 +18,7 @@ namespace OpenSim
bool startLoginServer = false;
string physicsEngine = "basicphysics";
bool allowFlying = false;
bool userAccounts = false;
for (int i = 0; i < args.Length; i++)
{
@ -30,6 +31,10 @@ namespace OpenSim
{
startLoginServer = true;
}
if (args[i] == "-accounts")
{
userAccounts = true;
}
if (args[i] == "-realphysx")
{
physicsEngine = "RealPhysX";
@ -44,6 +49,7 @@ namespace OpenSim
OpenSimMain sim = new OpenSimMain( sandBoxMode, startLoginServer, physicsEngine );
// OpenSimRoot.Instance.Application = sim;
sim.m_sandbox = sandBoxMode;
sim.user_accounts = userAccounts;
OpenSim.world.Avatar.PhysicsEngineFlying = allowFlying;
sim.StartUp();