From owner-svn-src-all@FreeBSD.ORG  Fri Jan 15 03:03:02 2010
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5CED01065694;
	Fri, 15 Jan 2010 03:03:02 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4999D8FC1A;
	Fri, 15 Jan 2010 03:03:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0F332vv026647;
	Fri, 15 Jan 2010 03:03:02 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0F332Ov026645;
	Fri, 15 Jan 2010 03:03:02 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201001150303.o0F332Ov026645@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Fri, 15 Jan 2010 03:03:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r202331 - stable/8/etc/rc.d
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
	user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 15 Jan 2010 03:03:02 -0000

Author: dougb
Date: Fri Jan 15 03:03:02 2010
New Revision: 202331
URL: http://svn.freebsd.org/changeset/base/202331

Log:
  MFC r201367, r201370:
  Virtualize the location of "the configuration directory" instead of
  hard-coding it to be /etc/namedb

Modified:
  stable/8/etc/rc.d/named
Directory Properties:
  stable/8/etc/   (props changed)

Modified: stable/8/etc/rc.d/named
==============================================================================
--- stable/8/etc/rc.d/named	Fri Jan 15 02:58:22 2010	(r202330)
+++ stable/8/etc/rc.d/named	Fri Jan 15 03:03:02 2010	(r202331)
@@ -43,19 +43,19 @@ chroot_autoupdate()
 		warn "chroot directory structure not updated"
 	fi
 
-	# Create /etc/namedb symlink
+	# Create (or update) the configuration directory 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!"
+	if [ ! -L "${named_conf%/*}" ]; then
+		if [ -d "${named_conf%/*}" ]; then
+			warn "named chroot: ${named_conf%/*} is a directory!"
+		elif [ -e "${named_conf%/*}" ]; then
+			warn "named chroot: ${named_conf%/*} exists!"
 		else
-			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
+			ln -s ${named_confdir} ${named_conf%/*}
 		fi
 	else
 		# Make sure it points to the right place.
-		ln -shf ${named_chrootdir}/etc/namedb /etc/namedb
+		ln -shf ${named_confdir} ${named_conf%/*}
 	fi
 
 	# Mount a devfs in the chroot directory if needed
@@ -179,12 +179,12 @@ named_prestart()
 	# Create an rndc.key file for the user if none exists
 	#
 	confgen_command="${command%/named}/rndc-confgen -a -b256 -u $named_uid \
-	    -c ${named_chrootdir}/etc/namedb/rndc.key"
-	if [ -s "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
+	    -c ${named_confdir}/rndc.key"
+	if [ -s "${named_confdir}/rndc.conf" ]; then
 		unset confgen_command
 	fi
-	if [ -s "${named_chrootdir}/etc/namedb/rndc.key" ]; then
-		case `stat -f%Su ${named_chrootdir}/etc/namedb/rndc.key` in
+	if [ -s "${named_confdir}/rndc.key" ]; then
+		case `stat -f%Su ${named_confdir}/rndc.key` in
 		root|$named_uid) ;;
 		*) $confgen_command ;;
 		esac
@@ -198,8 +198,8 @@ named_prestart()
 			warn "named_auto_forward enabled, but no /etc/resolv.conf"
 
 			# Empty the file in case it is included in named.conf
-			[ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-			    create_file ${named_chrootdir}/etc/namedb/auto_forward.conf
+			[ -s "${named_confdir}/auto_forward.conf" ] &&
+			    create_file ${named_confdir}/auto_forward.conf
 
 			${command%/named}/named-checkconf $named_conf ||
 			    err 3 'named-checkconf for $named_conf failed'
@@ -248,19 +248,19 @@ named_prestart()
 			mv /var/run/naf-resolv.conf /etc/resolv.conf
 		fi
 
-		if cmp -s ${named_chrootdir}/etc/namedb/auto_forward.conf \
+		if cmp -s ${named_confdir}/auto_forward.conf \
 		    /var/run/auto_forward.conf; then
 			unlink /var/run/auto_forward.conf
 		else
-			[ -e "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-			    unlink ${named_chrootdir}/etc/namedb/auto_forward.conf
+			[ -e "${named_confdir}/auto_forward.conf" ] &&
+			    unlink ${named_confdir}/auto_forward.conf
 			mv /var/run/auto_forward.conf \
-			    ${named_chrootdir}/etc/namedb/auto_forward.conf
+			    ${named_confdir}/auto_forward.conf
 		fi
 	else
 		# Empty the file in case it is included in named.conf
-		[ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] &&
-		    create_file ${named_chrootdir}/etc/namedb/auto_forward.conf
+		[ -s "${named_confdir}/auto_forward.conf" ] &&
+		    create_file ${named_confdir}/auto_forward.conf
 	fi
 
 	${command%/named}/named-checkconf $named_conf ||
@@ -274,5 +274,6 @@ load_rc_config $name
 required_dirs="$named_chrootdir"	# if it is set, it must exist
 required_files="${named_conf:=/etc/namedb/named.conf}"
 pidfile="${named_pidfile:-/var/run/named/pid}"
+named_confdir="${named_chrootdir}${named_conf%/*}"
 
 run_rc_command "$1"