[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [guile-user] Sandboxing?

From: Keisuke Nishida
Subject: Re: [guile-user] Sandboxing?
Date: Tue, 20 Mar 2001 17:13:36 -0500
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.99 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

At Mon, 19 Mar 2001 17:23:59 +0000 (/etc/localtime),
Kyle Cronan wrote:
> Ok, I decided to use this approach.  I have some C code that takes some
> scheme code from a cgi and calls gh_eval_str on something like this:
> (eval '(begin <formcode>) (safe-environment 5))
> My problem is the procedures I have defined with gh_new_procedure are
> unbound in this environment.  Ideally, it would be nice to have a way to
> evaluate everything passed to gh_eval_str within a safe environment.  Or
> is there some way I can get the C procedures available to the eval
> statement above?

Hmm, you could import your procedures into the safe environment:

  (define custom-environment (safe-environment 5))

  (module-define! custom-environment 'hello (lambda () "Hello"))

  (eval '(hello) custom-environment)  => "Hello"

Or you could define your custom module:

  ---- custom-environment.scm ----------
  (define-module (custom-environment)
    :use-module (ice-9 safe-r5rs))

  (define (hello) "Hello")


  (eval '(hello) (resolve-module '(custom-environment))) => "Hello"

I don't know how to do this using the GH interface, sorry.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]