From 8905cc86e543bd2e1d5d39636892739552c01f70 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 30 Nov 2008 21:44:47 +0000 Subject: [PATCH] Added `sandbox-exit-handler' to control the exit handler svn: r12654 --- collects/scheme/sandbox.ss | 10 ++++++++-- collects/scribblings/reference/sandbox.scrbl | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/collects/scheme/sandbox.ss b/collects/scheme/sandbox.ss index 048a8d0234..c1199582be 100644 --- a/collects/scheme/sandbox.ss +++ b/collects/scheme/sandbox.ss @@ -15,8 +15,9 @@ sandbox-coverage-enabled sandbox-namespace-specs sandbox-override-collection-paths - sandbox-security-guard sandbox-path-permissions + sandbox-security-guard + sandbox-exit-handler sandbox-network-guard sandbox-make-inspector sandbox-make-logger @@ -138,6 +139,11 @@ (define sandbox-security-guard (make-parameter default-sandbox-guard)) +(define (default-sandbox-exit-handler _) + (error 'exit "sandboxed code cannot exit")) + +(define sandbox-exit-handler (make-parameter default-sandbox-exit-handler)) + (define sandbox-make-inspector (make-parameter make-inspector)) (define sandbox-make-logger (make-parameter current-logger)) @@ -594,7 +600,7 @@ [current-command-line-arguments '#()] ;; restrict the sandbox context from this point [current-security-guard (sandbox-security-guard)] - [exit-handler (lambda x (error 'exit "user code cannot exit"))] + [exit-handler (sandbox-exit-handler)] [current-inspector ((sandbox-make-inspector))] [current-logger ((sandbox-make-logger))] ;; This breaks because we need to load some libraries that are trusted diff --git a/collects/scribblings/reference/sandbox.scrbl b/collects/scribblings/reference/sandbox.scrbl index d208e6c895..3db9ae43ee 100644 --- a/collects/scribblings/reference/sandbox.scrbl +++ b/collects/scribblings/reference/sandbox.scrbl @@ -448,6 +448,12 @@ collection libraries (including @scheme[make-evalautor] for more information.} +@defparam[sandbox-exit-handler handler (any/c . -> . any)]{ + +A parameter that determines the initial @scheme[(exit-handler)] for +sandboxed evaluations. The default handler simply throws an error.} + + @defparam[sandbox-network-guard proc (symbol? (or/c (and/c string? immutable?) #f)