Free cookie consent management tool by TermsFeed Policy Generator

Changeset 997


Ignore:
Timestamp:
12/16/08 22:20:13 (16 years ago)
Author:
kgrading
Message:

improved sandbox (#410)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r993 r997  
    4545
    4646namespace HeuristicLab.Hive.Client.Core {
    47   public class Core {
    48 
     47  public class Core: MarshalByRefObject {
    4948    public delegate string GetASnapshotDelegate();
    5049
    5150    Dictionary<long, Executor> engines = new Dictionary<long, Executor>();
    5251    Dictionary<long, AppDomain> appDomains = new Dictionary<long, AppDomain>();
    53 
    54     private ClientCommunicatorClient ccc;
     52   
    5553    private WcfService wcfService;
    5654
     
    146144    void wcfService_PullJobCompleted(object sender, PullJobCompletedEventArgs e) {
    147145      if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {
    148         bool sandboxed = false;
     146        bool sandboxed = true;
    149147
    150148        PluginManager.Manager.Initialize();
    151         AppDomain appDomain =  PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.JobId.ToString(), sandboxed, typeof(TestJob));     
     149        AppDomain appDomain =  PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.JobId.ToString(), sandboxed, typeof(TestJob));
     150        appDomain.UnhandledException += new UnhandledExceptionEventHandler(appDomain_UnhandledException);
     151
    152152        appDomains.Add(e.Result.JobId, appDomain);
    153153
     
    190190      return engines;
    191191    }
     192
     193    void appDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
     194      Logging.GetInstance().Error(this.ToString(), " Exception: " + e.ExceptionObject.ToString());
     195    }
    192196  }
    193197}
  • trunk/sources/HeuristicLab.Hive.Contracts/Properties/AssemblyInfo.frame

    r744 r997  
    2424using System.Runtime.InteropServices;
    2525using HeuristicLab.PluginInfrastructure;
     26using System.Security;
    2627
    2728// General Information about an assembly is controlled through the following
     
    3637[assembly: AssemblyTrademark("")]
    3738[assembly: AssemblyCulture("")]
     39[assembly: AllowPartiallyTrustedCallers]
    3840
    3941// Setting ComVisible to false makes the types in this assembly not visible
  • trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs

    r938 r997  
    161161
    162162    public AppDomain CreateAndInitAppDomainWithSandbox(string friendlyName, bool sandboxed, Type jobType) {
    163 
    164163      PermissionSet pset;
     164
     165      DiscoveryService dService = new DiscoveryService();
     166      //get the declaring plugin of the job
     167      PluginInfo jobPlugin = dService.GetDeclaringPlugin(jobType);
     168
     169      //get all the plugins that have dependencies with the jobplugin
     170      List<PluginInfo> depPlugins = GetDependentPlugins(jobPlugin);
     171      //insert all jobs into one list
     172      depPlugins.Add(jobPlugin);
     173     
    165174      if (sandboxed) {
    166175        pset = new PermissionSet(PermissionState.None);
    167         pset.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));       
     176        pset.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
     177        pset.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
     178        /*foreach (PluginInfo plugin in depPlugins) {
     179            foreach(String assemblies in plugin.Assemblies)
     180              pset.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, assemblies));
     181        }*/
     182        pset.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
    168183      } else {
    169184        pset = new PermissionSet(PermissionState.Unrestricted);
     
    176191      Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap(typeof(Runner).Assembly.GetName().Name, typeof(Runner).FullName);
    177192      NotifyListeners(PluginManagerAction.Initializing, "All plugins");
    178 
    179       DiscoveryService dService = new DiscoveryService();
    180       PluginInfo jobPlugin = dService.GetDeclaringPlugin(jobType);
    181 
    182       List<PluginInfo> depPlugins = GetDependentPlugins(jobPlugin);
    183       depPlugins.Add(jobPlugin);
    184193
    185194      if (depPlugins != null && depPlugins.Count > 0) {
  • trunk/sources/HeuristicLab.PluginInfrastructure/Runner.cs

    r886 r997  
    2828
    2929namespace HeuristicLab.PluginInfrastructure {
    30   internal class Runner : MarshalByRefObject {
     30  public class Runner : MarshalByRefObject {
    3131
    3232    public void LoadPlugins(ICollection<PluginInfo> plugins) {
Note: See TracChangeset for help on using the changeset viewer.