LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   Suse init script: start daemon as different user. possible? (https://www.linuxquestions.org/questions/suse-opensuse-60/suse-init-script-start-daemon-as-different-user-possible-864624/)

BrianK 02-23-2011 04:59 PM

Suse init script: start daemon as different user. possible?
 
Redhat supplies /etc/init.d/functions. In that file, many shell script functions are provided, one of which is "daemon" which has an option of "--user" which allows a daemon to be started by a user other than root. daemon --user foo /path/to/program.

Is there an equivilent provided by Suse? I see /lib/lsb/init-functions which includes "start_daemon". start_daemon is a symlink to startproc, but the man page(s) shows that start_daemon only takes an argument of -p, whereas startproc takes, among others, a -u <uid> option, which is close to what I'm after, though not exactly.

At the end of the day, I'm trying to write an init script that will work on both RH and Suse. One of the features of the init script is the ability to run a daemon as a given username. Is start_daemon the best way to go for Suse? Is it acceptable use -u with it? Is there another way I can go about this so that I can provide a username rather than UID?

Suggestions? Thanks.

SL00b 02-28-2011 02:34 PM

We do this with sudo. The start command in your init script would look something like this:

/usr/bin/sudo -u userid /path/to/daemon_executable


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