[racket] Handin Server + PLAI problem

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Jan 14 20:21:04 EST 2012

When I set up the modules below, I get these two stacktraces for what
seem to be thinks the sandbox would reject:

[robby at yanpu] ~$ racket ~/tmp.rkt
security guard: current-directory #<path:/Users/robby/> (exists)
  (#f . #(struct:srcloc #<path:/Users/robby/tmp.rkt> 9 17 283 475))
  (find-main-collects . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/private/main-collects.rkt>
19 4 817 884))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 103
10 5179 84))
  (call-with-exception-handler . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/more-scheme.rkt>
268 2 9480 256))
  (force/generic . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 95 0
4902 376))
  (exploded-root . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-relativize.rkt> 31 4
1238 58))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 103
10 5179 84))
  (call-with-exception-handler . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/more-scheme.rkt>
268 2 9480 256))
  (force/generic . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 95 0
4902 376))
  (path->relative . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-relativize.rkt> 34 2
1371 907))
  (path->relative-string9 . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-to-relative.rkt> 31 2
1132 805))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/syntax/location.rkt> 13 0 339
828))
  (standard-module-name-resolver . #f)
  (standard-module-name-resolver . #f)
  (|[running body]| . #(struct:srcloc #<path:/Users/robby/tmp.rkt> #f #f #f #f))
---
security guard: current-directory #<path:/Users/robby/> (exists)
  (#f . #(struct:srcloc #<path:/Users/robby/tmp.rkt> 9 17 283 475))
  (find-main-collects . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/private/main-collects.rkt>
19 4 817 884))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 103
10 5179 84))
  (call-with-exception-handler . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/more-scheme.rkt>
268 2 9480 256))
  (force/generic . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 95 0
4902 376))
  (exploded-root . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-relativize.rkt> 31 4
1238 58))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 103
10 5179 84))
  (call-with-exception-handler . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/more-scheme.rkt>
268 2 9480 256))
  (force/generic . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/private/promise.rkt> 95 0
4902 376))
  (path->relative . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-relativize.rkt> 34 2
1371 907))
  (path->relative-string9 . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/setup/path-to-relative.rkt> 31 2
1132 805))
  (#f . #(struct:srcloc
#<path:/Users/robby/git/plt/collects/racket/contract/private/provide.rkt>
55 5 2253 2691))
  (standard-module-name-resolver . #f)
  (|[running body]| . #(struct:srcloc #<path:/Users/robby/tmp.rkt> #f #f #f #f))
---


;; tmp.rkt
#lang racket/base
(define ns (make-base-namespace))

(define fn (build-path (current-directory) "tmp3.rkt"))
(parameterize ([current-namespace ns]
               [current-security-guard
                (make-security-guard
                 (current-security-guard)
                 (λ (name path what)
                   (when (and (memq 'exists what)
                              (eq? name 'current-directory)
                              (path? path))
                     (printf "security guard: ~s ~s ~s\n" name path what)
                     (for ([x (in-list (continuation-mark-set->context
                                        (current-continuation-marks)))])
                       (printf "  ~s\n" x))
                     (printf "---\n")))
                 void
                 void)])
  (dynamic-require fn #f))


;; tmp3.rkt
#lang racket
(require (file "tmp2.rkt"))
(print-only-errors #t)


;; tmp2.rkt
#lang scheme
(define print-only-errors? #t)
(provide/contract (print-only-errors (() (boolean?) . ->* . void?)))
(define (print-only-errors [print? true])
  (set! print-only-errors? print?))


On Sat, Jan 14, 2012 at 6:47 PM, Eli Barzilay <eli at barzilay.org> wrote:
> 10 minutes ago, Robby Findler wrote:
>> This is the correct example.
>>
>> #lang racket/base
>> (define ns (make-base-namespace))
>
> I was about to say that I don't see any output with this, but I
> missed the above -- so if you use the module's namespace via an anchor
> there is no printout.  This means that the output that your code shows
> is probably due to the resolver.
>
> But regardless, when I run it (properly) I see:
>
>  security guard: current-directory #f (exists)
>
> so the sandbox wouldn't block it.  You can also see it by the fact
> that the error message it spits (from John's email):
>
>  current-directory: `exists' access denied for /home/clements/class/handin/
>
> has the path in it.
>
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!



Posted on the users mailing list.