LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-13-2005, 02:53 AM   #1
Butterbroetchen
Member
 
Registered: Jan 2004
Posts: 57

Rep: Reputation: 15
Starting a Service at Boot as a Different user, how?


Hi all,

I have a Teamspeak server and have added the Startup script into my /etc/init.d and created all the links in the rc.d folder to be able to manage it via chkconfig so that the service start when the machine starts...this works fine.

My question is how do I get this to start as another user other than root? When the machine starts the service is running as root and this can't be good...is there a way of gettng it to run as a different user? I know I can stop it and then start it as any other user when the server is up but I do not want to have to do this all the time.

Thanks for any advise in advance.

Butter

Last edited by Butterbroetchen; 05-13-2005 at 04:42 AM.
 
Old 05-13-2005, 07:26 AM   #2
slacky
Member
 
Registered: Feb 2004
Location: USA
Distribution: Debian
Posts: 174

Rep: Reputation: 16
You could try editing the startup scripts and adding the appropriate su command where the script starts the program.
 
Old 05-16-2005, 07:05 PM   #3
cormander
Member
 
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Rep: Reputation: 15
Assume the service you want to start as another user is "myservice", here is what I would do:

mkdir /usr/local/init

cd into /etc/rc.d/init.d

Move the myservice init script you want to change the user for, into /usr/local/init

Make a simple "wrapper" shell script to execute it as a different user, and name it what the service is

Code:
#!/bin/bash

exec sudo -u USER /usr/local/init/myservice
On boot, when the service runs, it will run your wrapper script, which executes the real init script as the specified USER

Hope this helps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Won't Boot - Starting Printer Service - Starting CUPS jeansond Linux - Newbie 0 10-11-2004 06:39 PM
starting a service at boot time fallen26 General 5 07-31-2004 12:21 PM
Starting a service as non root user? dee3lmo Linux - General 2 07-30-2004 07:37 PM
Starting up a service (Postgres) on boot aa2bi Linux - Newbie 1 06-15-2004 05:34 PM
Starting apache and mysql as service on boot :: buddy Linux - General 2 12-30-2002 02:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration