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: 204

Filed under:
|
|

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

Related posts about environment-variables

Related posts about home

  • encfs error while decoding the data

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have installed encfs and started using it to secure all my personal & office data and it was working absolutely fine until 2 hours back. The setup is like this. I have a folder in Copy folder called OfficeData which gets synchronized with my Copy folder When I login into the system I use… >>> More

  • Magento, NGINX, PHP-FPM, APC, MEMCACHED, 16gb Ram CentOS, Spiking PHP-FPM to 100% CPU

    as seen on Server Fault - Search for 'Server Fault'
    I have been trying to resolve my issue of spiking cpu caused by php-fpm processes. I've reduced the php-fpm config settings to: pm = ondemand pm.max_children = 12 pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 10 pm.max_requests = 500 php_admin_value[memory_limit] = 128M Problem… >>> More

  • Building Awesome WM

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    Hello, I am following these steps in order to build Awesome window manager on 10.04 I am building 3.4 while the tutorial is for 3.1 I installed all of the specified dependencies including cairo. After running cd awesome-3.4 && make I get the following missing dependencies error: Running… >>> More

  • Building Awesome WM

    as seen on Server Fault - Search for 'Server Fault'
    Hello, I am following these steps in order to build Awesome window manager on 10.04 I am building 3.4 while the tutorial is for 3.1 I installed all of the specified dependencies including cairo. EDIT I ran: sudo apt-get install libxcb-xtest0-dev libxcb-property1-dev libxdg-basedir-dev libstartup-notification0-dev… >>> More

  • Building Awesome WM

    as seen on Super User - Search for 'Super User'
    Hello, I am following these steps in order to build Awesome window manager on 10.04 I am building 3.4 while the tutorial is for 3.1 I installed all of the specified dependencies including cairo. EDIT I ran: sudo apt-get install libxcb-xtest0-dev libxcb-property1-dev libxdg-basedir-dev libstartup-notification0-dev… >>> More