* CHANGED SOME CONSOLE COMMAND BEHAVIOURS
* Normalized 'change-region' so (almost) all commands are context sensitive (use 'root' or '..' to set 'all scenes' context) * 'terrain-sim' is thusly obsolete, use 'change-region', followed by 'terrain' * Introduced SceneManager to administrate operations on group of scenes and moved relevant funcs there. * In it, there's a ForEach(Action<Scene>) that either passes all scenes, or only current scene depending on context. * Changed default prim backup (save-xml/load-xml) xml to "prim-backup.xml" * Changed Disable/EnablePermissions to BypassPermissions = true/false; Also: * Removed unused and non-existent project refafrisby
parent
4cb8108fae
commit
6961013c24
|
@ -50,6 +50,8 @@ namespace OpenSim
|
|||
|
||||
public class OpenSimMain : RegionApplicationBase, conscmd_callback
|
||||
{
|
||||
private const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
|
||||
|
||||
public string m_physicsEngine;
|
||||
public string m_scriptEngine;
|
||||
public bool m_sandbox;
|
||||
|
@ -65,7 +67,7 @@ namespace OpenSim
|
|||
|
||||
protected List<UDPServer> m_udpServers = new List<UDPServer>();
|
||||
protected List<RegionInfo> m_regionData = new List<RegionInfo>();
|
||||
protected List<Scene> m_localScenes = new List<Scene>();
|
||||
protected SceneManager m_localScenes = new SceneManager();
|
||||
|
||||
private bool m_silent;
|
||||
private readonly string m_logFilename = ("region-console.log");
|
||||
|
@ -213,10 +215,7 @@ namespace OpenSim
|
|||
//}
|
||||
|
||||
//Server side object editing permissions checking
|
||||
if (m_permissions)
|
||||
scene.PermissionsMngr.EnablePermissions();
|
||||
else
|
||||
scene.PermissionsMngr.DisablePermissions();
|
||||
scene.PermissionsMngr.BypassPermissions = !m_permissions;
|
||||
|
||||
m_localScenes.Add(scene);
|
||||
|
||||
|
@ -266,7 +265,7 @@ namespace OpenSim
|
|||
IAssetServer assetServer;
|
||||
if (m_assetStorage == "db4o")
|
||||
{
|
||||
assetServer = new LocalAssetServer();
|
||||
assetServer = new LocalAssetServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -334,10 +333,9 @@ namespace OpenSim
|
|||
m_log.Verbose("Killing clients");
|
||||
// IMPLEMENT THIS
|
||||
m_log.Verbose("Closing console and terminating");
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
|
||||
m_localScenes.Close();
|
||||
|
||||
m_log.Close();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
@ -376,6 +374,8 @@ namespace OpenSim
|
|||
/// <param name="cmdparams">Additional arguments passed to the command</param>
|
||||
public void RunCmd(string command, string[] cmdparams)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
if ((m_consoleRegion == null) || (command == "change-region") || (command == "shutdown"))
|
||||
{
|
||||
switch (command)
|
||||
|
@ -414,56 +414,51 @@ namespace OpenSim
|
|||
case "save-xml":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_localScenes[0].SavePrimsToXml(cmdparams[0]);
|
||||
m_localScenes.SavePrimsToXml(cmdparams[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_localScenes[0].SavePrimsToXml("test.xml");
|
||||
m_localScenes.SavePrimsToXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
break;
|
||||
|
||||
case "load-xml":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_localScenes[0].LoadPrimsFromXml(cmdparams[0]);
|
||||
m_localScenes.LoadPrimsFromXml(cmdparams[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_localScenes[0].LoadPrimsFromXml("test.xml");
|
||||
m_localScenes.LoadPrimsFromXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
break;
|
||||
|
||||
case "terrain":
|
||||
string result = "";
|
||||
foreach (Scene scene in m_localScenes)
|
||||
if (!m_localScenes.RunTerrainCmd(cmdparams, ref result))
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
m_log.Error(result);
|
||||
}
|
||||
m_log.Error(result);
|
||||
}
|
||||
break;
|
||||
case "terrain-sim":
|
||||
string result2 = "";
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionName.ToLower() == cmdparams[0].ToLower())
|
||||
{
|
||||
string[] tmpCmdparams = new string[cmdparams.Length - 1];
|
||||
cmdparams.CopyTo(tmpCmdparams, 1);
|
||||
|
||||
if (!scene.Terrain.RunTerrainCmd(tmpCmdparams, ref result2, scene.RegionInfo.RegionName))
|
||||
{
|
||||
m_log.Error(result2);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// terrain-sim now obsolete: do change-region first, then terrain as usual
|
||||
//case "terrain-sim":
|
||||
// foreach (Scene scene in m_localScenes)
|
||||
// {
|
||||
// if (scene.RegionInfo.RegionName.ToLower() == cmdparams[0].ToLower())
|
||||
// {
|
||||
// string[] tmpCmdparams = new string[cmdparams.Length - 1];
|
||||
// cmdparams.CopyTo(tmpCmdparams, 1);
|
||||
|
||||
// if (!scene.Terrain.RunTerrainCmd(tmpCmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
// {
|
||||
// m_log.Error(result);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
|
||||
case "script":
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
scene.SendCommandToScripts(cmdparams);
|
||||
}
|
||||
m_localScenes.SendCommandToScripts(cmdparams);
|
||||
break;
|
||||
|
||||
case "command-script":
|
||||
|
@ -475,27 +470,18 @@ namespace OpenSim
|
|||
|
||||
case "permissions":
|
||||
// Treats each user as a super-admin when disabled
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (Convert.ToBoolean(cmdparams[0]))
|
||||
scene.PermissionsMngr.EnablePermissions();
|
||||
else
|
||||
scene.PermissionsMngr.DisablePermissions();
|
||||
}
|
||||
bool permissions = Convert.ToBoolean(cmdparams[0]);
|
||||
|
||||
m_localScenes.BypassPermissions(!permissions);
|
||||
|
||||
break;
|
||||
|
||||
case "backup":
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
scene.Backup();
|
||||
}
|
||||
m_localScenes.Backup();
|
||||
break;
|
||||
|
||||
case "alert":
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
scene.HandleAlertCommand(cmdparams);
|
||||
}
|
||||
m_localScenes.HandleAlertCommand(cmdparams);
|
||||
break;
|
||||
|
||||
case "create":
|
||||
|
@ -513,43 +499,27 @@ namespace OpenSim
|
|||
case "change-region":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
if ((cmdparams[0].ToLower() == "root") || (cmdparams[0].ToLower() == ".."))
|
||||
string regionName = this.CombineParams(cmdparams, 0);
|
||||
|
||||
if( m_localScenes.TrySetCurrentRegion( regionName ) )
|
||||
{
|
||||
if (m_consoleRegion != null)
|
||||
{
|
||||
m_consoleRegion = null;
|
||||
MainLog.Instance.Verbose("Now at Root level");
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Verbose("Already at Root level");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
string name = this.CombineParams(cmdparams, 0);
|
||||
Console.WriteLine("Searching for Region: '" + name + "'");
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionName.ToLower() == name.ToLower())
|
||||
{
|
||||
m_consoleRegion = scene;
|
||||
MainLog.Instance.Verbose("Setting current region: " + m_consoleRegion.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
MainLog.Instance.Error("Couldn't set current region to: " + regionName);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_localScenes.CurrentScene == null)
|
||||
{
|
||||
MainLog.Instance.Verbose("Currently at Root level. To change region please use 'change-region <regioname>'");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_consoleRegion != null)
|
||||
{
|
||||
MainLog.Instance.Verbose("Current Region: " + m_consoleRegion.RegionInfo.RegionName + ". To change region please use 'change-region <regioname>'");
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Verbose("Currently at Root level. To change region please use 'change-region <regioname>'");
|
||||
}
|
||||
MainLog.Instance.Verbose("Current Region: " + m_consoleRegion.RegionInfo.RegionName + ". To change region please use 'change-region <regioname>'");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -564,30 +534,9 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
|
||||
private void DebugPacket(int newDebug)
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
Scene scene = m_localScenes[i];
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
m_log.Error(String.Format("Packet debug for {0} {1} set to {2}",
|
||||
scenePrescence.Firstname, scenePrescence.Lastname,
|
||||
newDebug));
|
||||
scenePrescence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Debug(string[] args)
|
||||
{
|
||||
switch(args[0])
|
||||
switch (args[0])
|
||||
{
|
||||
case "packet":
|
||||
if (args.Length > 1)
|
||||
|
@ -595,7 +544,7 @@ namespace OpenSim
|
|||
int newDebug;
|
||||
if (int.TryParse(args[1], out newDebug))
|
||||
{
|
||||
DebugPacket(newDebug);
|
||||
m_localScenes.DebugPacket(m_log, newDebug);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -627,29 +576,34 @@ namespace OpenSim
|
|||
break;
|
||||
case "users":
|
||||
m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
|
||||
List<ScenePresence> avatars = m_localScenes.GetAvatars();
|
||||
|
||||
foreach( ScenePresence avatar in avatars )
|
||||
{
|
||||
Scene scene = m_localScenes[i];
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
RegionInfo regionInfo = m_localScenes.GetRegionInfo( avatar.RegionHandle );
|
||||
string regionName;
|
||||
|
||||
if( regionInfo == null )
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
m_log.Error(
|
||||
String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
|
||||
scenePrescence.Firstname,
|
||||
scenePrescence.Lastname,
|
||||
scenePrescence.UUID,
|
||||
scenePrescence.ControllingClient.AgentId,
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
scene.RegionInfo.RegionName));
|
||||
}
|
||||
}
|
||||
regionName = "Unresolvable";
|
||||
}
|
||||
else
|
||||
{
|
||||
regionName = regionInfo.RegionName;
|
||||
}
|
||||
|
||||
m_log.Error(
|
||||
String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
|
||||
avatar.Firstname,
|
||||
avatar.Lastname,
|
||||
avatar.UUID,
|
||||
avatar.ControllingClient.AgentId,
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
regionName ));
|
||||
}
|
||||
|
||||
break;
|
||||
case "modules":
|
||||
m_log.Error("The currently loaded shared modules are:");
|
||||
|
|
|
@ -19,23 +19,19 @@ namespace OpenSim.Region.Environment
|
|||
// disable in any production environment
|
||||
// TODO: Change this to false when permissions are a desired default
|
||||
// TODO: Move to configuration option.
|
||||
private bool bypassPermissions = true;
|
||||
private bool m_bypassPermissions = true;
|
||||
public bool BypassPermissions
|
||||
{
|
||||
get { return m_bypassPermissions; }
|
||||
set { m_bypassPermissions = value; }
|
||||
}
|
||||
|
||||
|
||||
public PermissionManager(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
public void DisablePermissions()
|
||||
{
|
||||
bypassPermissions = true;
|
||||
}
|
||||
|
||||
public void EnablePermissions()
|
||||
{
|
||||
bypassPermissions = false;
|
||||
}
|
||||
|
||||
protected virtual void SendPermissionError(LLUUID user, string reason)
|
||||
{
|
||||
m_scene.EventManager.TriggerPermissionError(user, reason);
|
||||
|
@ -43,16 +39,20 @@ namespace OpenSim.Region.Environment
|
|||
|
||||
protected virtual bool IsAdministrator(LLUUID user)
|
||||
{
|
||||
if (bypassPermissions)
|
||||
return bypassPermissions;
|
||||
if (m_bypassPermissions)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return m_scene.RegionInfo.MasterAvatarAssignedUUID == user;
|
||||
}
|
||||
|
||||
protected virtual bool IsEstateManager(LLUUID user)
|
||||
{
|
||||
if (bypassPermissions)
|
||||
return bypassPermissions;
|
||||
if (m_bypassPermissions)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -74,14 +74,22 @@ namespace OpenSim.Region.Environment
|
|||
string reason = "Insufficient permission";
|
||||
|
||||
if (IsAdministrator(user))
|
||||
{
|
||||
permission = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = "Not an administrator";
|
||||
}
|
||||
|
||||
if (GenericParcelPermission(user, position))
|
||||
{
|
||||
permission = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = "Not the parcel owner";
|
||||
}
|
||||
|
||||
if (!permission)
|
||||
SendPermissionError(user, reason);
|
||||
|
|
|
@ -0,0 +1,210 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Types;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneManager
|
||||
{
|
||||
private readonly List<Scene> m_localScenes;
|
||||
private Scene m_currentScene = null;
|
||||
public Scene CurrentScene
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
|
||||
private Scene CurrentOrFirstScene
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml(filename);
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml(filename);
|
||||
}
|
||||
|
||||
public bool RunTerrainCmd(string[] cmdparams, ref string result)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
bool success = true;
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommandToScripts(string[] cmdparams)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
scene.SendCommandToScripts(cmdparams);
|
||||
});
|
||||
}
|
||||
|
||||
public void BypassPermissions(bool bypassPermissions)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
scene.PermissionsMngr.BypassPermissions = bypassPermissions;
|
||||
});
|
||||
}
|
||||
|
||||
private void ForEach(Action<Scene> func)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(m_currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public void Backup()
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
scene.Backup();
|
||||
});
|
||||
}
|
||||
|
||||
public void HandleAlertCommand(string[] cmdparams)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
scene.HandleAlertCommand(cmdparams);
|
||||
});
|
||||
}
|
||||
|
||||
public bool TrySetCurrentRegion(string regionName)
|
||||
{
|
||||
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
|
||||
{
|
||||
m_currentScene = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '" + regionName + "'");
|
||||
Scene foundScene = null;
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DebugPacket(LogBase log, int newDebug)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
log.Error(String.Format("Packet debug for {0} {1} set to {2}",
|
||||
scenePrescence.Firstname, scenePrescence.Lastname,
|
||||
newDebug));
|
||||
|
||||
scenePrescence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<ScenePresence> GetAvatars()
|
||||
{
|
||||
List<ScenePresence> avatars = new List<ScenePresence>();
|
||||
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
avatars.Add(scenePrescence);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(ulong regionHandle)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if( scene.RegionInfo.RegionHandle == regionHandle )
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -823,7 +823,6 @@
|
|||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Framework.Servers"/>
|
||||
<Reference name="OpenSim.Framework.Data"/>
|
||||
<Reference name="OpenSim.Grid.Framework.Manager"/>
|
||||
<Reference name="libsecondlife.dll"/>
|
||||
<Reference name="Db4objects.Db4o.dll"/>
|
||||
<Reference name="XMLRPC.dll"/>
|
||||
|
|
Loading…
Reference in New Issue