From owner-freebsd-rc@FreeBSD.ORG Sat Oct 6 21:53:33 2007 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9384E16A41A for ; Sat, 6 Oct 2007 21:53:33 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: from terra.mike.lan (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 89AE213C447; Sat, 6 Oct 2007 21:53:31 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: by terra.mike.lan (Postfix, from userid 1000) id A5B7F67991; Sun, 7 Oct 2007 00:57:57 +0300 (EAT) Date: Sun, 7 Oct 2007 00:57:57 +0300 From: Mike Makonnen To: Maksim Yevmenkin Message-ID: <20071006215757.GA10458@terra.mike.lan> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD/7.0-CURRENT (i386) Cc: freebsd-rc@freebsd.org Subject: Re: multiple instances of ppp X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2007 21:53:33 -0000 On Sat, Oct 06, 2007 at 01:14:18PM -0700, Maksim Yevmenkin wrote: > hello, > > a friend of mine send me the following /etc/rc.c/ppp replacement > script. the idea is to start multiple instances of ppp at boot time > (possibly with different profiles). > > i'm not sure if this is ok to commit as it is, so i decided to ask if > there is a better way to handle this. > > any thoughts on the subject is very much appreciated. I like it, but it has several bugs and needs to be cleaned up first. My comments are inline. > > . /etc/rc.subr > name="ppp" > rcvar=`set_rcvar` > command="/usr/sbin/${name}" > start_cmd="ppp_prestart" > start_poststart="ppp_poststart" The above line should start with: start_postcmd= The ppp_poststart() routine will never be executed becuse rc.subr(8) looks for start_postcmd not start_poststart. > > ppp_prestart() You should change the name of the routine to reflect its new behavior. It's no longer executed before the start routine, it *is* the start routine. > { > echo -n "Starting PPP profile:" > for profile in ${ppp_profile} > do > echo -n " ${profile}" > # Establish ppp mode. > # > rc_flags='' > eval ppp_mode=\$ppp_${profile}_mode This breaks POLA. It should be fixed so that it falls back to ppp_mode if ppp_${profile}_mode is empty. > if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ > -a "${ppp_mode}" != "dedicated" \ > -a "${ppp_mode}" != "background" ]; then > ppp_mode="auto" > fi > rc_flags="$rc_flags -quiet -${ppp_mode}" ^^^^^^^^^^ rc_flags is set to the the "empty string" at the beginning of the loop so it will allways be empty at this point in script. > > # Switch on NAT mode? > # > nat=$ppp_nat > eval cur_nat=\$ppp_${profile}_nat > case $cur_nat in > [Yy][Ee][Ss]|[Nn][Oo]) > nat=${cur_nat} > ;; > esac > case ${nat} in > [Yy][Ee][Ss]) > rc_flags="$rc_flags -nat" > ;; > esac > > # Run ! > # > su -m $ppp_user -c "$command ${rc_flags} ${profile}" Cheers. -- Mike Makonnen | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm @ FreeBSD.Org | FreeBSD - http://www.freebsd.org