How to tell start-stop-daemon to update $HOME and $USER accordingly to --chuid parameter
Posted
by iElectric
on Server Fault
See other posts from Server Fault
or by iElectric
Published on 2010-05-09T08:15:50Z
Indexed on
2010/05/09
8:18 UTC
Read the original article
Hit count: 235
I'm trying to run a service that uses $HOME and $USER environment variables. I could set them in service itself, but that would only be a temporary solution.
Let's say I have a script test.sh
with following content:
echo $USER
And I run it with start-stop-daemon
to see my results:
$ start-stop-daemon --start --exec `pwd`/test.sh --user guest --group guest --chuid -guest
root
Seems like it does not update environment, maybe that should be reported as a bug?
I have found a nasty hacky solution, which only works (for unknown reason) on my this simple use case:
$ start-stop-daemon --exec /usr/bin/sudo --start -- -u guest -i 'echo $USER'
guest
I'm sure someone else stumbled upon this, I'm interested in clean solution.
$ start-stop-daemon --version
start-stop-daemon 1.13.11+gentoo
© Server Fault or respective owner