Which user is running the R on OpenCPU server side?

243 Views Asked by At

I'm inexperienced in using opencpu as a server and so I tried to find a answer to this in the documentation but did not found any answers to this question. Never the less this seems quite basic to me in terms of permission and authentication, so I guess this is documented somewhere and I just did not found it.... The question I have is regarding users and permissions when running a request to the OpenCPU server. I've written a R package which I want to host using the OpenCPU server. So far I managed to install OpenCPU server without any problems and it works fine for most functions in my R pakage. However one function uses Sys.getenv('USERNAME') to determine the user which runs the code. But when the R code is triggered by a client request I have no clue how to figure out the user.

Min Example: Suppose I have a function "myFun" included in my R package named "MyRPkg" like:

MyRPkg/R/myFun.R:

myFun(v){
  return(Sys.getenv('USERNAME'))
}

When I've installed the package (in the "root" R library) and have my OpenCPU server running than I can access the package and call this function by a POST request like:

SERVERNAME/ocpu/library/MyRPkg/R/myFun/json

and get an empty string as an answer.

[""]

How do I figure out what is happen on the server side in terms of which user "runs" the R code and is it possible to configure this? My initial thought was that the user should be "data-www" which is the default Apache setting on my system. Don't know at what layer the user is set, Apache, rApache or opencpu, but I'm guessing it should be configurable on OpenCPU level?

The System the server runs on is more or less a linux Ubuntu server.

1

There are 1 best solutions below

0
On

The OpenCPU system runs on top of your system default Apache2 server. Which uid is used to run the apache2 daemon is configured on your system. By default it is www-data on Debian/Ubuntu. You can probably override this somewhere.