[plt-scheme] Running student tests on student code
I was running into a similar, perhaps the same, problem. Below are two
forwarded messages from Eli that might be useful. The second was not
posted to the mailing list, but it may help you tell the sandbox
evaluator to permit writing to a temp file in whatever directory is
causing you problems.
--- nadeem
Begin forwarded message:
> From: Eli Barzilay <eli at barzilay.org>
> Date: December 6, 2009 4:05:13 PM EST
> To: Nadeem Abdul Hamid <nadeem at acm.org>
> Cc: plt edu <plt-edu at list.cs.brown.edu>
> Subject: Re: [plt-edu] Gaining access to a student's source code
> from a test harness.
>
> On Dec 6, Nadeem Abdul Hamid wrote:
>> Why I try this:
>>
>> On Dec 6, 2009, at 3:30 PM, Eli Barzilay wrote:
>>> Now you can do this:
>>>> (require scheme/sandbox)
>>>> (define e (make-module-evaluator (string->path "some-file.ss")))
>>
>> I get an error:
>>
>> open-output-file: `write' access denied for /var/folders/so/
>> sodQxXkWEL8lYu1Sd7M+N++++TI/-Tmp-/mztmp1260131680-441220566
>
> Looks like the sandboxed code is using planet, which is trying to
> install a library. Code that runs in a sandbox is heavily
> restricted[*], and that's what leads to that error. Recent versions
> (4.2.3, and I think that 4.2.2 also) would allow reading planet
> libraries, but still not allow writing -- you should make sure that
> these libraries are installed before running a sandbox.
>
> Alternatively, if you trust the students to not try to hack your
> machine, you can start the sandbox in "trusted" mode:
>
> (define e
> (call-with-trusted-sandbox-configuration
> (lambda () (make-module-evaluator ...same...))))
>
> This removes all of the restrictions -- inlcluding timeouts and memory
> limits.
>
>
> [*] It is not allowed to write anywhere, and it is only allowed to
> read from specific places like the PLT tree. This way you're
> protected against malicious student code that will try, for example,
> to send an email with your /etc/passwords file.
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli
> Barzilay:
> http://barzilay.org/ Maze is
> Life!
Begin forwarded message:
> From: Eli Barzilay <eli at barzilay.org>
> Date: December 6, 2009 10:06:23 PM EST
> To: Nadeem Abdul Hamid <nadeem at acm.org>
> Subject: Re: [plt-edu] Gaining access to a student's source code
> from a test harness.
>
> On Dec 6, Nadeem Abdul Hamid wrote:
>> I've attached some files to this email that cause the error: the
>> student file is "hw09-kiva.ss". It uses the "kiva-teachpack.ss" that
>> I wrote. The "some-file-tester.ss" contains the sandbox
>> evaluator. I'm running this on Windows now, DrScheme version
>> 4.2.2.4-svn23oct2009, and I get the error:
>>
>> open-output-file: `write' access denied for
>> C:\DOCUME~1\Nadeem\LOCALS~1\Temp\mztmp1260145242-427658720
>>
>> Would it be the teachpack or something in it that causes the
>> problem? I don't seem to recall anything in it that is trying to
>> use planet?
>
> No, it's not planet... I've tracked this down to some paths that the
> mred reader needs to access, and in addition include-bitmap (which is
> used to have images inlined in the source) requires writing a
> temporary file (which is the error you've seen). I was finally able
> to make it work by permitting these paths manually:
>
> (define e (parameterize ([sandbox-path-permissions
> '([read "/tmp/zzz"]
> [read "/home/scheme/plt"]
> [read "/home/eli/.plt-scheme/plt-
> prefs.ss"]
> [write "/var/tmp"])])
> (make-module-evaluator (string->path "hw09-kiva.ss"))))
>
> where "/tmp/zzz" is where I put all your files, "/home/scheme/plt" is
> where the plt installation lives (which is needed because of that
> problem), the prefs file is readable because something was accessing
> it too, and "/var/tmp" is where it was saving the temp files on my
> machine (needed for including bitmaps).
>
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli
> Barzilay:
> http://barzilay.org/ Maze is
> Life!
On Dec 15, 2009, at 10:43 PM, Jordan Johnson wrote:
> Hi all,
>
> Newbie question: I have multiple suites of tests (check-expects
> culled from multiple files) that I want to run against multiple
> student homework handins.
>
> This is essentially the code I'm working from in the tests file:
>
> ;;;;;
> #lang scheme
>
> (require htdp/testing scheme/sandbox)
>
> (define e (make-module-evaluator <path-to-test-subject-file>))
>
> (e '(begin
> ...first sequence of check-expects...
> (test)))
>
> (e '(begin
> ...second sequence of check-expects...
> (test)))
>
> ;; etc.
>
> However, I'm getting errors that tell me DrScheme is trying to
> create a temp file in the directory of the subject file, and failing
> because of sandbox restrictions.
>
> Questions:
> - Is the htdp/testing lib the one requiring the aforementioned temp
> file?
> - Am I going off in the wrong direction trying to run check-expects
> this way?
>
> and perhaps most importantly
> - is there a better way I'm unaware of?
>
> I'm sure this is merely a sign I'm missing something in the docs, so
> if anyone can point me in the right direction I'd be grateful.
>
> Best,
> Jordan
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091216/186812a5/attachment.html>