diff --git a/collects/racket/sandbox.rkt b/collects/racket/sandbox.rkt index 4acaa21e6e..5fd4573053 100644 --- a/collects/racket/sandbox.rkt +++ b/collects/racket/sandbox.rkt @@ -29,6 +29,7 @@ sandbox-make-inspector sandbox-make-code-inspector sandbox-make-logger + sandbox-make-environment-variables sandbox-memory-limit sandbox-eval-limits sandbox-eval-handlers @@ -89,6 +90,7 @@ [sandbox-make-inspector current-inspector] [sandbox-make-code-inspector current-code-inspector] [sandbox-make-logger current-logger] + [sandbox-make-environment-variables current-environment-variables] [sandbox-memory-limit #f] [sandbox-eval-limits #f] [sandbox-eval-handlers '(#f #f)]) @@ -230,6 +232,11 @@ (define sandbox-make-logger (make-parameter current-logger)) +(define sandbox-make-environment-variables (make-parameter + (lambda () + (environment-variables-copy + (current-environment-variables))))) + (define (compute-permissions for-require for-load) ;; `for-require' is a list of module paths and paths that will be `reqiure'd, ;; while `for-load' is a list of path (strings) that will be `load'ed. @@ -909,6 +916,7 @@ [current-custodian user-cust] [current-thread-group (make-thread-group)] ;; paths + [current-environment-variables ((sandbox-make-environment-variables))] [current-library-collection-paths (filter directory-exists? (append (sandbox-override-collection-paths) diff --git a/collects/scribblings/reference/sandbox.scrbl b/collects/scribblings/reference/sandbox.scrbl index ab3c979cce..146ca2225e 100644 --- a/collects/scribblings/reference/sandbox.scrbl +++ b/collects/scribblings/reference/sandbox.scrbl @@ -321,8 +321,9 @@ function. Invokes the @racket[thunk] in a context where sandbox configuration parameters are set for minimal restrictions. More specifically, there -are no memory or time limits, and the existing existing inspectors, -security guard, exit handler, and logger are used. (Note that the I/O +are no memory or time limits, and the existing existing @tech{inspectors}, +@tech{security guard}, @tech{exit handler}, @tech{logger}, and +@tech{environment variable set} are used. (Note that the I/O ports settings are not included.)} @@ -759,6 +760,16 @@ an evaluator, and the default parameter value is @racket[current-logger]. This means that it is not creating a new logger (this might change in the future).} + +@defparam[sandbox-make-environment-variables make (-> environment-variables?)]{ + +A @tech{parameter} that determines the procedure used to create the +@tech{environment variable set} for sandboxed evaluation. The +procedure is called when initializing an evaluator, and the default +parameter value constructs a new @tech{environment variable set} using +@racket[(environment-variables-copy +(current-environment-variables))].} + @; ---------------------------------------------------------------------- @section{Interacting with Evaluators} diff --git a/collects/tests/racket/sandbox.rktl b/collects/tests/racket/sandbox.rktl index 1df5cb4c57..fffa6aa060 100644 --- a/collects/tests/racket/sandbox.rktl +++ b/collects/tests/racket/sandbox.rktl @@ -590,6 +590,12 @@ --eval-- (syntax-original? #'x) => #t + --eval-- + (putenv "APPLE" "AnApple") => #t + (getenv "APPLE") => "AnApple" + --top-- + (getenv "APPLE") => #f + )) (parameterize ([current-module-declare-name (make-resolved-module-path 'junk)]) diff --git a/doc/release-notes/racket/HISTORY.txt b/doc/release-notes/racket/HISTORY.txt index 9f8c74a2e5..4882e4b9d6 100644 --- a/doc/release-notes/racket/HISTORY.txt +++ b/doc/release-notes/racket/HISTORY.txt @@ -3,6 +3,7 @@ Added current-environment-variables, environment-variables-get, environment-variables-set!, environment-variables-keys, environment-variables-copy, bytes-environment-variables-name?, string-environment-variables-name?, and environment-variables? +racket/sadnox: added sandbox-make-environment-variables Version 5.3.4.1 Changed JIT to support ARM