From josemi@freebsd.jazztel.es  Tue Nov 16 17:15:46 2004
Return-Path: <josemi@freebsd.jazztel.es>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8CECE16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 17:15:46 +0000 (GMT)
Received: from smtp2.jazztel.es (smtp2.jazztel.es [62.14.3.162])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A937B43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 17:15:45 +0000 (GMT)
	(envelope-from josemi@freebsd.jazztel.es)
Received: from antivirus
	by smtp2.jazztel.es
	with antivirus id 1CU6vd-0003xw-00
	for FreeBSD-gnats-submit@freebsd.org
	Tue, 16 Nov 2004 18:15:41 +0100
Received: from [212.106.252.3] (helo=rguez.homeunix.net)
	by smtp2.jazztel.es
	with esmtp id 1CU6vd-0003xH-00
	for FreeBSD-gnats-submit@freebsd.org
	Tue, 16 Nov 2004 18:15:41 +0100
Received: from redesjm.local (orion.redesjm.local [192.168.254.16])
	by rguez.homeunix.net (8.13.1/8.13.1) with ESMTP id iAGHFhl9022982
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 18:15:43 +0100 (CET)
	(envelope-from freebsd@redesjm.local)
Received: (from freebsd@localhost)
	by redesjm.local (8.13.1/8.13.1/Submit) id iAGHFgCf071028;
	Tue, 16 Nov 2004 18:15:42 +0100 (CET)
	(envelope-from freebsd)
Message-Id: <200411161715.iAGHFgCf071028@redesjm.local>
Date: Tue, 16 Nov 2004 18:15:42 +0100 (CET)
From: Jose M Rodriguez <josemi@freebsd.jazztel.es>
Reply-To: Jose M Rodriguez <josemi@freebsd.jazztel.es>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] /etc/rc.d/named minor fixes
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         74006
>Category:       conf
>Synopsis:       [PATCH] /etc/rc.d/named minor fixes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 16 17:20:22 GMT 2004
>Closed-Date:    Mon Oct 22 08:34:49 UTC 2007
>Last-Modified:  Mon Oct 22 17:42:42 UTC 2007
>Originator:     Jose M Rodriguez
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
Redes JM
>Environment:
System: FreeBSD orion.redesjm.local 5.3-STABLE FreeBSD 5.3-STABLE #0: Tue Nov 16 13:26:33 CET 2004 root@orion.redesjm.local:/usr/obj/usr/src/sys/ORION i386


>Description:
	Minor fixes to /etc/rc.d/named

	- add a ${named_chroot_mtree} var
	    To be capable of another chroot mtree without be force
	    to edit /etc/mtree/BIND.chroot.dist

	- move devfs mount code from chroot_autoupdate() to
	  named_precmd()
	    Mounting fs is not a task that must be expected from
	    chroot_autoupdate().  Do this in named_precmd(), after
	    chroot_autoupdate.

	- remove /etc/namedb symlink code from chroot_autoupdate()
	    This is the more cosmetic change.  Seems that this code
	    is here from initial works in /etc/rc.d/named and:
		+ This is not the place to do that.  Maybe in
		named_precmd().
		+ Don't seems needed.  Sure on that after 5.3 REL

>How-To-Repeat:
>Fix:

--- patch-named begins here ---
--- etc/rc.d/named.orig	Wed Oct 20 08:30:58 2004
+++ etc/rc.d/named	Wed Oct 20 08:31:19 2004
@@ -30,36 +30,16 @@
 {
 	# Create (or update) the chroot directory structure
 	#
-	if [ -f /etc/mtree/BIND.chroot.dist ]; then
-		mtree -deU -f /etc/mtree/BIND.chroot.dist \
+	if [ -f ${named_chroot_mtree:-/etc/mtree/BIND.chroot.dist} ]; then
+		mtree -deU -f ${named_chroot_mtree} \
 		    -p ${named_chrootdir}
 	else
-		warn "/etc/mtree/BIND.chroot.dist missing,"
+		warn "${named_chroot_mtree} missing,"
 		warn "chroot directory structure not updated"
 	fi
 
 	# Create /etc/namedb symlink
-	#
-	if [ ! -L /etc/namedb ]; then
-		if [ -d /etc/namedb ]; then
-			warn "named chroot: /etc/namedb is a directory!"
-		elif [ -e /etc/namedb ]; then
-			warn "named chroot: /etc/namedb exists!"
-		else
-			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
-		fi
-	fi
-
-	# Mount a devfs in the chroot directory if needed
-	#
-	if [ ! -c ${named_chrootdir}/dev/random -o \
-	    ! -c ${named_chrootdir}/dev/null ]; then
-		umount ${named_chrootdir}/dev 2>/dev/null
-		mount_devfs devfs ${named_chrootdir}/dev
-	fi
-	devfs -m ${named_chrootdir}/dev rule apply hide
-	devfs -m ${named_chrootdir}/dev rule apply path null unhide
-	devfs -m ${named_chrootdir}/dev rule apply path random unhide
+	# this must be a mergemaster task
 
 	# Copy local timezone information if it is not up to date.
 	#
@@ -87,6 +67,16 @@
 		rc_flags="$rc_flags -t $named_chrootdir"
 		confgen_chroot="-t${named_chrootdir} -u bind"
 		checkyesno named_chroot_autoupdate && chroot_autoupdate
+		# Mount a devfs in the chroot directory if needed
+		#
+		if [ ! -c ${named_chrootdir}/dev/random -o \
+			! -c ${named_chrootdir}/dev/null ]; then
+			umount ${named_chrootdir}/dev 2>/dev/null
+			mount_devfs devfs ${named_chrootdir}/dev
+		fi
+		devfs -m ${named_chrootdir}/dev rule apply hide
+		devfs -m ${named_chrootdir}/dev rule apply path null unhide
+		devfs -m ${named_chrootdir}/dev rule apply path random unhide
 	else
 		named_symlink_enable=NO
 	fi
--- patch-named ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Tue Mar 15 03:41:35 GMT 2005 
Responsible-Changed-Why:  

I generally maintain BIND stuff. 

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

From: Jose M Rodriguez <josemi@freebsd.jazztel.es>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: conf/74006: [PATCH] /etc/rc.d/named minor fixes
Date: Tue, 15 Mar 2005 23:55:48 +0100 (CET)

 Follow-up with corrected patch and devfs umount in stop postcmd
 
 - josemi
 
 --- patch-named begins here ---
 --- /usr/RELENG_5/src/etc/rc.d/named	Sun Oct 10 11:50:53 2004
 +++ etc/rc.d/named	Mon Mar 14 00:01:56 2005
 @@ -14,6 +14,7 @@
  rcvar=`set_rcvar`
  start_precmd="named_precmd"
  start_postcmd="make_symlinks"
 +stop_postcmd="named_postcmd"
  required_dirs="$named_chrootdir"	# if it is set, it must exist
  extra_commands="reload"
  
 @@ -30,36 +31,16 @@
  {
  	# Create (or update) the chroot directory structure
  	#
 -	if [ -f /etc/mtree/BIND.chroot.dist ]; then
 -		mtree -deU -f /etc/mtree/BIND.chroot.dist \
 +	if [ -f ${named_chroot_mtree:=/etc/mtree/BIND.chroot.dist} ]; then
 +		mtree -deU -f ${named_chroot_mtree} \
  		    -p ${named_chrootdir}
  	else
 -		warn "/etc/mtree/BIND.chroot.dist missing,"
 +		warn "${named_chroot_mtree} missing,"
  		warn "chroot directory structure not updated"
  	fi
  
  	# Create /etc/namedb symlink
 -	#
 -	if [ ! -L /etc/namedb ]; then
 -		if [ -d /etc/namedb ]; then
 -			warn "named chroot: /etc/namedb is a directory!"
 -		elif [ -e /etc/namedb ]; then
 -			warn "named chroot: /etc/namedb exists!"
 -		else
 -			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
 -		fi
 -	fi
 -
 -	# Mount a devfs in the chroot directory if needed
 -	#
 -	if [ ! -c ${named_chrootdir}/dev/random -o \
 -	    ! -c ${named_chrootdir}/dev/null ]; then
 -		umount ${named_chrootdir}/dev 2>/dev/null
 -		mount_devfs devfs ${named_chrootdir}/dev
 -	fi
 -	devfs -m ${named_chrootdir}/dev rule apply hide
 -	devfs -m ${named_chrootdir}/dev rule apply path null unhide
 -	devfs -m ${named_chrootdir}/dev rule apply path random unhide
 +	# this must be a mergemaster task
  
  	# Copy local timezone information if it is not up to date.
  	#
 @@ -87,6 +68,16 @@
  		rc_flags="$rc_flags -t $named_chrootdir"
  		confgen_chroot="-t${named_chrootdir} -u bind"
  		checkyesno named_chroot_autoupdate && chroot_autoupdate
 +		# Mount a devfs in the chroot directory if needed
 +		#
 +		if [ ! -c ${named_chrootdir}/dev/random -o \
 +			! -c ${named_chrootdir}/dev/null ]; then
 +			umount ${named_chrootdir}/dev 2>/dev/null
 +			mount_devfs devfs ${named_chrootdir}/dev
 +		fi
 +		devfs -m ${named_chrootdir}/dev rule apply hide
 +		devfs -m ${named_chrootdir}/dev rule apply path null unhide
 +		devfs -m ${named_chrootdir}/dev rule apply path random unhide
  	else
  		named_symlink_enable=NO
  	fi
 @@ -96,6 +87,13 @@
  	if [ ! -f "${named_chrootdir}/etc/namedb/rndc.key" -a \
  	    ! -f "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
  		rndc-confgen -a -b256 ${confgen_chroot}
 +	fi
 +}
 +
 +named_postcmd() {
 +	# Is the user using a sandbox?
 +	if [ -n "$named_chrootdir" ]; then
 +		umount ${named_chrootdir}/dev 2>/dev/null
  	fi
  }
  
 --- patch-named ends here ---

From: Jose M Rodriguez <josemi@freebsd.jazztel.es>
To: bug-followup@FreeBSD.org, josemi@freebsd.jazztel.es
Cc:  
Subject: Re: conf/74006: [PATCH] /etc/rc.d/named minor fixes
Date: Mon, 25 Apr 2005 16:13:20 +0200

 Hi,
 
 I manage this to a minor set of diffs against named ver 1.21
 
 Hope this may be acceptable
 
 --
   josemi
 
 --- patch-named begins here ---
 --- /home/josemi/wk/bind/src/etc/rc.d/named	Sun Apr 24 03:51:22 2005
 +++ etc/rc.d/named	Sun Apr 24 21:40:44 2005
 @@ -32,28 +32,30 @@
  {
  	# Create (or update) the chroot directory structure
  	#
 -	if [ -f /etc/mtree/BIND.chroot.dist ]; then
 -		mtree -deU -f /etc/mtree/BIND.chroot.dist \
 +	if [ -f ${named_chroot_mtree:=/etc/mtree/BIND.chroot.dist} ]; then
 +		mtree -deU -f ${named_chroot_mtree} \
  		    -p ${named_chrootdir}
  	else
 -		warn "/etc/mtree/BIND.chroot.dist missing,"
 +		warn "${named_chroot_mtree} missing,"
  		warn "chroot directory structure not updated"
  	fi
  
  	# Create /etc/namedb symlink
  	#
 +	if [ -z "${named_sysconfdir}" ]; then
 +		named_sysconfdir="${named_chroot}/etc/namedb"
 +	fi
  	if [ ! -L /etc/namedb ]; then
  		if [ -d /etc/namedb ]; then
  			warn "named chroot: /etc/namedb is a directory!"
  		elif [ -e /etc/namedb ]; then
  			warn "named chroot: /etc/namedb exists!"
  		else
 -			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
 +			ln -s ${named_sysconfdir} /etc/namedb
  		fi
  	else
  		# Make sure it points to the right place.
 -		ln -shf ${named_chrootdir}/etc/namedb /etc/namedb
 -
 +		ln -shf ${named_sysconfdir} /etc/namedb
  	fi
  
  	# Mount a devfs in the chroot directory if needed
 --- patch-named ends here ---

From: Jose M Rodriguez <josemi@freebsd.jazztel.es>
To: bug-followup@FreeBSD.org, josemi@freebsd.jazztel.es
Cc:  
Subject: Re: conf/74006: [PATCH] /etc/rc.d/named minor fixes
Date: Tue, 3 May 2005 21:48:37 +0200

 Sorry,
 
 -		named_sysconfdir="${named_chroot}/etc/namedb"
 +		named_sysconfdir="${named_chrootdir}/etc/namedb"
 
 --
   josemi
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Mon Oct 22 08:31:38 UTC 2007 
State-Changed-Why:  

I'm sorry to say that I don't really like any of your cosmetic 
changes, and you did not provide any reasoning for your suggestions. 

As for your substantive suggestion of adding a variable for defining 
a different mtree file for the chroot, no one else has suggested this, 
and I don't feel that it would be something that would be widely used, 
so I'm very hesitant to add more complexity to the code. I will keep 
this idea in mind however if need ever does arise. 

In any case, thanks for your suggestions. 

Doug 

(Note: This message to the originator bounced.)


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