Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit ed30102

Browse files
committed
The C, C++, Java, Python language bindings has been changed to run in a chroot jail for additional security.
Closes #2
1 parent 418a419 commit ed30102

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

codejudge-compiler/src/codejudge/compiler/languages/C.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void execute() {
5252
// create the execution script
5353
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dir + "/run.sh")));
5454
out.write("cd \"" + dir +"\"\n");
55+
out.write("chroot .\n");
5556
out.write("./a.out < in.txt > out.txt");
5657
out.close();
5758
Runtime r = Runtime.getRuntime();

codejudge-compiler/src/codejudge/compiler/languages/Cpp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void execute() {
5252
// create the execution script
5353
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dir + "/run.sh")));
5454
out.write("cd \"" + dir +"\"\n");
55+
out.write("chroot .\n");
5556
out.write("./a.out < in.txt > out.txt");
5657
out.close();
5758
Runtime r = Runtime.getRuntime();

codejudge-compiler/src/codejudge/compiler/languages/Java.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void execute() {
5252
// create the execution script
5353
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dir + "/run.sh")));
5454
out.write("cd \"" + dir +"\"\n");
55+
out.write("chroot .\n");
5556
out.write("java " + file.substring(0, file.length() - 5) + " < in.txt > out.txt");
5657
out.close();
5758
Runtime r = Runtime.getRuntime();

codejudge-compiler/src/codejudge/compiler/languages/Python.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void compile() {
3232
// create the execution script
3333
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dir + "/run.sh")));
3434
out.write("cd \"" + dir +"\"\n");
35+
out.write("chroot .\n");
3536
out.write("python " + file + "< in.txt > out.txt 2>err.txt");
3637
out.close();
3738
Runtime r = Runtime.getRuntime();

0 commit comments

Comments
 (0)