eduproj/jails/ocamlStudentModule.nix

35 lines
680 B
Nix
Raw Normal View History

2021-08-28 11:37:52 +00:00
{ writeTextFile, nsjail }:
let
inner = writeTextFile {
name = "ocamlStudentModuleInner";
executable = true;
text = ''
#!/bin/sh
INTERFACE_FILE=$1
STUDENT_FILE=$2
DRIVER_FILE=$3
ocamlc -o student.cmi $INTERFACE_FILE
ocamlc -o student.cmo $STUDENT_FILE
ocaml student.cmo $DRIVER_FILE
'';
};
in
writeTextFile {
name = "ocamlStudentModule";
executable = true;
text = ''
JAIL=$(mktemp -d)
mkdir -p $JAIL/bin
cp ${inner} $JAIL/bin/ocamlStudentModule
${nsjail}/bin/nsjail \
-Mo \
--chroot $JAIL \
-R /bin/sh \
-R /bin/ls \
/bin/ls
# /bin/ocamlStudentModule
'';
}