i have a daemon running which might spawn a Process on incomming connections. This is done using execvp()
and fork()
.
The Problem is that the process should not run as root and the process is dependend on a correct user environment. So im seeking a way to load the user environment.
Currently the process is executed as another user by setting gid and uid. What i have already tried is using as command su -l user -c command
, which did not work for some reason.
Does somebody have an idea how i can load the user environment (especially the $HOME
variable)?
Thanks in advance.
You might do it like this:
Note: Please compile twice to generate Debug/Test and Debug/TestProcess
Result: