Subject: bin/30420: chrooted named does not work out of the box.
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <christos@netbsd.org>
List: netbsd-bugs
Date: 06/03/2005 20:20:00
>Number:         30420
>Category:       bin
>Synopsis:       chrooted named does not work out of the box.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 03 20:20:00 +0000 2005
>Originator:     Christos Zoulas
>Release:        NetBSD 3.99.5
>Organization:
	What day is it today?
>Environment:
System: NetBSD quasar.astron.com 3.99.5 NetBSD 3.99.5 (QUASAR) #3: Sun May 29 16:47:58 EDT 2005 christos@quasar.astron.com:/usr/src/sys/arch/i386/compile/QUASAR i386
Architecture: i386
Machine: i386
>Description:
	It would be nice if adding named=YES named_chrootdir=/var/chroot/named
	worked without user intervention. The named script tries, but it
	does not complete the job.

>How-To-Repeat:
	add named=YES and named_chrootdir=/var/chroot/named in /etc/rc.conf
	and start named on a freshly built system. Look in /var/log/messages.
>Fix:
	This patch copies the skeleton files and makes a symlink to a
	default named.conf (both in the chrooted and non-chrooted case).
	This way named works out of the box.

Index: named
===================================================================
RCS file: /cvsroot/src/etc/rc.d/named,v
retrieving revision 1.15
diff -u -u -r1.15 named
--- named	17 Mar 2005 18:44:09 -0000	1.15
+++ named	3 Jun 2005 20:15:28 -0000
@@ -58,6 +58,19 @@
 		fi
 	done
 
+	if [ -d /etc/namedb ]; then
+		(cd /etc/namedb && for i in *; do
+			j=${named_chrootdir}/etc/namedb/$i
+			if [ ! -r $j ]; then
+				cp -rp $i $j
+			fi
+		done)
+	fi
+	if [ \( ! -r ${named_chrootdir}/etc/named.conf \) -a \
+	    \( -r ${named_chrootdir}/etc/namedb/named.conf \) ]; then
+		ln -s namedb/named.conf ${named_chrootdir}/etc
+	fi
+
 	if [ -f /etc/localtime ]; then
 		cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
 		    cp -p /etc/localtime "${named_chrootdir}/etc/localtime"