From nicolas@i.0x5.de  Fri Oct 20 18:22:40 2006
Return-Path: <nicolas@i.0x5.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 25FF916A403
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Oct 2006 18:22:40 +0000 (UTC)
	(envelope-from nicolas@i.0x5.de)
Received: from n.0x5.de (n.0x5.de [217.197.85.144])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A492243D5A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Oct 2006 18:22:39 +0000 (GMT)
	(envelope-from nicolas@i.0x5.de)
Received: by pc5.i.0x5.de (Postfix, from userid 1003)
	id EE07061C74; Fri, 20 Oct 2006 20:22:37 +0200 (CEST)
Message-Id: <20061020182237.EE07061C74@pc5.i.0x5.de>
Date: Fri, 20 Oct 2006 20:22:37 +0200 (CEST)
From: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
Reply-To: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: "rc.d/ppp restart" stops all instances of ppp
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         104623
>Category:       bin
>Synopsis:       "rc.d/ppp restart" stops all instances of ppp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    emax
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 20 18:30:18 GMT 2006
>Closed-Date:    Tue Mar 04 17:23:13 UTC 2008
>Last-Modified:  Tue Mar 04 17:23:13 UTC 2008
>Originator:     Nicolas Rachinsky
>Release:        FreeBSD 6.2-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD pc5.i.0x5.de 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #3: Sat Oct 14 15:24:36 CEST 2006 n@pc5.i.0x5.de:/usr/exported/src/sys/i386/compile/PC5 i386


	
>Description:
"rc.d/ppp restart" stops all running instances of ppp, but restarts only
the one configured in rc.conf.
>How-To-Repeat:
Start multiple instances of ppp (e.g. one for your dsl line and another
with pptpclient to use a pptp tunnel). Now do "rc.d/ppp restart" while both
are running. After it completes, only one of them is running.
>Fix:
Don't know how to fix this. If the tun device is known, the pid file could
be used. But without that, it seems hard to find the right one.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Oct 21 17:23:55 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=104623 

From: Mike Makonnen <mtm@FreeBSD.Org>
To: bug-followup@FreeBSD.org, freebsd-pr@cl.turing-complete.org
Cc:  
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 31 Mar 2007 13:49:59 +0300

 --IS0zKkzwUGydFO0o
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Can you try the attached patch?
 It allows you to specify the ppp instance to control by specifying
 the tunnel device name as an addtional argument:
  # /etc/rc.d/ppp restart tun0
 
 Cheers.
 -- 
 Mike Makonnen          | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
 mmakonnen_at_gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
 mtm_at_FreeBSD.Org     | FreeBSD - http://www.freebsd.org
 
 --IS0zKkzwUGydFO0o
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="ppp.diff"
 
 Index: etc/rc.d/ppp
 ===================================================================
 RCS file: /home/ncvs/src/etc/rc.d/ppp,v
 retrieving revision 1.13
 diff -u -r1.13 ppp
 --- etc/rc.d/ppp	31 Mar 2007 09:03:38 -0000	1.13
 +++ etc/rc.d/ppp	31 Mar 2007 09:25:27 -0000
 @@ -2,6 +2,8 @@
  #
  # $FreeBSD: src/etc/rc.d/ppp,v 1.13 2007/03/31 09:03:38 mtm Exp $
  #
 +# usage: /etc/rc.d/ppp <cmd> [tunX]
 +#
  
  # PROVIDE: ppp
  # REQUIRE: netif isdnd
 @@ -46,5 +48,13 @@
  	/etc/rc.d/pf resync
  }
  
 +# Allow the user to specify which ppp instance to control by
 +# specifing the tunnel device name on the command-line.
 +#
 +pppcmdline="$*"
 +if [ $# -gt 1 ]; then
 +	pidfile="/var/run/$2.pid"
 +fi
 +
  load_rc_config $name
 -run_rc_command "$1"
 +run_rc_command ${pppcmdline}
 
 --IS0zKkzwUGydFO0o--

From: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
To: Mike Makonnen <mtm@FreeBSD.Org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 31 Mar 2007 13:49:00 +0200

 * Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 13:49 +0300]:
 > +# usage: /etc/rc.d/ppp <cmd> [tunX]
 
 I haven't yet tried it, but I see one problem. AFAIK there is no
 mechanism to start more than one ppp with the current rc.d/ppp script
 via rc.conf. Thus I can't imagine how this can work if I do this with
 a tun device that does correspond to the ppp started via rc.d/ppp.
 
 And it will still terminate processes that are unrelated to the pp
 started via rc.d/ppp if it is used without the additional parameter.
 
 So I don't think, this can fix the real problem, that there is no way
 to identify the ppp instance that were started via rc.d/ppp. At least
 I see no such way.
 
 Do I miss something?
 
 Nicolas
State-Changed-From-To: open->feedback 
State-Changed-By: mtm 
State-Changed-When: Sat Mar 31 12:22:01 UTC 2007 
State-Changed-Why:  
I'll look into this. 
Patch has been worked up and awaiting response from 
Originator. 


Responsible-Changed-From-To: freebsd-rc->mtm 
Responsible-Changed-By: mtm 
Responsible-Changed-When: Sat Mar 31 12:22:01 UTC 2007 
Responsible-Changed-Why:  
I'll look into this. 
Patch has been worked up and awaiting response from 
Originator. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=104623 

From: Mike Makonnen <mtm@FreeBSD.Org>
To: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 31 Mar 2007 15:46:10 +0300

 On Sat, Mar 31, 2007 at 01:49:00PM +0200, Nicolas Rachinsky wrote:
 > * Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 13:49 +0300]:
 > > +# usage: /etc/rc.d/ppp <cmd> [tunX]
 > 
 > I haven't yet tried it, but I see one problem. AFAIK there is no
 > mechanism to start more than one ppp with the current rc.d/ppp script
 > via rc.conf. Thus I can't imagine how this can work if I do this with
 > a tun device that does correspond to the ppp started via rc.d/ppp.
 
 Whether you can start more than one ppp with rc.d/ppp is immaterial.
 That's an issue for another PR(1) :-)
 If you start more than one ppp (however you started them), the patch gives
 you the option of stoping/restarting them selectively using rc.d/ppp
 by specifying the tunnel device. So, if you want to stop the ppp daemon
 associated with tun1, for example, without affecting tun0 you can
 now do that.
 
 > 
 > And it will still terminate processes that are unrelated to the pp
 > started via rc.d/ppp if it is used without the additional parameter.
 > 
 > So I don't think, this can fix the real problem, that there is no way
 > to identify the ppp instance that were started via rc.d/ppp. At least
 > I see no such way.
 
 Sorry, I should have included an explanation with the patch.
 
 As you say there's no easy or straight-forward way to determine
 which ppp was started with rc.d/ppp. The patch was a compromise to
 allow an admin to selectively stop/restart a ppp instance without
 terminating all others. Also, arguably, running rc.d/ppp stop
 without additional arguments *should* terminate *all* ppp instances.
 
 Cheers.
 -- 
 Mike Makonnen          | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
 mmakonnen_at_gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
 mtm_at_FreeBSD.Org     | FreeBSD - http://www.freebsd.org

From: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
To: Mike Makonnen <mtm@FreeBSD.Org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 31 Mar 2007 15:04:03 +0200

 * Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 15:46 +0300]:
 > If you start more than one ppp (however you started them), the patch gives
 > you the option of stoping/restarting them selectively using rc.d/ppp
 > by specifying the tunnel device. So, if you want to stop the ppp daemon
 > associated with tun1, for example, without affecting tun0 you can
 > now do that.
 
 Stopping does work, restarting not, it tries to start the ppp that is
 started by rc.d/ppp. Restarting the one started by rc.d/ppp does work.
 
 > As you say there's no easy or straight-forward way to determine
 > which ppp was started with rc.d/ppp. The patch was a compromise to
 > allow an admin to selectively stop/restart a ppp instance without
 > terminating all others. Also, arguably, running rc.d/ppp stop
 > without additional arguments *should* terminate *all* ppp instances.
 
 I can not agree with the last sentence. "rc.d/ppp stop" should stop
 everything started by "rc.d/ppp start" and nothing else. I think it is
 a POLA violation if "rc.d/ppp stop" stops every instance of ppp, even
 instances started by other users!
 
 Nicolas
 

From: Mike Makonnen <mtm@FreeBSD.Org>
To: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 20 Oct 2007 02:34:35 +0300

 I think the following commit should fix this issue. It starts/stops based on
 the ppp profile. I've attached a patch relative to RELENG_6 to make
 it easier for you to try.
 
 ----- Forwarded message from Maksim Yevmenkin <emax@FreeBSD.org> -----
 
 Date: Thu, 18 Oct 2007 17:10:40 +0000 (UTC)
 To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
 From: Maksim Yevmenkin <emax@FreeBSD.org>
 Subject: cvs commit: src/etc/rc.d ppp
 Authentication-Results: mx.google.com; spf=pass (google.com: domain of owner-src-committers@freebsd.org designates 69.147.83.53 as permitted sender) smtp.mail=owner-src-committers@freebsd.org
 
 emax        2007-10-18 17:10:40 UTC
 
   FreeBSD src repository
 
   Modified files:
     etc/rc.d             ppp 
   Log:
   Teach /etc/rc.d/ppp how to start/stop individual instances
   of ppp. This is an extension of previous commit.
   
   Submitted by:   Yuri Kurenkov < y dot kurenkov at init dot ru >
   Reviewed by:    mtm
   MFC after:      3 days
   
   Revision  Changes    Path
   1.15      +36 -3     src/etc/rc.d/ppp
 
 ----- End forwarded message -----
 
 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

From: Mike Makonnen <mtm@FreeBSD.Org>
To: Nicolas Rachinsky <freebsd-pr@cl.turing-complete.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/104623: "rc.d/ppp restart" stops all instances of ppp
Date: Sat, 20 Oct 2007 03:17:33 +0300

 --n8g4imXOkfNTN/H1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Sorry, I forgot to attach the patch :(
 -- 
 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
 
 --n8g4imXOkfNTN/H1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=rcd-ppp-patch
 
 Index: etc/rc.d/ppp
 ===================================================================
 RCS file: /home/ncvs/src/etc/rc.d/ppp,v
 retrieving revision 1.11.2.3
 retrieving revision 1.15
 diff -u -r1.11.2.3 -r1.15
 --- etc/rc.d/ppp	15 May 2007 08:01:42 -0000	1.11.2.3
 +++ etc/rc.d/ppp	18 Oct 2007 17:10:40 -0000	1.15
 @@ -12,30 +12,70 @@
  name="ppp"
  rcvar=`set_rcvar`
  command="/usr/sbin/${name}"
 -start_precmd="ppp_prestart"
 +start_cmd="ppp_start"
 +stop_cmd="ppp_stop"
  start_postcmd="ppp_poststart"
  
 -ppp_prestart()
 +ppp_start_profile()
  {
 +	local _ppp_profile _ppp_mode _ppp_nat
 +
 +	_ppp_profile=$1
 +
 +	# Check for ppp profile mode override.
 +	#
 +	eval _ppp_mode=\$ppp_${_ppp_profile}_mode
 +	if [ -z "$_ppp_mode" ]; then
 +		_ppp_mode=$ppp_mode
 +	fi
 +
 +	# Check for ppp profile nat override.
 +	#
 +	eval _ppp_nat=\$ppp_${_ppp_profile}_nat
 +	if [ -z "$_ppp_nat" ]; then
 +		_ppp_nat=$ppp_nat
 +	fi
 +
  	# Establish ppp mode.
  	#
 -	if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
 -		-a "${ppp_mode}" != "dedicated" \
 -		-a "${ppp_mode}" != "background" ]; then
 -		ppp_mode="auto"
 +	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="-quiet -${_ppp_mode}"
  
  	# Switch on NAT mode?
  	#
 -	case ${ppp_nat} in
 +	case ${_ppp_nat} in
  	[Yy][Ee][Ss])
  		rc_flags="$rc_flags -nat"
  		;;
  	esac
  
 -	rc_flags="$rc_flags ${ppp_profile}"
 +	# Run!
 +	#
 +	su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}"
 +}
 +
 +ppp_start()
 +{
 +	local _ppp_profile _p
 +
 +	_ppp_profile=$*
 +	if [ -z "${_ppp_profile}" ]; then
 +		_ppp_profile=$ppp_profile
 +	fi
 +
 +	echo -n "Starting PPP profile:"
 +
 +	for _p in $_ppp_profile; do
 +		echo -n " $_p"
 +		ppp_start_profile $_p
 +	done
 +
 +	echo "."
  }
  
  ppp_poststart()
 @@ -46,5 +86,32 @@
  	/etc/rc.d/pf resync
  }
  
 +ppp_stop_profile() {
 +	local _ppp_profile
 +
 +	_ppp_profile=$1
 +
 +	/bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \
 +		echo -n "(not running)"
 +}
 +
 +ppp_stop() {
 +	local _ppp_profile _p
 +
 +	_ppp_profile=$*
 +	if [ -z "${_ppp_profile}" ]; then
 +		_ppp_profile=$ppp_profile
 +	fi
 +
 +	echo -n "Stopping PPP profile:"
 +
 +	for _p in $_ppp_profile; do
 +		echo -n " $_p"
 +		ppp_stop_profile $_p
 +	done
 +
 +	echo "."
 +}
 +
  load_rc_config $name
 -run_rc_command "$1"
 +run_rc_command $*
 
 --n8g4imXOkfNTN/H1--
State-Changed-From-To: feedback->patched 
State-Changed-By: linimon 
State-Changed-When: Sun Mar 2 06:04:36 UTC 2008 
State-Changed-Why:  
emax committed a patch that should address this, but it has not been 
MFCed to 6 yet. 


Responsible-Changed-From-To: mtm->emax 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Mar 2 06:04:36 UTC 2008 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=104623 
State-Changed-From-To: patched->closed 
State-Changed-By: emax 
State-Changed-When: Tue Mar 4 17:22:09 UTC 2008 
State-Changed-Why:  
the patch was MFC'ed to RELENG_6. for whatever reason it does not show up 
in cvsweb. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=104623 
>Unformatted:

the patch was MFC'ed to RELENG_6. for whatever reason it does not show up
in cvsweb.

