I have a little question: we have to run Java programs and parts of the code will be uploaded by the users. So I want to know what's the best way to run them? I know 2开发者_运维技巧 possible ways,
exec("javac Usercode.class")
and then run the whole thing withexec("java Main")
, but I tried it withexec()
and it don't work. maybe because the http is not root? But I don't know exactly why.- http://php-java-bridge.sourceforge.net/pjb/ ?
Any suggestions?
And another question is, how can I run these programs in a sandbox. we have a Debian server and so it's no problem to execute the command with a limited time, but is there a possible way to run the whole code in a sandbox?
Ideas for sandboxing:
Run in a chroot using e.g. Debian's schroot command. Protects against them accessing files outside of the chroot but not against them doing things like opening sockets etc.
Each user has their own Linux username against which they validate. Commands will then be run under the appropriate username (e.g. by using sudo or a set-uid executable).
Maintain a pool of virtual servers - expensive and complicated but gives best isolation.
精彩评论