- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Running startup scripts under different user
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 11:19 AM
тАО09-03-2003 11:19 AM
Does anyone know of a way to run a startup script in /etc/rc.d/init.d/ under a user other than root?
I don't think that there is any setting in the program itself or the config files for it.
To run it normally I just installed it using user "user1" and su to user1 to call the startup script. This way the process is owned by user1.
I tried creating a chkconfig compatible script in /etc/rc.d/init.d/ to start it on startup, but then it starts as root.
Any suggestions?
Thanks...
-Travis
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 11:38 AM
тАО09-03-2003 11:38 AM
Re: Running startup scripts under different user
This is a potential security hazard.
To change the permissions chmod o+x /etc/init.d/
You couild change ownership on the script, but this too is a security hazard.
Some daemon's are quite unhappy with being run by non-root users. Some won't run at all.
Probably the issue with what you have done thus far is permissions and ownership of the script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 12:01 PM
тАО09-03-2003 12:01 PM
Solutionsu -
heres a runnable example:
su - flexlm -c "lmgrd -c license.dat"
I actually use this to run my flexlm license daemons so that the process is running as the flexlm user, ie. no shell.
I hope that helps,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 12:55 PM
тАО09-03-2003 12:55 PM
Re: Running startup scripts under different user
Dave, so it sounds like I should be able to just enter the command
su user -c "command" for the program I want started into the rc.local file and it should run correctly.
Does that sound right?
I tried starting it on the command line that way and it works just fine.
-Travis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 01:10 PM
тАО09-03-2003 01:10 PM
Re: Running startup scripts under different user
remember the - after the su is very important otherwise you are that user but you have not sourced that users enviroment scripts which can be bad news, ie. path will be totally on crack.
su dave != su - dave
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 01:22 PM
тАО09-03-2003 01:22 PM
Re: Running startup scripts under different user
Then make some links to it in /etc/rc2.d/
called S99<scriptname> ( S is for start )
and one in rc5.d/ called
K99<scriptname> ( the k is for stop which is kind of dumb but whatever )
The scripts in the rcN.d directorys are executed with the argument start or stop depending on their name. At least that has been my experience. I will attach a really simple script that I use to start my flexlm servers so you have a kind of template to work with.
I hope that helps,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 02:16 PM
тАО09-03-2003 02:16 PM
Re: Running startup scripts under different user
I'm pretty sure I have it working, I'll know next time I restart.
I already had a script in /etc/rc.d/init.d/ that would start the program but under root.
All that script did was call the program's respective _start or _stop scripts.
So I just added the "su - user" in front of each call to the start/stop scripts.
It works by doing
/etc/rc.d/init.d/program start|stop manually
and runs under the appropriate user so I'm pretty sure that it will works on startup.
I also configured the script appropriately with the S and K links.
Thanks a lot...
-Travis