开发者

Can my CGI call R?

开发者 https://www.devze.com 2023-04-12 00:02 出处:网络
I know barely more than zero about R: until yesterday I didn\'t know how to spell it. But I\'m suicidal: for my web site, I\'m thinking about letting a visitor type in an R \"program\" ( is it even ca

I know barely more than zero about R: until yesterday I didn't know how to spell it. But I'm suicidal: for my web site, I'm thinking about letting a visitor type in an R "program" ( is it even called a "program") and then, at submit time, blindly calling the R interpreter from my CGI. I'd then return the interpreter's output to the visitor.

Does this make sense? Or does it amount to useless noise?

If it's workable, what are the pitfalls in this approach? For example, what are the security 开发者_开发技巧issues, if any? Is it possible to make R crash, killing my CGI program? Do I have to clean up the R code before calling the interpreter? And the like.


you could take a look to Rserve which allows to execute R scripts via the TCP/IP interface available in PHP for example if I'm not mistaken.


Its just asking for trouble to let people run arbitrary R code on your server. You could try running it in a chroot jail, but these things can be broken out of. Even in a chroot, the R process could delete or alter files, or spawn a long-running process, or download a file to your server, and all manner of nastiness.


You might look at Rweb, which has exactly this behavior: http://www.math.montana.edu/Rweb/


Since you can read and write files in R, it would not be safe to let people run arbitrary R code at your server. I would look if R has something like PHP's safe mode... If not, and if you are root, you can try to run R under user nobody in a chroot (you must also place there packages and libraries - for readonly access, and some temporary directory for RW access).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号