Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim

This commit is contained in:
Diva Canto
2009-08-17 05:55:38 -07:00
46 changed files with 1738 additions and 372 deletions

View File

@@ -120,6 +120,7 @@ namespace OpenSim
configSource.AddSwitch("Startup", "gridmode");
configSource.AddSwitch("Startup", "physics");
configSource.AddSwitch("Startup", "gui");
configSource.AddSwitch("Startup", "console");
configSource.AddConfig("StandAlone");
configSource.AddConfig("Network");
@@ -223,4 +224,4 @@ namespace OpenSim
_IsHandlingException = false;
}
}
}
}

View File

@@ -52,6 +52,7 @@ namespace OpenSim
protected string m_startupCommandsFile;
protected string m_shutdownCommandsFile;
protected bool m_gui = false;
protected string m_consoleType = "local";
private string m_timedScript = "disabled";
private Timer m_scriptTimer;
@@ -71,7 +72,10 @@ namespace OpenSim
m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt");
m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt");
m_gui = startupConfig.GetBoolean("gui", false);
if (startupConfig.GetString("console", String.Empty) == String.Empty)
m_gui = startupConfig.GetBoolean("gui", false);
else
m_consoleType= startupConfig.GetString("console", String.Empty);
m_timedScript = startupConfig.GetString("timer_Script", "disabled");
if (m_logFileAppender != null)
@@ -110,13 +114,31 @@ namespace OpenSim
if (m_gui) // Driven by external GUI
m_console = new CommandConsole("Region");
else
m_console = new LocalConsole("Region");
{
switch (m_consoleType)
{
case "basic":
m_console = new CommandConsole("Region");
break;
case "rest":
m_console = new RemoteConsole("Region");
((RemoteConsole)m_console).ReadConfig(m_config.Source);
break;
default:
m_console = new LocalConsole("Region");
break;
}
}
MainConsole.Instance = m_console;
RegisterConsoleCommands();
base.StartupSpecific();
if (m_console is RemoteConsole)
((RemoteConsole)m_console).SetServer(m_httpServer);
//Run Startup Commands
if (String.IsNullOrEmpty(m_startupCommandsFile))
{

View File

@@ -1435,6 +1435,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="map">heightmap</param>
public virtual void SendLayerData(float[] map)
{
DoSendLayerData((object)map);
ThreadPool.QueueUserWorkItem(DoSendLayerData, map);
}
@@ -1450,16 +1451,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
for (int y = 0; y < 16; y++)
{
// For some terrains, sending more than one terrain patch at once results in a libsecondlife exception
// see http://opensimulator.org/mantis/view.php?id=1662
//for (int x = 0; x < 16; x += 4)
//{
// SendLayerPacket(map, y, x);
// Thread.Sleep(150);
//}
for (int x = 0; x < 16; x++)
for (int x = 0; x < 16; x += 4)
{
SendLayerData(x, y, LLHeightFieldMoronize(map));
SendLayerPacket(LLHeightFieldMoronize(map), y, x);
Thread.Sleep(35);
}
}
@@ -1476,17 +1470,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="map">heightmap</param>
/// <param name="px">X coordinate for patches 0..12</param>
/// <param name="py">Y coordinate for patches 0..15</param>
// private void SendLayerPacket(float[] map, int y, int x)
// {
// int[] patches = new int[4];
// patches[0] = x + 0 + y * 16;
// patches[1] = x + 1 + y * 16;
// patches[2] = x + 2 + y * 16;
// patches[3] = x + 3 + y * 16;
private void SendLayerPacket(float[] map, int y, int x)
{
int[] patches = new int[4];
patches[0] = x + 0 + y * 16;
patches[1] = x + 1 + y * 16;
patches[2] = x + 2 + y * 16;
patches[3] = x + 3 + y * 16;
// Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
// OutPacket(layerpack, ThrottleOutPacketType.Land);
// }
LayerDataPacket layerpack;
try
{
layerpack = TerrainCompressor.CreateLandPacket(map, patches);
layerpack.Header.Zerocoded = true;
layerpack.Header.Reliable = true;
if (layerpack.Length > 1000) // Oversize packet was created
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Send oversize packet in individual patches
//
SendLayerData(x+xa, y, map);
}
}
else
{
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
}
catch (OverflowException e)
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Send oversize packet in individual patches
//
SendLayerData(x+xa, y, map);
}
}
catch (IndexOutOfRangeException e)
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Bad terrain, send individual chunks
//
SendLayerData(x+xa, y, map);
}
}
}
/// <summary>
/// Sends a specified patch to a client
@@ -1507,6 +1538,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
layerpack.Header.Zerocoded = true;
layerpack.Header.Reliable = true;
OutPacket(layerpack, ThrottleOutPacketType.Land);
@@ -1556,7 +1588,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="windSpeeds">16x16 array of wind speeds</param>
public virtual void SendWindData(Vector2[] windSpeeds)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds);
DoSendWindData((object)windSpeeds);
// ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds);
}
/// <summary>

View File

@@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{

View File

@@ -147,7 +147,7 @@ namespace OpenSim.Region.Communications.OGS1
{
// The timeout should always be significantly larger than the timeout for the grid server to request
// the initial status of the region before confirming registration.
GridResp = GridReq.Send(serversInfo.GridURL, 90000);
GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
}
catch (Exception e)
{

View File

@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private int m_saydistance = 30;
private int m_shoutdistance = 100;
private int m_whisperdistance = 10;
private string m_adminprefix = String.Empty;
private List<Scene> m_scenes = new List<Scene>();
internal object m_syncy = new object();
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
m_adminprefix = config.Configs["Chat"].GetString("admin_prefix", m_adminprefix);
}
public virtual void AddRegion(Scene scene)
@@ -207,6 +209,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
fromPos = avatar.AbsolutePosition;
fromName = avatar.Name;
fromID = c.Sender.AgentId;
if (avatar.GodLevel > 100)
fromName = m_adminprefix + fromName;
break;
@@ -255,14 +259,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
string fromName = c.From;
UUID fromID = UUID.Zero;
UUID ownerID = UUID.Zero;
ChatSourceType sourceType = ChatSourceType.Object;
if (null != c.Sender)
{
ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId);
fromID = c.Sender.AgentId;
ownerID = c.Sender.AgentId;
fromName = avatar.Name;
sourceType = ChatSourceType.Agent;
}
if (c.SenderObject != null)
{
SceneObjectPart senderObject = (SceneObjectPart)c.SenderObject;
fromID = senderObject.UUID;
ownerID = senderObject.OwnerID;
fromName = senderObject.Name;
}
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);

View File

@@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land
public LandData GetLandData(ulong regionHandle, uint x, uint y)
{
m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {2}",
m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
regionHandle, m_Scenes.Count);
foreach (Scene s in m_Scenes)
{

View File

@@ -214,7 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
{
m_scene.Restart(timeInSeconds);
// m_scene.Restart(timeInSeconds);
remoteClient.SendBlueBoxMessage(UUID.Zero, "System", "Restart is not available");
}
private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)

View File

@@ -115,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param>
public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
{
PacketType i = PacketType.ObjectUpdate;
List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList)

View File

@@ -1,3 +1,30 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public interface IAvatarAttachment

View File

@@ -27,9 +27,14 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Text;
using log4net;
using Microsoft.CSharp;
@@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private readonly MicroScheduler m_microthreads = new MicroScheduler();
private IConfig m_config;
public void RegisterExtension<T>(T instance)
{
m_extensions[typeof (T)] = instance;
@@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
if (source.Configs["MRM"] != null)
{
m_config = source.Configs["MRM"];
if (source.Configs["MRM"].GetBoolean("Enabled", false))
{
m_log.Info("[MRM] Enabling MRM Module");
@@ -112,6 +122,91 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
return script;
}
/// <summary>
/// Create an AppDomain that contains policy restricting code to execute
/// with only the permissions granted by a named permission set
/// </summary>
/// <param name="permissionSetName">name of the permission set to restrict to</param>
/// <param name="appDomainName">'friendly' name of the appdomain to be created</param>
/// <exception cref="ArgumentNullException">
/// if <paramref name="permissionSetName"/> is null
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// if <paramref name="permissionSetName"/> is empty
/// </exception>
/// <returns>AppDomain with a restricted security policy</returns>
/// <remarks>Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx
/// Valid permissionSetName values are:
/// * FullTrust
/// * SkipVerification
/// * Execution
/// * Nothing
/// * LocalIntranet
/// * Internet
/// * Everything
/// </remarks>
public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName)
{
if (permissionSetName == null)
throw new ArgumentNullException("permissionSetName");
if (permissionSetName.Length == 0)
throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName,
"Cannot have an empty permission set name");
// Default to all code getting nothing
PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None));
UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy);
bool foundName = false;
PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted);
// iterate over each policy level
IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy();
while (levelEnumerator.MoveNext())
{
PolicyLevel level = levelEnumerator.Current as PolicyLevel;
// if this level has defined a named permission set with the
// given name, then intersect it with what we've retrieved
// from all the previous levels
if (level != null)
{
PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName);
if (levelSet != null)
{
foundName = true;
if (setIntersection != null)
setIntersection = setIntersection.Intersect(levelSet);
}
}
}
// Intersect() can return null for an empty set, so convert that
// to an empty set object. Also return an empty set if we didn't find
// the named permission set we were looking for
if (setIntersection == null || !foundName)
setIntersection = new PermissionSet(PermissionState.None);
else
setIntersection = new NamedPermissionSet(permissionSetName, setIntersection);
// if no named permission sets were found, return an empty set,
// otherwise return the set that was found
PolicyStatement permissions = new PolicyStatement(setIntersection);
policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions));
// create an AppDomain policy level for the policy tree
PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel();
appDomainLevel.RootCodeGroup = policyRoot;
// create an AppDomain where this policy will be in effect
string domainName = appDomainName;
AppDomain restrictedDomain = AppDomain.CreateDomain(domainName);
restrictedDomain.SetAppDomainPolicy(appDomainLevel);
return restrictedDomain;
}
void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{
if (script.StartsWith("//MRM:C#"))
@@ -125,9 +220,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
try
{
m_log.Info("[MRM] Found C# MRM");
m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security.");
MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
string domainName = UUID.Random().ToString();
AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"),
domainName);
MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap(
CompileFromDotNetText(script, itemID.ToString()),
"OpenSim.MiniModule");

View File

@@ -71,7 +71,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private bool CanEdit()
{
if(!m_security.CanEditObject(this))
if (!m_security.CanEditObject(this))
{
throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
}
@@ -672,7 +672,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return m_sculptType; }
set
{
if(!CanEdit())
if (!CanEdit())
return;
m_sculptType = value;

View File

@@ -156,10 +156,10 @@ namespace OpenSim.Region.Physics.OdePlugin
private const uint m_regionWidth = Constants.RegionSize;
private const uint m_regionHeight = Constants.RegionSize;
private bool IsLocked = false;
private float ODE_STEPSIZE = 0.020f;
private float metersInSpace = 29.9f;
private List<PhysicsActor> RemoveQueue;
public float gravityx = 0f;
public float gravityy = 0f;
public float gravityz = -9.8f;
@@ -376,6 +376,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Initialize the mesh plugin
public override void Initialise(IMesher meshmerizer, IConfigSource config)
{
RemoveQueue = new List<PhysicsActor>();
mesher = meshmerizer;
m_config = config;
// Defaults
@@ -2047,13 +2048,21 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (prim is OdePrim)
{
lock (OdeLock)
if (!IsLocked) //Fix a deadlock situation.. have we been locked by Simulate?
{
OdePrim p = (OdePrim) prim;
lock (OdeLock)
{
OdePrim p = (OdePrim)prim;
p.setPrimForRemoval();
AddPhysicsActorTaint(prim);
//RemovePrimThreadLocked(p);
p.setPrimForRemoval();
AddPhysicsActorTaint(prim);
//RemovePrimThreadLocked(p);
}
}
else
{
//Add the prim to a queue which will be removed when Simulate has finished what it's doing.
RemoveQueue.Add(prim);
}
}
}
@@ -2575,7 +2584,7 @@ namespace OpenSim.Region.Physics.OdePlugin
DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
}
IsLocked = true;
lock (OdeLock)
{
// Process 10 frames if the sim is running normal..
@@ -2988,6 +2997,19 @@ namespace OpenSim.Region.Physics.OdePlugin
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
}
}
IsLocked = false;
if (RemoveQueue.Count > 0)
{
do
{
if (RemoveQueue[0] != null)
{
RemovePrimThreadLocked((OdePrim)RemoveQueue[0]);
}
RemoveQueue.RemoveAt(0);
}
while (RemoveQueue.Count > 0);
}
return fps;
}

View File

@@ -35,6 +35,7 @@ using Nini.Config;
using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenMetaverse;
using System;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ScriptEngine.Shared.Tests
{
@@ -52,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void SetUp()
{
IniConfigSource initConfigSource = new IniConfigSource();
IConfigSource initConfigSource = new IniConfigSource();
IConfig config = initConfigSource.AddConfig("XEngine");
config.Set("Enabled", "true");

View File

@@ -70,6 +70,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
/// <summary>
/// When an object gets paid by an avatar and generates the paid event,
/// this will pipe it to the script engine
/// </summary>
/// <param name="objectID">Object ID that got paid</param>
/// <param name="agentID">Agent Id that did the paying</param>
/// <param name="amount">Amount paid</param>
private void HandleObjectPaid(UUID objectID, UUID agentID,
int amount)
{
@@ -93,6 +100,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
/// <summary>
/// Handles piping the proper stuff to The script engine for touching
/// Including DetectedParams
/// </summary>
/// <param name="localID"></param>
/// <param name="originalID"></param>
/// <param name="offsetPos"></param>
/// <param name="remoteClient"></param>
/// <param name="surfaceArgs"></param>
public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{