Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a script that can only write to STDOUT and read from STDIN?

I want my users to write code and run it inside a controlled environment, like for example Lua or Perl. My site runs on Perl CGI's. Is there a way to run an isolated perl/Lua/python/etc script without access to the filesystem and returns data via stdout to be saved in a database? What i need is a secure environment, how do i apply the restrictions? Thanks in advance. FYI: I want to achieve something like ideone.com or codepad.org

I've been reading about sandboxes in Lua or inline code, but they don't allow me to limit resources and time, just operations. I think i'll have a virtual machine and run the code in there, any tips?

like image 718
AlfredoVR Avatar asked Dec 29 '25 11:12

AlfredoVR


2 Answers

One idea that comes to my mind is to create a chroot'ed env for each of your user and run the user's script in that chroot'ed env.

like image 119
kbsbng Avatar answered Jan 01 '26 00:01

kbsbng


If you plan to use Lua, take a look at this page on the Lua-users wiki:

Sandboxes

like image 44
jpjacobs Avatar answered Jan 01 '26 01:01

jpjacobs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!