Reputation: 269
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 with exec("java Main")
, but I tried it with exec()
and it don't work. maybe because the http is not root? But I don't know exactly why.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?
Upvotes: 2
Views: 506
Reputation: 1920
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.
Upvotes: 2