Exemplo n.º 1
0
        public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID)
        {
            m_log.Info("[MRM] Created MRM Instance");

            IWorld m_world = new World(m_scene);
            IHost  m_host  = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions),
                                      m_microthreads);

            mmb.InitMiniModule(m_world, m_host, itemID);
        }
Exemplo n.º 2
0
        void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
        {
            if (script.StartsWith("//MRM:C#"))
            {
                if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID
                    ||
                    m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID)
                {
                    return;
                }

                script = ConvertMRMKeywords(script);

                try
                {
                    m_log.Info("[MRM] Found C# MRM");

                    MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
                        CompileFromDotNetText(script, itemID.ToString()),
                        "OpenSim.MiniModule");

                    InitializeMRM(mmb, localID, itemID);

                    m_scripts[itemID] = mmb;

                    m_log.Info("[MRM] Starting MRM");
                    mmb.Start();
                }
                catch (UnauthorizedAccessException e)
                {
                    m_log.Error("[MRM] UAE " + e.Message);
                    m_log.Error("[MRM] " + e.StackTrace);

                    if (e.InnerException != null)
                    {
                        m_log.Error("[MRM] " + e.InnerException);
                    }

                    m_scene.Broadcast(delegate(IClientAPI user)
                    {
                        user.SendAlertMessage(
                            "MRM UnAuthorizedAccess: " + e);
                    });
                }
                catch (Exception e)
                {
                    m_log.Info("[MRM] Error: " + e);
                    m_scene.Broadcast(delegate(IClientAPI user)
                    {
                        user.SendAlertMessage(
                            "Compile error while building MRM script, check OpenSim console for more information.");
                    });
                }
            }
        }
Exemplo n.º 3
0
        public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID)
        {
            m_log.Info("[MRM] Created MRM Instance");

            IWorld world;
            IHost  host;

            GetGlobalEnvironment(localID, out world, out host);

            mmb.InitMiniModule(world, host, itemID);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Start the script in the same application domain as opensim.
 /// </summary>
 /// <returns>True if the script was started successfully.</returns>
 private bool StartLocal()
 {
     try {
         m_mrm = (MRMBase)Activator.CreateInstanceFrom(m_assembly, m_class).Unwrap();
         m_mrm.InitMiniModule(m_world, m_host, ID);
         m_mrm.Start(m_args);
         return true;
     } catch (Exception e) {
         m_world.Shutdown();
         ErrorString = "Unable to start MRM." + e.Message + "\n" + e.StackTrace;
         while (e.InnerException != null) {
             e = e.InnerException;
             ErrorString += "\n\nInner Exception: " + e.Message + "\n" + e.StackTrace;
         }
         return false;
     }
 }
Exemplo n.º 5
0
#pragma warning restore 0618


        void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
        {
            if (script.StartsWith("//MRM:C#"))
            {
                if (m_config.GetBoolean("OwnerOnly", true))
                {
                    if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.EstateSettings.EstateOwner ||
                        m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.EstateSettings.EstateOwner)
                    {
                        return;
                    }
                }

                script = ConvertMRMKeywords(script);

                try
                {
                    AppDomain target;
                    if (m_config.GetBoolean("Sandboxed", true))
                    {
                        m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " +
                                   m_config.GetString("SandboxLevel", "Internet") + "-level security.");

                        string domainName = UUID.Random().ToString();
                        target = CreateRestrictedDomain(m_config.GetString("SandboxLevel", "Internet"),
                                                        domainName);
                    }
                    else
                    {
                        m_log.Info("[MRM] Found C# MRM - Starting in current AppDomain");
                        m_log.Warn(
                            "[MRM] Security Risk: AppDomain is run in current context. Use only in trusted environments.");
                        target = AppDomain.CurrentDomain;
                    }

                    m_log.Info("[MRM] Unwrapping into target AppDomain");
                    MRMBase mmb = (MRMBase)target.CreateInstanceFromAndUnwrap(
                        CompileFromDotNetText(script, itemID.ToString()),
                        "OpenSim.MiniModule");

                    m_log.Info("[MRM] Initialising MRM Globals");
                    InitializeMRM(mmb, localID, itemID);

                    m_scripts[itemID] = mmb;

                    m_log.Info("[MRM] Starting MRM");
                    mmb.Start();
                }
                catch (UnauthorizedAccessException e)
                {
                    m_log.Error("[MRM] UAE " + e.Message);
                    m_log.Error("[MRM] " + e.StackTrace);

                    if (e.InnerException != null)
                    {
                        m_log.Error("[MRM] " + e.InnerException);
                    }

                    m_scene.ForEachClient(delegate(IClientAPI user)
                    {
                        user.SendAlertMessage(
                            "MRM UnAuthorizedAccess: " + e);
                    });
                }
                catch (Exception e)
                {
                    m_log.Info("[MRM] Error: " + e);
                    m_scene.ForEachClient(delegate(IClientAPI user)
                    {
                        user.SendAlertMessage(
                            "Compile error while building MRM script, check OpenSim console for more information.");
                    });
                }
            }
        }
Exemplo n.º 6
0
        public string Start(string assembly, string clazz, IHost host, IWorld world, UUID id, string name, Unloader unloader, string[] args)
        {
            m_scheduler = new MicroScheduler();
            _unloader = unloader;
            AppDomain.CurrentDomain.UnhandledException += (sender, exceptionArgs) => Kill(exceptionArgs.ExceptionObject as Exception);

            try {
                m_id = id;
                m_name = name;
                m_mrm = (MRMBase)Activator.CreateInstanceFrom(assembly, clazz).Unwrap();
                m_world = new SandboxedWorld(world);
                m_host = new SandboxedHost(host, m_world.Objects, m_scheduler);
                m_mrm.InitMiniModule(m_world, m_host, id);
                m_mrm.Start(args);
            } catch (Exception e) {
                return FullError(e);
            }
            return null;
        }
Exemplo n.º 7
0
 public string Stop()
 {
     try {
         /*
         m_cont = false;
         m_stopped = true;
         lock (m_eventQ)
             Monitor.Pulse(m_eventQ);
          */
         m_mrm.Stop();
         if (m_world != null) {
             m_world.Shutdown();
             m_world.Kill(TimeSpan.FromMinutes(1));
         }
         m_mrm.Kill(TimeSpan.FromMinutes(1));
         m_mrm = null;
         return null;
     } catch (Exception e) {
         m_log.Warn("[XMRM]: Problem shutting down " + m_name + ".", e);
         return e.Message;
     }
 }