Date: Sun, 7 Oct 2007 00:57:57 +0300 From: Mike Makonnen <mtm@FreeBSD.Org> To: Maksim Yevmenkin <maksim.yevmenkin@gmail.com> Cc: freebsd-rc@freebsd.org Subject: Re: multiple instances of ppp Message-ID: <20071006215757.GA10458@terra.mike.lan> In-Reply-To: <bb4a86c70710061314j588ce9a9s6922d2c1e7100e6a@mail.gmail.com> References: <bb4a86c70710061314j588ce9a9s6922d2c1e7100e6a@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071006215757.GA10458>