Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Running a program as non root from init dureing boot up?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
dman777
Veteran
Veteran


Joined: 10 Jan 2007
Posts: 1004

PostPosted: Fri Jul 01, 2011 5:41 am    Post subject: Running a program as non root from init dureing boot up? Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9891
Location: almost Mile High in the USA

PostPosted: Fri Jul 01, 2011 6:12 am    Post subject: Reply with quote

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
View user's profile Send private message
dman777
Veteran
Veteran


Joined: 10 Jan 2007
Posts: 1004

PostPosted: Fri Jul 01, 2011 7:27 am    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9891
Location: almost Mile High in the USA

PostPosted: Fri Jul 01, 2011 5:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum