eddelbuettel/rinside — pull request #8 by cauthmann (2014-11-20 13:42:05+00:00)
Title: Sandboxed server review

This is an attempt to "sandbox" RInside in a separate process. This should prevent buggy or malicious R code from interfering with your application - which is always useful, especially when the R code is user-submitted.
The exposed client API provides similar functionality to RInside, with slightly different syntax. Custom data types can be supported (assuming they implement serialization methods in addition to the Rcpp wrappers), and the R code can call back into provided C++ functions.

I don't think it's possible or wise to tightly integrate this code into RInside; hence it lives in a separate directory in the examples.

This code hasn't seen more than two eyes yet, so please review and comment!

What you will need to run this:
* RInside installed with RINSIDE_CALLBACKS (it's disabled by default, see inst/include/RInsideConfig.h)
* Rcpp 0.11.3 (or later)
* A C++11 compatible compiler
* A POSIX-like system that supports sockets, signals, fork and others. I have only tested this on linux. Feedback from other POSIX systems or even windows is appreciated.

```Shell
cd inst/examples/sandboxed_server/
make
# in one terminal, run
./example_server
# in a different terminal, run
./example_client
```

I've split the code into five separate commits for review; I suggest reading them commit by commit. If this gets accepted, I'll be happy to provide a different history for the actual pulling.

Currently, I've only implemented a separate standalone server that listen()s for clients. For my needs, this increases security (running the server as a different user) and improves performance (R is initialized only once, then fork()ed for each client).
I've chosen the abstraction in a way that should make it easy to switch to a solution where the application spawns a new process and communicates over a shared pipe - which is more suitable for a desktop application. I'm not currently interested in implementing that though.