View previous topic :: View next topic |
Author |
Message |
dman777 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 10 Jan 2007 Posts: 1004
|
Posted: Fri Jul 01, 2011 5:41 am Post subject: Running a program as non root from init dureing boot up? |
|
|
I have a music server software running on my gentoo system(called subsonic) that streams to my android phone. It runs in a Java sandbox and also uses Apache. For security, I have all the files owned by a non root user I created call music. What I usually do is su to user music and start the service(from a shell script that starts it).
If I wanted this music to start from init during boot up, how can I do this and not have it run as root? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
eccerr0r Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
Joined: 01 Jul 2004 Posts: 9891 Location: almost Mile High in the USA
|
Posted: Fri Jul 01, 2011 6:12 am Post subject: |
|
|
You can run it
su userid -c command_to_run
It will change user to userid before running command_to_run. This of course will affect command_to_run and not subsequent commands in the shell executing the su... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
dman777 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 10 Jan 2007 Posts: 1004
|
Posted: Fri Jul 01, 2011 7:27 am Post subject: |
|
|
I'm not at home to post the script that starts subsonic server(and all of it's java software). When you say "This of course will affect command_to_run and not subsequent commands in the shell executing the su..." does this mean it will only start the first command in the script as the non root user and the rest of the commands(such as some java commands) that transverse in the script as root? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
eccerr0r Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
Joined: 01 Jul 2004 Posts: 9891 Location: almost Mile High in the USA
|
Posted: Fri Jul 01, 2011 5:56 pm Post subject: |
|
|
The su forks a shell running the command you specify, that shell is the only process with the changed priviledged. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|