From owner-freebsd-questions@FreeBSD.ORG Wed Feb 6 21:58:22 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF83916A417 for ; Wed, 6 Feb 2008 21:58:22 +0000 (UTC) (envelope-from fbsd06+S3=4afc8aa7@mlists.homeunix.com) Received: from mxout-03.mxes.net (mxout-03.mxes.net [216.86.168.178]) by mx1.freebsd.org (Postfix) with ESMTP id 9E32413C44B for ; Wed, 6 Feb 2008 21:58:22 +0000 (UTC) (envelope-from fbsd06+S3=4afc8aa7@mlists.homeunix.com) Received: from gumby.homeunix.com. (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id 61C2123E3E8 for ; Wed, 6 Feb 2008 16:58:20 -0500 (EST) Date: Wed, 6 Feb 2008 21:58:18 +0000 From: RW To: freebsd-questions@freebsd.org Message-ID: <20080206215818.2bf7aa0e@gumby.homeunix.com.> In-Reply-To: <47A9E9DE.2060503@dial.pipex.com> References: <94136a2c0802060751o7952c2f8w639139271c946e98@mail.gmail.com> <47A9E373.80300@dial.pipex.com> <94136a2c0802060849o1dfb3f6ek67d7d41db5d99102@mail.gmail.com> <47A9E9DE.2060503@dial.pipex.com> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.7; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: /usr/local/etc/rc.d/ scripts and non-root user X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2008 21:58:22 -0000 On Wed, 06 Feb 2008 17:09:50 +0000 Alex Zbyslaw 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"