hit-moodle / moodle-local_onlinejudge

Online Judge plugin for Moodle 2.7-4.2.
http://cms.hit.edu.cn
GNU General Public License v3.0
120 stars 59 forks source link

To run java codes in sandbox #60

Closed Nageshmal closed 2 days ago

Nageshmal commented 12 years ago

I actually thought of running java codes locally in sandbox instead of running it in ideone.com . Please suggest me how to do this .

sunner commented 12 years ago

Implement a java wrapper as judge engine. The wrapper should protect system from malicious java programs.

Nageshmal commented 12 years ago

Please can u explain how to implement java wrapper as judge engine .

sunner commented 12 years ago

You can read the code in judge/

kanikeabhishek commented 12 years ago

So, In /var/www/moodle/local/onlinejudge/judge/sandbox/lib.php (gedit application)

class judge_sandbox extends judge_base { protected static $supported_languages = array( 'c' => 'gcc -m32 -D_MOODLE_ONLINEJUDGE -Wall -static -o %DEST% %SOURCES% -lm', 'c_warn2err' => 'gcc -m32 -D_MOODLE_ONLINEJUDGE -Wall -Werror -static -o %DEST% %SOURCES% -lm', 'cpp' => 'g++ -m32 -D_MOODLE_ONLINEJUDGE -Wall -static -o %DEST% %SOURCES% -lm', 'cpp_warn2err' => 'g++ -m32 -D_MOODLE_ONLINEJUDGE -Wall -Werror -static -o %DEST% %SOURCES% -lm', 'java' => 'javac -m32 -D_MOODLE_ONLINEJUDGE -Wall -static -o %DEST% %SOURCES% -lm'
);

If u see above array i have included java compiler option... Is this enough to run java programs in sandbox??? When i did that i got a compilation Error as: Details: javac: invalid flag: -m32 Usage: javac use -help for a list of possible options