From marck@kitty.wpub.hole.ru  Wed Aug 22 13:57:10 2001
Return-Path: <marck@kitty.wpub.hole.ru>
Received: from kitty.wpub.hole.ru (wpub.rinet.ru [195.54.193.21])
	by hub.freebsd.org (Postfix) with ESMTP id 3D47B37B42B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Aug 2001 13:57:07 -0700 (PDT)
	(envelope-from marck@kitty.wpub.hole.ru)
Received: (from marck@localhost)
	by kitty.wpub.hole.ru (8.11.5/8.11.5) id f7MKrwm24440;
	Thu, 23 Aug 2001 00:53:59 +0400 (MSD)
	(envelope-from marck)
Message-Id: <200108222053.f7MKrwm24440@kitty.wpub.hole.ru>
Date: Thu, 23 Aug 2001 00:53:59 +0400 (MSD)
From: Dmitry Morozovsky <marck@kitty.wpub.hole.ru>
Reply-To: Dmitry Morozovsky <marck@rinet.ru>, yar@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: cleanup of ppp server socket on unclean startup
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         29966
>Category:       bin
>Synopsis:       cleanup of ppp server socket on unclean startup
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 22 14:00:00 PDT 2001
>Closed-Date:    Tue Nov 6 02:51:45 PST 2001
>Last-Modified:  Tue Nov 06 02:55:18 PST 2001
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
Cronyx Plus LLC
>Environment:

	Various

>Description:

	After unclean shutdown (e.g, crash) ppp server socket
remains on file system. Then, if ppp started automatically
during startup, it cannot bind to that socket

>How-To-Repeat:

	ppp_enable="YES" at /etc/rc.conf

	boot

	killall -9 ppp
	shutdown -r now

>Fix:

Add another little knob to rc.conf and appropriate part to
rc.network

--- etc/defaults/rc.conf	Fri Aug 17 11:26:38 2001
+++ /etc/defaults/rc.conf	Thu Aug 23 00:20:33 2001
@@ -105,6 +105,7 @@
 ppp_nat="YES"		# Use PPP's internal network address translation or NO.
 ppp_profile="papchap"	# Which profile to use from /etc/ppp/ppp.conf.
 ppp_user="root"		# Which user to run ppp as
+ppp_server="/var/tmp/loop"	# PPP server socket
 
 ### Network daemon (miscellaneous) & NFS options: ###
 syslogd_enable="YES"		# Run syslog daemon (or NO).
--- etc/rc.network	Mon Aug 20 14:47:38 2001
+++ /etc/rc.network	Thu Aug 23 00:39:51 2001
@@ -243,7 +243,12 @@
 
 		ppp_command="${ppp_command} ${ppp_profile}"
 
+		# Clean old server socket
+		if [ "${ppp_server}" != "" -a -S "${ppp_server}" ]; then
+			rm -f "${ppp_server}"
+		fi
+
		echo "Starting ppp as \"${ppp_user}\""
 		su -m ${ppp_user} -c "exec ${ppp_command}"
 		;;
 	esac
>Release-Note:
>Audit-Trail:

From: "Crist J. Clark" <cristjc@earthlink.net>
To: Dmitry Morozovsky <marck@rinet.ru>, yar@FreeBSD.ORG
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup
Date: Wed, 22 Aug 2001 16:19:17 -0700

 On Thu, Aug 23, 2001 at 12:53:59AM +0400, Dmitry Morozovsky wrote:
 
 [snip]
 
 > >Description:
 > 
 > 	After unclean shutdown (e.g, crash) ppp server socket
 > remains on file system. Then, if ppp started automatically
 > during startup, it cannot bind to that socket
 >
 > >How-To-Repeat:
 > 
 > 	ppp_enable="YES" at /etc/rc.conf
 > 
 > 	boot
 > 
 > 	killall -9 ppp
 > 	shutdown -r now
 
 This is actually a more general issue than dealing with start-ups. You
 can just do,
 
   # ppp -background WhatEver
   Working in background mode
   Using interface: tun0
   PPP enabled
   # kill -KILL `cat /var/run/tun.pid`
   ppp -background Earthlink
   Working in background mode
   Using interface: tun0
   Warning: Local: bind: Address already in use
   Warning: set server: Failed 2
 
 And get the same failure.
  
 > >Fix:
 > 
 > Add another little knob to rc.conf and appropriate part to
 > rc.network
 
 Actually, a much easier fix is to put your server socket above
 /var/run. Everything above /var/run is already cleaned during the boot
 process.
 
 It's simply not possible to make the rc(8) scripts completely
 bulletproof when coming up from a crash. I personally don't see a need
 for this addition to the process. Using /var/run or some other
 location automatically cleaned at boot for your socket seems to be a
 much more general solution. Unless someone has some compelling
 arguments on why ppp(8) needs this special treatment in rc(8) scripts,
 I'll close this PR tomorrow.
 -- 
 Crist J. Clark                           cjclark@alum.mit.edu

From: Dmitry Morozovsky <marck@rinet.ru>
To: <cjclark@alum.mit.edu>
Cc: <yar@FreeBSD.ORG>, <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup
Date: Thu, 23 Aug 2001 03:29:46 +0400 (MSD)

 Hello ther Crist,
 
 
 On Wed, 22 Aug 2001, Crist J. Clark wrote:
 
 CJC> > 	After unclean shutdown (e.g, crash) ppp server socket
 CJC> > remains on file system. Then, if ppp started automatically
 CJC> > during startup, it cannot bind to that socket
 
 [snip]
 
 CJC> Actually, a much easier fix is to put your server socket above
 CJC> /var/run. Everything above /var/run is already cleaned during the boot
 CJC> process.
 
 Unfortunately, it's not such easy now. I use my socket in /var/run/ppp and
 it is not cleaned. AFAICC, the only files that are now cleaned from
 /var/run is pid files -- and it's not "The Right Thing (tm)" for me to
 name socket ending with .pid ;-)
 
 Or did I miss some serious changes with purgedir()?
 
 CJC> It's simply not possible to make the rc(8) scripts completely
 CJC> bulletproof when coming up from a crash. I personally don't see a need
 CJC> for this addition to the process. Using /var/run or some other
 CJC> location automatically cleaned at boot for your socket seems to be a
 CJC> much more general solution. Unless someone has some compelling
 CJC> arguments on why ppp(8) needs this special treatment in rc(8) scripts,
 CJC> I'll close this PR tomorrow.
 
 Thank you for your cooperation and especially for quick reaction.
 
 
 Sincerely,
 D.Marck                                   [DM5020, DM268-RIPE, DM3-RIPN]
 ------------------------------------------------------------------------
 *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
 ------------------------------------------------------------------------
 

From: "Yar Tikhiy" <yar@comp.chem.msu.su>
To: <freebsd-gnats-submit@FreeBSD.org>, <marck@rinet.ru>
Cc:  
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup
Date: Wed, 10 Oct 2001 11:43:31 +0400

 /var/run is cleaned now, so please put all files that must be removed
 at the boot time there. It won't be sensible to have an rc.conf knob for
 every such case.
 

From: "Crist J. Clark" <cristjc@earthlink.net>
To: Dmitry Morozovsky <marck@rinet.ru>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup
Date: Fri, 12 Oct 2001 21:55:29 -0700

 On Thu, Aug 23, 2001 at 02:16:12PM +0400, Dmitry Morozovsky wrote:
 [snip]
 
 > oops. seems I miss something during mergemaster. Yes, now it should remove
 > anything which is not directory. So, my trouble gone away. The only thing
 > I suppose is useful according to this issue now is change ppp.conf both in
 > /etc/ppp and in examples to move example server sockets to /var/run.
 
 Finally got to this. I'll commit these soon. Any place else anyone can
 see 'set server' in the ppp(8) examples or documentation?
 
 Index: src/etc/mtree/BSD.var.dist
 ===================================================================
 RCS file: /export/ncvs/src/etc/mtree/BSD.var.dist,v
 retrieving revision 1.50
 diff -u -r1.50 BSD.var.dist
 --- src/etc/mtree/BSD.var.dist	2001/10/01 08:54:16	1.50
 +++ src/etc/mtree/BSD.var.dist	2001/10/13 04:53:25
 @@ -57,6 +57,7 @@
      run
          named           uname=bind gname=bind
          ..
 +        ppp             gname=network mode=0775
      ..
      rwho            gname=daemon mode=0775
      ..
 Index: src/share/examples/ppp/ppp.conf.isdn
 ===================================================================
 RCS file: /export/ncvs/src/share/examples/ppp/ppp.conf.isdn,v
 retrieving revision 1.8
 diff -u -r1.8 ppp.conf.isdn
 --- src/share/examples/ppp/ppp.conf.isdn	2001/05/25 12:11:02	1.8
 +++ src/share/examples/ppp/ppp.conf.isdn	2001/10/13 04:39:07
 @@ -75,7 +75,7 @@
   link * set mode auto			# Automatically manage the second link
   set autoload 10 80 30			# Down @10% usage, up at 80%, 30s sample
  
 - set server /tmp/ppp-isdn "" 0177	# The diagnostic port (-rw-------)
 + set server /var/run/ppp/ppp-isdn "" 0177 # The diagnostic port (-rw-------)
  
  #
  # When phone calls become free (say 0:00 Saturday morning), we may want
 Index: src/share/examples/ppp/ppp.conf.sample
 ===================================================================
 RCS file: /export/ncvs/src/share/examples/ppp/ppp.conf.sample,v
 retrieving revision 1.27
 diff -u -r1.27 ppp.conf.sample
 --- src/share/examples/ppp/ppp.conf.sample	2001/07/24 13:11:57	1.27
 +++ src/share/examples/ppp/ppp.conf.sample	2001/10/13 04:40:35
 @@ -156,7 +156,7 @@
  
   set mru 1504			# Some extra room for the MP header
  
 - set server /tmp/ppp-TA "" 0177	# The diagnostic port (-rw-------)
 + set server /var/run/ppp/ppp-TA "" 0177	# The diagnostic port (-rw-------)
  
  
  #                          Example segments
 @@ -182,7 +182,7 @@
  # First, you must set up your control socket.  It's safest to use
  # a UNIX domain socket, and watch the permissions:
  #
 -    set server /var/tmp/internet MySecretPassword 0177
 +    set server /var/run/ppp/internet MySecretPassword 0177
  #
  # Although a TCP port may be used if you want to allow control
  # connections from other machines:
 @@ -566,7 +566,7 @@
   set dial
   set login
   set ifaddr 127.0.0.2 127.0.0.3
 - set server /var/tmp/loop "" 0177
 + set server /var/run/ppp/loop "" 0177
   
  loop-in:
   set timeout 0
 Index: src/share/examples/ppp/ppp.conf.span-isp.working
 ===================================================================
 RCS file: /export/ncvs/src/share/examples/ppp/ppp.conf.span-isp.working,v
 retrieving revision 1.3
 diff -u -r1.3 ppp.conf.span-isp.working
 --- src/share/examples/ppp/ppp.conf.span-isp.working	2000/08/17 14:40:42	1.3
 +++ src/share/examples/ppp/ppp.conf.span-isp.working	2001/10/13 04:42:45
 @@ -94,7 +94,7 @@
    enable chap
    disable lqr
    set ifaddr 127.0.0.2 127.0.0.3
 -  set server /var/tmp/vpn-in "" 0177
 +  set server /var/run/ppp/vpn-in "" 0177
  
  
  isp-in-7:
 Index: src/share/examples/ppp/ppp.linkup.span-isp
 ===================================================================
 RCS file: /export/ncvs/src/share/examples/ppp/ppp.linkup.span-isp,v
 retrieving revision 1.2
 diff -u -r1.2 ppp.linkup.span-isp
 --- src/share/examples/ppp/ppp.linkup.span-isp	1999/08/28 00:19:31	1.2
 +++ src/share/examples/ppp/ppp.linkup.span-isp	2001/10/13 04:42:12
 @@ -14,4 +14,4 @@
    !bg ppp -background vpnN vpn
  
  vpn:
 -  set server /var/tmp/vpn "" 0177
 +  set server /var/run/ppp/vpn "" 0177
 Index: src/share/examples/ppp/ppp.linkup.span-isp.working
 ===================================================================
 RCS file: /export/ncvs/src/share/examples/ppp/ppp.linkup.span-isp.working,v
 retrieving revision 1.2
 diff -u -r1.2 ppp.linkup.span-isp.working
 --- src/share/examples/ppp/ppp.linkup.span-isp.working	1999/08/28 00:19:31	1.2
 +++ src/share/examples/ppp/ppp.linkup.span-isp.working	2001/10/13 04:42:33
 @@ -14,4 +14,4 @@
    !bg ppp -background vpn3 vpn
  
  vpn:
 -  set server /var/tmp/vpn "" 0177
 +  set server /var/run/ppp/vpn "" 0177
 
 -- 
 Crist J. Clark                     |     cjclark@alum.mit.edu
                                    |     cjclark@jhu.edu
 http://people.freebsd.org/~cjc/    |     cjc@freebsd.org

From: "Crist J. Clark" <cristjc@earthlink.net>
To: Brian Somers <brian@freebsd-services.com>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup
Date: Sat, 13 Oct 2001 11:57:38 -0700

 On Sat, Oct 13, 2001 at 01:17:18PM +0100, Brian Somers wrote:
 > >  Finally got to this. I'll commit these soon. Any place else anyone can
 > >  see 'set server' in the ppp(8) examples or documentation?
 > >  
 > >  Index: src/etc/mtree/BSD.var.dist
 > >  ===================================================================
 > >  RCS file: /export/ncvs/src/etc/mtree/BSD.var.dist,v
 > >  retrieving revision 1.50
 > >  diff -u -r1.50 BSD.var.dist
 > >  --- src/etc/mtree/BSD.var.dist	2001/10/01 08:54:16	1.50
 > >  +++ src/etc/mtree/BSD.var.dist	2001/10/13 04:53:25
 > >  @@ -57,6 +57,7 @@
 > >       run
 > >           named           uname=bind gname=bind
 > >           ..
 > >  +        ppp             gname=network mode=0775
 > >       ..
 > >       rwho            gname=daemon mode=0775
 > >       ..
 > [.....]
 > 
 > I suggested this a very long time ago and it was rejected on the 
 > grounds that it's not necessary to create a ``standard'' hierarchy 
 > under /var/run as ppp is generally run at most once or twice on a 
 > given machine.
 > 
 > I believe putting these sockets in /var/run is perfectly fine and the 
 > patch should not be applied.
 
 The reason for the directory is to give write permission to the group
 'network.' ppp(8) is not always run by root. This is the same reason
 there is a 'named' directory in there. 
 -- 
 Crist J. Clark                     |     cjclark@alum.mit.edu
                                    |     cjclark@jhu.edu
 http://people.freebsd.org/~cjc/    |     cjc@freebsd.org

From: Brian Somers <brian@freebsd-services.com>
To: cjclark@alum.mit.edu
Cc: Brian Somers <brian@freebsd-services.com>,
	freebsd-gnats-submit@FreeBSD.ORG, brian@freebsd-services.com
Subject: Re: bin/29966: cleanup of ppp server socket on unclean startup 
Date: Mon, 15 Oct 2001 10:49:18 +0100

 > On Sat, Oct 13, 2001 at 01:17:18PM +0100, Brian Somers wrote:
 > > >  Finally got to this. I'll commit these soon. Any place else anyone can
 > > >  see 'set server' in the ppp(8) examples or documentation?
 > > >  
 > > >  Index: src/etc/mtree/BSD.var.dist
 > > >  ===================================================================
 > > >  RCS file: /export/ncvs/src/etc/mtree/BSD.var.dist,v
 > > >  retrieving revision 1.50
 > > >  diff -u -r1.50 BSD.var.dist
 > > >  --- src/etc/mtree/BSD.var.dist	2001/10/01 08:54:16	1.50
 > > >  +++ src/etc/mtree/BSD.var.dist	2001/10/13 04:53:25
 > > >  @@ -57,6 +57,7 @@
 > > >       run
 > > >           named           uname=bind gname=bind
 > > >           ..
 > > >  +        ppp             gname=network mode=0775
 > > >       ..
 > > >       rwho            gname=daemon mode=0775
 > > >       ..
 > > [.....]
 > > 
 > > I suggested this a very long time ago and it was rejected on the 
 > > grounds that it's not necessary to create a ``standard'' hierarchy 
 > > under /var/run as ppp is generally run at most once or twice on a 
 > > given machine.
 > > 
 > > I believe putting these sockets in /var/run is perfectly fine and the 
 > > patch should not be applied.
 > 
 > The reason for the directory is to give write permission to the group
 > 'network.' ppp(8) is not always run by root. This is the same reason
 > there is a 'named' directory in there. 
 
 Hmm, ok, I retract my objection in that case :)
 
 > -- 
 > Crist J. Clark                     |     cjclark@alum.mit.edu
 >                                    |     cjclark@jhu.edu
 > http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
 
 -- 
 Brian <brian@freebsd-services.com>                <brian@Awfulhak.org>
       http://www.freebsd-services.com/        <brian@[uk.]FreeBSD.org>
 Don't _EVER_ lose your sense of humour !      <brian@[uk.]OpenBSD.org>
 
 
State-Changed-From-To: open->closed 
State-Changed-By: cjc 
State-Changed-When: Tue Nov 6 02:51:45 PST 2001 
State-Changed-Why:  
A /var/run/ppp directory writable by the network group is now created 
in -CURRENT and -STABLE. The /usr/share/examples/ppp files have been 
changed to reflect this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29966 
>Unformatted:
