/usr/local/etc/rc.d/ scripts and non-root user
RW
fbsd06 at mlists.homeunix.com
Wed Feb 6 21:58:22 UTC 2008
On Wed, 06 Feb 2008 17:09:50 +0000
Alex Zbyslaw <xfb52 at dial.pipex.com> wrote:
> I personally much prefer scripts in rc.d because it's much easier to
> migrate than crontabs, and if I never use a crontab I always know
> where to look.
>
> It looks to me like you shouldn't be starting the demon as user api -
> startups scripts should always be started as root. If the demon or
> whatever is supposed to run as api not root, then perhaps your script
> should say e.g.
>
> su api -c the-path-to-the-demon-or-whatever
>
> root can su to whoever without a password, and api can su to api
> without a password, and everyone else gets prompted.
It's actually built into /etc/rc.subr, the subversion server script is
a simple example of starting a daemon with a different user:
$ grep -v "^#" /usr/local/etc/rc.d/svnserve
. "/etc/rc.subr"
svnserve_enable=${svnserve_enable:-"NO"}
svnserve_flags=${svnserve_flags:-"-d --listen-port=3690"}
svnserve_data=${svnserve_data:-"/usr/local/repositories"}
svnserve_user=${svnserve_user:-"svn"}
svnserve_group=${svnserve_group:-"svn"}
name=svnserve
rcvar=`set_rcvar`
load_rc_config $name
command=/usr/local/bin/svnserve
command_args="-r ${svnserve_data}"
run_rc_command "$1"
More information about the freebsd-questions
mailing list