Module Name:    src
Committed By:   martin
Date:           Mon Mar 11 17:25:20 UTC 2024

Modified Files:
        src/etc [netbsd-10]: named.conf
        src/external/mpl/bind/dist/lib/isc/netmgr [netbsd-10]: netmgr-int.h
        src/usr.sbin/postinstall [netbsd-10]: postinstall.in

Log Message:
Pull up following revision(s) (requested by christos in ticket #622):

        etc/named.conf: revision 1.11
        usr.sbin/postinstall/postinstall.in: revision 1.59
        external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h: revision 1.11
        usr.sbin/postinstall/postinstall.in: revision 1.60
        usr.sbin/postinstall/postinstall.in: revision 1.61

Make sure that the extra field is maximally aligned since it is used for
other struct storage.
- fix named.conf (remove dnssec-enable option)
- use proper local variables instead of adding _ or other prefixes.
- centralize rm use
- use grep -q instead of > /dev/null
- reduce constant duplication

no local in loops, simplify eval (thanks kre)

postinstall: fix endless loop (since 2024-03-07)

remove obsolete option "dnssec-enable"


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.6.1 src/etc/named.conf
cvs rdiff -u -r1.8.2.1 -r1.8.2.2 \
    src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h
cvs rdiff -u -r1.51.2.2 -r1.51.2.3 src/usr.sbin/postinstall/postinstall.in

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/named.conf
diff -u src/etc/named.conf:1.10 src/etc/named.conf:1.10.6.1
--- src/etc/named.conf:1.10	Sun Oct 11 22:14:55 2020
+++ src/etc/named.conf	Mon Mar 11 17:25:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: named.conf,v 1.10 2020/10/11 22:14:55 jnemeth Exp $
+# $NetBSD: named.conf,v 1.10.6.1 2024/03/11 17:25:20 martin Exp $
 
 # boot file for secondary name server
 # Note that there should be one primary entry for each SOA record.
@@ -10,7 +10,6 @@
 
 options {
 	directory "/etc/namedb";
-	dnssec-enable yes;
 	dnssec-validation auto;
 	managed-keys-directory "keys";
 	bindkeys-file "bind.keys";

Index: src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h
diff -u src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h:1.8.2.1 src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h:1.8.2.2
--- src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h:1.8.2.1	Sun Feb 25 15:47:24 2024
+++ src/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h	Mon Mar 11 17:25:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netmgr-int.h,v 1.8.2.1 2024/02/25 15:47:24 martin Exp $	*/
+/*	$NetBSD: netmgr-int.h,v 1.8.2.2 2024/03/11 17:25:20 martin Exp $	*/
 
 /*
  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -276,7 +276,7 @@ struct isc_nmhandle {
 	LINK(isc_nmhandle_t) active_link;
 #endif
 	void *opaque;
-	char extra[];
+	max_align_t extra[];
 };
 
 typedef enum isc__netievent_type {

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.51.2.2 src/usr.sbin/postinstall/postinstall.in:1.51.2.3
--- src/usr.sbin/postinstall/postinstall.in:1.51.2.2	Sat Feb  3 14:15:00 2024
+++ src/usr.sbin/postinstall/postinstall.in	Mon Mar 11 17:25:20 2024
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.51.2.2 2024/02/03 14:15:00 martin Exp $
+# $NetBSD: postinstall.in,v 1.51.2.3 2024/03/11 17:25:20 martin Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -60,6 +60,7 @@
 : ${SED:=sed}
 : ${SORT:=sort}
 : ${STAT:=stat}
+: ${RM:=rm}
 
 #
 #	helper functions
@@ -67,11 +68,11 @@
 
 err()
 {
-	exitval=$1
+	local exitval=$1
 	shift
 	echo 1>&2 "${PROGNAME}: $*"
 	if [ -n "${SCRATCHDIR}" ]; then
-	    /bin/rm -rf "${SCRATCHDIR}"
+	    ${RM} -rf "${SCRATCHDIR}"
 	fi
 	exit ${exitval}
 }
@@ -92,15 +93,16 @@ mkdtemp()
 	[ -d /tmp ] || err 2 /tmp is not a directory
 	[ -w /tmp ] || err 2 /tmp is not writable
 
-	_base="/tmp/_postinstall.$$"
-	_serial=0
+	local base="/tmp/_postinstall.$$"
+	local serial=0
+	local dir
 
 	while true; do
-		_dir="${_base}.${_serial}"
-		mkdir -m 0700 "${_dir}" && break
-		_serial=$((${_serial} + 1))
+		dir="${base}.${serial}"
+		mkdir -m 0700 "${dir}" && break
+		serial=$((${serial} + 1))
 	done
-	echo "${_dir}"
+	echo "${dir}"
 }
 
 # Quote args to make them safe in the shell.
@@ -131,7 +133,7 @@ shell_quote()
 			# '\'''\'' sequences that result from multiple
 			# adjacent quotes in he input.
 			qarg="$(printf "%s\n" "$arg" | \
-			    ${SED:-sed} -e "s/'/'\\\\''/g" \
+			    ${SED} -e "s/'/'\\\\''/g" \
 				-e "1s/^/'/" -e "\$s/\$/'/" \
 				-e "1s/^''//" -e "\$s/''\$//" \
 				-e "s/'''/'/g"
@@ -206,18 +208,18 @@ adddisableditem()
 check_dir()
 {
 	[ $# -eq 3 ] || err 3 "USAGE: check_dir op dir mode"
-	_cdop="$1"
-	_cddir="$2"
-	_cdmode="$3"
-	[ -d "${_cddir}" ] && return 0
-	if [ "${_cdop}" = "check" ]; then
-		msg "${_cddir} is not a directory"
+	local op="$1"
+	local dir="$2"
+	local mode="$3"
+	[ -d "${dir}" ] && return 0
+	if [ "${op}" = "check" ]; then
+		msg "${dir} is not a directory"
 		return 1
-	elif ! mkdir -m "${_cdmode}" "${_cddir}" ; then
-		msg "Can't create missing ${_cddir}"
+	elif ! mkdir -m "${mode}" "${dir}" ; then
+		msg "Can't create missing ${dir}"
 		return 1
 	else
-		msg "Missing ${_cddir} created"
+		msg "Missing ${dir} created"
 	fi
 	return 0
 }
@@ -234,27 +236,27 @@ check_dir()
 check_ids()
 {
 	[ $# -ge 6 ] || err 3 "USAGE: checks_ids op type file start srcfile id ..."
-	_op="$1"
-	_type="$2"
-	_file="$3"
-	_srcfile="$4"
-	_start="$5"
+	local op="$1"
+	local type="$2"
+	local file="$3"
+	local srcfile="$4"
+	local start="$5"
 	shift 5
-	#_ids="$@"
+	#local ids="$@"
 
-	if [ ! -f "${_file}" ]; then
-		msg "${_file} doesn't exist; can't check for missing ${_type}"
+	if [ ! -f "${file}" ]; then
+		msg "${file} doesn't exist; can't check for missing ${type}"
 		return 1
 	fi
-	if [ ! -r "${_file}" ]; then
-		msg "${_file} is not readable; can't check for missing ${_type}"
+	if [ ! -r "${file}" ]; then
+		msg "${file} is not readable; can't check for missing ${type}"
 		return 1
 	fi
-	_notfixed=""
-	if [ "${_op}" = "fix" ]; then
-		_notfixed="${NOT_FIXED}"
+	local notfixed=""
+	if [ "${op}" = "fix" ]; then
+		notfixed="${NOT_FIXED}"
 	fi
-	_missing="$(${AWK} -v start=$_start -F: '
+	local missing="$(${AWK} -v start=$start -F: '
 		BEGIN {
 			for (x = 1; x < ARGC; x++) {
 				if (ARGV[x] == "SKIP")
@@ -278,14 +280,14 @@ check_ids()
 				start++;
 			}
 		}
-	' "$@" < "${_file}")"	|| return 1
-	if [ -n "${_missing}" ]; then
-		msg "Error ${_type}${_notfixed}:" $(echo ${_missing})
+	' "$@" < "${file}")"	|| return 1
+	if [ -n "${missing}" ]; then
+		msg "Error ${type}${notfixed}:" $(echo ${missing})
 		msg "Use the following as a template:"
-		set -- ${_missing}
+		set -- ${missing}
 		while [ $# -gt 0 ]
 		do
-			${GREP} -E "^${1}:" ${_srcfile}
+			${GREP} -E "^${1}:" ${srcfile}
 			shift 2
 		done | sort -t: -k3n
 		msg "and adjust if necessary."
@@ -294,8 +296,8 @@ check_ids()
 	return 0
 }
 
-# populate_dir op onlynew src dest mode file ...
-#	Perform op ("check" or "fix") on files in src/ against dest/
+# populate_dir op onlynew src dst mode file ...
+#	Perform op ("check" or "fix") on files in src/ against dst/
 #	If op = "check" display missing or changed files, optionally with diffs.
 #	If op != "check" copies any missing or changed files.
 #	If onlynew evaluates to true, changed files are ignored.
@@ -303,96 +305,97 @@ check_ids()
 #
 populate_dir()
 {
-	[ $# -ge 5 ] || err 3 "USAGE: populate_dir op onlynew src dest mode file ..."
-	_op="$1"
-	_onlynew="$2"
-	_src="$3"
-	_dest="$4"
-	_mode="$5"
+	[ $# -ge 5 ] || err 3 "USAGE: populate_dir op onlynew src dst mode file ..."
+	local op="$1"
+	local onlynew="$2"
+	local src="$3"
+	local dst="$4"
+	local mode="$5"
 	shift 5
-	#_files="$@"
+	#local files="$@"
 
-	if [ ! -d "${_src}" ]; then
-		msg "${_src} is not a directory; skipping check"
+	if [ ! -d "${src}" ]; then
+		msg "${src} is not a directory; skipping check"
 		return 1
 	fi
-	check_dir "${_op}" "${_dest}" 755 || return 1
+	check_dir "${op}" "${dst}" 755 || return 1
 
-	_cmpdir_rv=0
+	local cmpdir_rv=0
+	local f fs fd error
 	for f in "$@"; do
-		fs="${_src}/${f}"
-		fd="${_dest}/${f}"
-		_error=""
+		fs="${src}/${f}"
+		fd="${dst}/${f}"
+		error=""
 		if [ ! -f "${fd}" ]; then
-			_error="${fd} does not exist"
+			error="${fd} does not exist"
 		elif ! cmp -s "${fs}" "${fd}" ; then
-			if $_onlynew; then	# leave existing ${fd} alone
+			if $onlynew; then	# leave existing ${fd} alone
 				continue;
 			fi
-			_error="${fs} != ${fd}"
+			error="${fs} != ${fd}"
 		else
 			continue
 		fi
-		if [ "${_op}" = "check" ]; then
-			msg "${_error}"
+		if [ "${op}" = "check" ]; then
+			msg "${error}"
 			if [ -n "${DIFF_STYLE}" -a -f "${fd}" ]; then
 				diff -${DIFF_STYLE} ${DIFF_OPT} "${fd}" "${fs}"
 			fi
-			_cmpdir_rv=1
-		elif ! rm -f "${fd}" ||
+			cmpdir_rv=1
+		elif ! ${RM} -f "${fd}" ||
 		     ! cp -f "${fs}" "${fd}"; then
 			msg "Can't copy ${fs} to ${fd}"
-			_cmpdir_rv=1
-		elif ! chmod "${_mode}" "${fd}"; then
-			msg "Can't change mode of ${fd} to ${_mode}"
-			_cmpdir_rv=1
+			cmpdir_rv=1
+		elif ! chmod "${mode}" "${fd}"; then
+			msg "Can't change mode of ${fd} to ${mode}"
+			cmpdir_rv=1
 		else
 			msg "Copied ${fs} to ${fd}"
 		fi
 	done
-	return ${_cmpdir_rv}
+	return ${cmpdir_rv}
 }
 
-# compare_dir op src dest mode file ...
-#	Perform op ("check" or "fix") on files in src/ against dest/
+# compare_dir op src dst mode file ...
+#	Perform op ("check" or "fix") on files in src/ against dst/
 #	If op = "check" display missing or changed files, optionally with diffs.
 #	If op != "check" copies any missing or changed files.
 #	Returns 0 if ok, 1 otherwise.
 #
 compare_dir()
 {
-	[ $# -ge 4 ] || err 3 "USAGE: compare_dir op src dest mode file ..."
-	_op="$1"
-	_src="$2"
-	_dest="$3"
-	_mode="$4"
+	[ $# -ge 4 ] || err 3 "USAGE: compare_dir op src dst mode file ..."
+	local op="$1"
+	local src="$2"
+	local dst="$3"
+	local mode="$4"
 	shift 4
-	#_files="$@"
+	#local files="$@"
 
-	populate_dir "$_op" false "$_src" "$_dest" "$_mode" "$@"
+	populate_dir "$op" false "$src" "$dst" "$mode" "$@"
 }
 
-# move_file op src dest --
-#	Check (op == "check") or move (op != "check") from src to dest.
+# move_file op src dst --
+#	Check (op == "check") or move (op != "check") from src to dst.
 #	Returns 0 if ok, 1 otherwise.
 #
 move_file()
 {
-	[ $# -eq 3 ] || err 3 "USAGE: move_file op src dest"
-	_fm_op="$1"
-	_fm_src="$2"
-	_fm_dest="$3"
-
-	if [ -f "${_fm_src}" -a ! -f "${_fm_dest}" ]; then
-		if [ "${_fm_op}" = "check" ]; then
-			msg "Move ${_fm_src} to ${_fm_dest}"
+	[ $# -eq 3 ] || err 3 "USAGE: move_file op src dst"
+	local op="$1"
+	local src="$2"
+	local dst="$3"
+
+	if [ -f "${src}" -a ! -f "${dst}" ]; then
+		if [ "${op}" = "check" ]; then
+			msg "Move ${src} to ${dst}"
 			return 1
 		fi
-		if ! mv "${_fm_src}" "${_fm_dest}"; then
-			msg "Can't move ${_fm_src} to ${_fm_dest}"
+		if ! mv "${src}" "${dst}"; then
+			msg "Can't move ${src} to ${dst}"
 			return 1
 		fi
-		msg "Moved ${_fm_src} to ${_fm_dest}"
+		msg "Moved ${src} to ${dst}"
 	fi
 	return 0
 }
@@ -406,26 +409,25 @@ move_file()
 rcconf_is_set()
 {
 	[ $# -ge 3 ] || err 3 "USAGE: rcconf_is_set op name var [verbose]"
-	_rcis_op="$1"
-	_rcis_name="$2"
-	_rcis_var="$3"
-	_rcis_verbose="$4"
-	_rcis_notfixed=""
-	if [ "${_rcis_op}" = "fix" ]; then
-		_rcis_notfixed="${NOT_FIXED}"
+	local op="$1"
+	local name="$2"
+	local var="$3"
+	local verbose="$4"
+	local notfixed=""
+	if [ "${op}" = "fix" ]; then
+		notfixed="${NOT_FIXED}"
 	fi
 	(
 		for f in \
 		    "${DEST_DIR}/etc/rc.conf" \
-		    "${DEST_DIR}/etc/rc.conf.d/${_rcis_name}"; do
+		    "${DEST_DIR}/etc/rc.conf.d/${name}"; do
 			[ -f "${f}" ] && . "${f}"
 		done
-		eval echo -n \"\${${_rcis_var}}\" 1>&3
-		if eval "[ -n \"\${${_rcis_var}}\" \
-			    -o \"\${${_rcis_var}-UNSET}\" != \"UNSET\" ]"; then
-			if [ -n "${_rcis_verbose}" ]; then
+		eval echo -n \"\${${var}}\" 1>&3
+		if eval "[ -n \"\${${var}+SET}\" ]"; then
+			if [ -n "${verbose}" ]; then
 				msg \
-    "Obsolete rc.conf(5) variable '\$${_rcis_var}' found.${_rcis_notfixed}"
+    "Obsolete rc.conf(5) variable '\$${var}' found.${notfixed}"
 			fi
 			exit 0
 		else
@@ -440,11 +442,11 @@ rcconf_is_set()
 rcvar_is_enabled()
 {
 	[ $# -eq 1 ] || err 3 "USAGE: rcvar_is_enabled var"
-	_rcie_var="$1"
+	local var="$1"
 	(
 		[ -f "${DEST_DIR}/etc/rc.conf" ] && . "${DEST_DIR}/etc/rc.conf"
-		eval _rcie_val=\"\${${_rcie_var}}\"
-		case $_rcie_val in
+		eval val=\"\${${var}}\"
+		case $val in
 		#	"yes", "true", "on", or "1"
 		[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
 			exit 0
@@ -468,20 +470,21 @@ find_file_in_dirlist()
 {
 	[ $# -ge 3 ] || err 3 "USAGE: find_file_in_dirlist file msg dir1 ..."
 
-	_file="$1" ; shift
-	_msg="$1" ; shift
-	_dir1st=	# first dir in list
+	local file="$1" ; shift
+	local msg="$1" ; shift
+	local dir1st=	# first dir in list
+	# returns dir
 	for dir in "$@"; do
-		: ${_dir1st:="${dir}"}
-		if [ -f "${dir}/${_file}" ]; then
-			if [ "${_dir1st}" != "${dir}" ]; then
+		: ${dir1st:="${dir}"}
+		if [ -f "${dir}/${file}" ]; then
+			if [ "${dir1st}" != "${dir}" ]; then
 				msg \
-    "(Checking for ${_msg} from ${dir} instead of ${_dir1st})"
+    "(Checking for ${msg} from ${dir} instead of ${dir1st})"
 			fi
 			return 0
 		fi
 	done
-	msg "Can't find source directory for ${_msg}"
+	msg "Can't find source directory for ${msg}"
 	return 1
 }
 
@@ -496,16 +499,16 @@ find_file_in_dirlist()
 file_exists_exact()
 {
 	[ -n "$1" ] || err 3 "USAGE: file_exists_exact path"
-	_path="${1#.}"
-	[ -h "${DEST_DIR}${_path}" ] || \
-		[ -e "${DEST_DIR}${_path}" ] || return 1
-	while [ "${_path}" != "/" -a "${_path}" != "." ] ; do
-		_dirname="$(dirname "${_path}" 2>/dev/null)"
-		_basename="$(basename "${_path}" 2>/dev/null)"
-		ls -fa "${DEST_DIR}${_dirname}" 2> /dev/null \
-			| ${GREP} -F -x "${_basename}" >/dev/null \
+	local path="${1#.}"
+	[ -h "${DEST_DIR}${path}" ] || \
+		[ -e "${DEST_DIR}${path}" ] || return 1
+	while [ "${path}" != "/" -a "${path}" != "." ] ; do
+		local dirname="$(dirname "${path}" 2>/dev/null)"
+		local basename="$(basename "${path}" 2>/dev/null)"
+		ls -fa "${DEST_DIR}${dirname}" 2> /dev/null \
+			| ${GREP} -q -F -x "${basename}" \
 			|| return 1
-		_path="${_dirname}"
+		path="${dirname}"
 	done
 	return 0
 }
@@ -518,15 +521,16 @@ file_exists_exact()
 obsolete_paths()
 {
 	[ -n "$1" ] || err 3 "USAGE: obsolete_paths fix|check"
-	op="$1"
+	local op="$1"
+	local failed=0
+	local ofile cmd ftype
 
-	failed=0
 	while read ofile; do
 		if ! ${file_exists_exact} "${ofile}"; then
 			continue
 		fi
 		ofile="${DEST_DIR}${ofile#.}"
-		cmd="rm"
+		cmd="${RM}"
 		ftype="file"
 		if [ -h "${ofile}" ]; then
 			ftype="link"
@@ -560,7 +564,7 @@ obsolete_paths()
 obsolete_libs()
 {
 	[ $# -eq 1 ] || err 3 "USAGE: obsolete_libs dir"
-	dir="$1"
+	local dir="$1"
 
 	_obsolete_libs "${dir}"
 	_obsolete_libs "/usr/libdata/debug/${dir}"
@@ -600,7 +604,7 @@ exclude_libs()
 
 _obsolete_libs()
 {
-	dir="$1"
+	local dir="$1"
 
 	(
 
@@ -698,30 +702,31 @@ modify_file()
 {
 	[ $# -eq 4 ] || err 3 "USAGE: modify_file op file scratch awkprog"
 
-	_mfop="$1"
-	_mffile="$2"
-	_mfscratch="$3"
-	_mfprog="$4"
-	_mffailed=0
-
-	${AWK} "${_mfprog}" < "${_mffile}" > "${_mfscratch}"
-	if ! cmp -s "${_mffile}" "${_mfscratch}"; then
-		diff "${_mffile}" "${_mfscratch}" > "${_mfscratch}.diffs"
-		if [ "${_mfop}" = "check" ]; then
-			msg "${_mffile} needs the following changes:"
-			_mffailed=1
-		elif ! rm -f "${_mffile}" ||
-		     ! cp -f "${_mfscratch}" "${_mffile}"; then
-			msg "${_mffile} changes not applied:"
-			_mffailed=1
+	local op="$1"
+	local file="$2"
+	local scratch="$3"
+	local prog="$4"
+	local failed=0
+	local line
+
+	${AWK} "${prog}" < "${file}" > "${scratch}"
+	if ! cmp -s "${file}" "${scratch}"; then
+		diff "${file}" "${scratch}" > "${scratch}.diffs"
+		if [ "${op}" = "check" ]; then
+			msg "${file} needs the following changes:"
+			mffailed=1
+		elif ! ${RM} -f "${file}" ||
+		     ! cp -f "${scratch}" "${file}"; then
+			msg "${file} changes not applied:"
+			mffailed=1
 		else
-			msg "${_mffile} changes applied:"
+			msg "${file} changes applied:"
 		fi
-		while read _line; do
-			msg "	${_line}"
-		done < "${_mfscratch}.diffs"
+		while read line; do
+			msg "	${line}"
+		done < "${scratch}.diffs"
 	fi
-	return ${_mffailed}
+	return ${failed}
 }
 
 
@@ -733,26 +738,27 @@ contents_owner()
 {
 	[ $# -eq 4 ] || err 3 "USAGE: contents_owner op dir user group"
 
-	_op="$1"
-	_dir="$2"
-	_user="$3"
-	_grp="$4"
-
-	if [ "${_op}" = "check" ]; then
-		_files=$(find "${_dir}" \( \( ! -user "${_user}" \) -o \
-		                \( ! -group "${_grp}" \) \) )
-		_error=$?
-		if [ ! -z "$_files" ] || [ $_error != 0 ]; then
-			msg "${_dir} and contents not all owned by" \
-			    "${_user}:${_grp}"
+	local op="$1"
+	local dir="$2"
+	local user="$3"
+	local grp="$4"
+	local files error
+
+	if [ "${op}" = "check" ]; then
+		files=$(find "${dir}" \( \( ! -user "${user}" \) -o \
+		                \( ! -group "${grp}" \) \) )
+		error=$?
+		if [ ! -z "$files" ] || [ $error != 0 ]; then
+			msg "${dir} and contents not all owned by" \
+			    "${user}:${grp}"
 			return 1
 		else
 			return 0
 		fi
-	elif [ "${_op}" = "fix" ]; then
-		find "${_dir}" \( \( ! -user "${_user}" \) -o \
-		\( ! -group "${_grp}" \) \) \
-		-exec chown "${_user}:${_grp}" -- {} \;
+	elif [ "${op}" = "fix" ]; then
+		find "${dir}" \( \( ! -user "${user}" \) -o \
+		\( ! -group "${grp}" \) \) \
+		-exec chown "${user}:${grp}" -- {} \;
 	fi
 }
 
@@ -760,14 +766,15 @@ contents_owner()
 #	Retrieve the value of a user-settable system make variable
 get_makevar()
 {
+	local var value
 	$SOURCEMODE || err 3 "get_makevar must be used in source mode"
 	[ $# -eq 0 ] && err 3 "USAGE: get_makevar var ..."
 
-	for _var in "$@"; do
-		_value="$(echo '.include <bsd.own.mk>' | \
-		    ${MAKE} -f - -V "\${${_var}}")"
+	for var in "$@"; do
+		value="$(echo '.include <bsd.own.mk>' | \
+		    ${MAKE} -f - -V "\${${var}}")"
 
-		eval ${_var}=\"\${_value}\"
+		eval ${var}=\"\${value}\"
 	done
 }
 
@@ -819,22 +826,25 @@ find_makedev()
 handle_atf_user()
 {
 	local op="$1"
+	local conf="$2"
+	local option="unprivileged-user"
+	local old="_atf"
+	local new="_tests"
 	local failed=0
 
-	local conf="${DEST_DIR}/etc/atf/common.conf"
-	if grep '[^#]*unprivileged-user[ \t]*=.*_atf' "${conf}" >/dev/null
+	local c=$(readlink -f "${conf}")
+	if ${GREP} -q "[^#]*${option}[ \t]*=.*${old}" "${c}"
 	then
-		if [ "$1" = "fix" ]; then
-			${SED} -e \
-			    "/[^#]*unprivileged-user[\ t]*=/s/_atf/_tests/" \
-			    "${conf}" >"${conf}.new"
+		if [ "${op}" = "fix" ]; then
+			${SED} -e "/[^#]*${option}[\ t]*=/s/${old}/${new}/" \
+			    "${c}" >"${c}.new"
 			failed=$(( ${failed} + $? ))
-			mv "${conf}.new" "${conf}"
+			mv "${c}.new" "${c}"
 			failed=$(( ${failed} + $? ))
-			msg "Set unprivileged-user=_tests in ${conf}"
+			msg "Set ${option}=${new} in ${c}"
 		else
-			msg "unprivileged-user=_atf in ${conf} should be" \
-			    "unprivileged-user=_tests"
+			msg "${option}=${old} in ${c} should be " \
+			    "${option}=${new}"
 			failed=1
 		fi
 	fi
@@ -846,15 +856,17 @@ additem atf "install missing atf configu
 do_atf()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_atf fix|check"
-	op="$1"
-	failed=0
+	local conf="${DEST_DIR}/etc/atf/common.conf"
+	local atfdir="${DEST_DIR}/etc/atf"
+	local op="$1"
+	local failed=0
 
 	# Ensure atf configuration files are in place.
 	if find_file_in_dirlist NetBSD.conf "NetBSD.conf" \
 	    "${SRC_DIR}/external/bsd/atf/etc/atf" \
 	    "${SRC_DIR}/etc/atf"; then
-			# ${dir} is set by find_file_in_dirlist()
-		populate_dir "${op}" true "${dir}" "${DEST_DIR}/etc/atf" 644 \
+		    # ${dir} is set by find_file_in_dirlist()
+		    populate_dir "${op}" true "${dir}" "${atfdir}" 644 \
 		    NetBSD.conf common.conf || failed=1
 	else
 		failed=1
@@ -862,16 +874,16 @@ do_atf()
 	if find_file_in_dirlist atf-run.hooks "atf-run.hooks" \
 	    "${SRC_DIR}/external/bsd/atf/dist/tools/sample" \
 	    "${SRC_DIR}/etc/atf"; then
-			# ${dir} is set by find_file_in_dirlist()
-		populate_dir "${op}" true "${dir}" "${DEST_DIR}/etc/atf" 644 \
+		# ${dir} is set by find_file_in_dirlist()
+		populate_dir "${op}" true "${dir}" "${atfdir}" 644 \
 		    atf-run.hooks || failed=1
 	else
 		failed=1
 	fi
 
 	# Validate the _atf to _tests user/group renaming.
-	if [ -f "${DEST_DIR}/etc/atf/common.conf" ]; then
-		handle_atf_user "${op}" || failed=1
+	if [ -f "${conf}" ]; then
+		handle_atf_user "${op}" "${conf}" || failed=1
 	else
 		failed=1
 	fi
@@ -896,8 +908,9 @@ special_media
 special_noauto
 special_null
 "
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
+
 	if [ "$op" = "fix" ]; then
 		mkdir -p "${DEST_DIR}/etc/autofs"
 	fi
@@ -950,10 +963,11 @@ do_blocklist()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_blocklist fix|check"
 	local op="$1"
+	local i old
 
 	# if we are actually using blocklistd
 	for i in /var/db/blacklist.db /etc/blacklistd.conf; do
-		local old="${DEST_DIR}${i}"
+		old="${DEST_DIR}${i}"
 		if [ ! -f "${old}" ]; then
 			continue
 		elif [ "$1" = "check" ]; then
@@ -979,8 +993,8 @@ additem bluetooth "Bluetooth configurati
 do_bluetooth()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_bluetooth fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	populate_dir "${op}" true \
 		"${SRC_DIR}/etc/bluetooth" "${DEST_DIR}/etc/bluetooth" 644 \
@@ -991,7 +1005,7 @@ do_bluetooth()
 			"${DEST_DIR}/var/db/btdevctl.plist"
 	failed=$(( ${failed} + $? ))
 
-	notfixed=""
+	local notfixed=""
 	if [ "${op}" = "fix" ]; then
 		notfixed="${NOT_FIXED}"
 	fi
@@ -1013,14 +1027,15 @@ do_bluetooth()
 
 obsolete_catpages()
 {
-	basedir="$2"
-	section="$3"
-	mandir="${basedir}/man${section}"
-	catdir="${basedir}/cat${section}"
+	local op="$1"
+	local basedir="$2"
+	local section="$3"
+	local mandir="${basedir}/man${section}"
+	local catdir="${basedir}/cat${section}"
 	test -d "$mandir" || return 0
 	test -d "$catdir" || return 0
 	(cd "$mandir" && find . -type f) | {
-	failed=0
+	local failed=0
 	while read manpage; do
 		manpage="${manpage#./}"
 		case "$manpage" in
@@ -1035,8 +1050,8 @@ obsolete_catpages()
 			;;
 		esac
 		test -e "$catname" -a "$catname" -ot "$mandir/$manpage" || continue
-		if [ "$1" = "fix" ]; then
-			rm "$catname"
+		if [ "${op}" = "fix" ]; then
+			${RM} "$catname"
 			failed=$(( ${failed} + $? ))
 			msg "Removed obsolete cat page $catname"
 		else
@@ -1051,12 +1066,14 @@ obsolete_catpages()
 additem catpages "remove outdated cat pages"
 do_catpages()
 {
-	failed=0
+	local op="$1"
+	local failed=0
+	local manbase sec
 	for manbase in /usr/share/man /usr/X11R6/man /usr/X11R7/man; do
 		for sec in 1 2 3 4 5 6 7 8 9; do
 			obsolete_catpages "$1" "${DEST_DIR}${manbase}" "${sec}"
 			failed=$(( ${failed} + $? ))
-			if [ "$1" = "fix" ]; then
+			if [ "${op}" = "fix" ]; then
 				rmdir "${DEST_DIR}${manbase}/cat${sec}"/* \
 					2>/dev/null
 				rmdir "${DEST_DIR}${manbase}/cat${sec}" \
@@ -1164,8 +1181,8 @@ additem dhcpcd "dhcpcd configuration is 
 do_dhcpcd()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_dhcpcd fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	find_file_in_dirlist dhcpcd.conf "dhcpcd.conf" \
 	    "${SRC_DIR}/external/bsd/dhcpcd/dist/src" \
@@ -1247,14 +1264,14 @@ additem dhcpcdrundir "accidentally creat
 do_dhcpcdrundir()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_dhcpcdrundir fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	if [ -d "${DEST_DIR}/@RUNDIR@" ]; then
 		if [ "${op}" = "check" ]; then
 			msg "Remove erroneously created /@RUNDIR@"
 			failed=1
-		elif ! rm -r "${DEST_DIR}/@RUNDIR@"; then
+		elif ! ${RM} -r "${DEST_DIR}/@RUNDIR@"; then
 			msg "Failed to remove ${DEST_DIR}/@RUNDIR@"
 			failed=1
 		else
@@ -1302,8 +1319,8 @@ additem fontconfig "X11 font configurati
 do_fontconfig()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_fontconfig fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	# First, check for updates we can handle.
 	if ! $SOURCEMODE; then
@@ -1367,7 +1384,7 @@ do_fontconfig()
 	# We can't modify conf.d easily; someone might have removed a file.
 
 	# Look for old files that need to be deleted.
-	obsolete_fonts="
+	local obsolete_fonts="
 10-autohint.conf
 10-no-sub-pixel.conf
 10-sub-pixel-bgr.conf
@@ -1380,7 +1397,7 @@ do_fontconfig()
 70-no-bitmaps.conf
 70-yes-bitmaps.conf
 "
-	failed_fonts=""
+	local failed_fonts=""
 	for i in ${obsolete_fonts}; do
 	    if [ -f "${DEST_DIR}/etc/fonts/conf.d/$i" ]; then
 		    conf_d_failed=1
@@ -1424,8 +1441,8 @@ additem gpio "gpio configuration is up t
 do_gpio()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_gpio fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	populate_dir "$op" true "${SRC_DIR}/etc" "${DEST_DIR}/etc" 644 \
 		gpio.conf
@@ -1480,9 +1497,9 @@ adddisableditem mailerconf "update /etc/
 do_mailerconf()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_mailterconf fix|check"
-	op="$1"
+	local op="$1"
 
-	failed=0
+	local failed=0
 	mta_path="$(${AWK} '/^sendmail[ \t]/{print$2}' \
 		"${DEST_DIR}/etc/mailer.conf")"
 	old_sendmail_path="/usr/libexec/sendmail/sendmail"
@@ -1509,7 +1526,7 @@ additem makedev "/dev/MAKEDEV being up t
 do_makedev()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_makedev fix|check"
-	failed=0
+	local failed=0
 
 	if [ -f "${SRC_DIR}/etc/MAKEDEV.tmpl" ]; then
 			# generate MAKEDEV from source if source is available
@@ -1547,8 +1564,8 @@ additem manconf "check for a mandoc usag
 do_manconf()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_manconf fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	[ -f "${DEST_DIR}/etc/man.conf" ] || return 0
 	if ${GREP} -w "mandoc" "${DEST_DIR}/etc/man.conf" >/dev/null 2>&1;
@@ -1601,7 +1618,7 @@ do_motd()
 			result=0
 		fi
 
-		rm -f "${tmp1}" "${tmp2}"
+		${RM} -f "${tmp1}" "${tmp2}"
 	else
 		result=0
 	fi
@@ -1618,7 +1635,7 @@ additem mtree "/etc/mtree/ being up to d
 do_mtree()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_mtree fix|check"
-	failed=0
+	local failed=0
 
 	compare_dir "$1" "${SRC_DIR}/etc/mtree" "${DEST_DIR}/etc/mtree" 444 special
 	failed=$(( ${failed} + $? ))
@@ -1626,13 +1643,13 @@ do_mtree()
 	if ! $SOURCEMODE; then
 		MTREE_DIR="${SRC_DIR}/etc/mtree"
 	else
-		/bin/rm -rf "${SCRATCHDIR}/obj"
+		${RM} -rf "${SCRATCHDIR}/obj"
 		mkdir "${SCRATCHDIR}/obj"
 		${MAKE} -s -C "${SRC_DIR}/etc/mtree" TOOL_AWK="${AWK}" \
 		    MAKEOBJDIR="${SCRATCHDIR}/obj" emit_dist_file > \
 		    "${SCRATCHDIR}/NetBSD.dist"
 		MTREE_DIR="${SCRATCHDIR}"
-		/bin/rm -rf "${SCRATCHDIR}/obj"
+		${RM} -rf "${SCRATCHDIR}/obj"
 	fi
 	compare_dir "$1" "${MTREE_DIR}" "${DEST_DIR}/etc/mtree" 444 NetBSD.dist
 	failed=$(( ${failed} + $? ))
@@ -1644,16 +1661,47 @@ do_mtree()
 #
 #	named
 #
+handle_named_conf()
+{
+	local op="$1"
+	local option="dnssec-enable"
+	local failed=0
+	local conf
+
+	shift
+
+	for conf; do
+		local c=$(readlink -f "${conf}")
+		if ! ${GREP} -qs "${option}" "${c}"
+		then
+			continue
+		fi
+
+		if [ "${op}" = "fix" ]; then
+			${SED} -e "/${option}/d" "${c}" > "${c}.new"
+			failed=$(( ${failed} + $? ))
+			mv "${c}.new" "${c}"
+			failed=$(( ${failed} + $? ))
+			msg "Removed obsolete '${option}' in ${c}"
+		else
+			msg "'${option}' option in ${c} should be removed"
+			failed=$(( ${failed} + 1 ))
+		fi
+	done
+
+	return ${failed}
+}
 
 additem named "named configuration update"
 do_named()
 {
+	local oldconf="${DEST_DIR}/etc/namedb/named.conf"
+	local conf="${DEST_DIR}/etc/named.conf"
 	[ -n "$1" ] || err 3 "USAGE: do_named fix|check"
-	op="$1"
+	local op="$1"
 
-	move_file "${op}" \
-		"${DEST_DIR}/etc/namedb/named.conf" \
-		"${DEST_DIR}/etc/named.conf"
+	move_file "${op}" "${oldconf}" "${conf}"
+	handle_named_conf "${op}" "${oldconf}" "${conf}"
 
 	compare_dir "${op}" "${SRC_DIR}/etc/namedb" "${DEST_DIR}/etc/namedb" \
 		644 \
@@ -1800,8 +1848,8 @@ additem pam "/etc/pam.d is populated"
 do_pam()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_pam fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	populate_dir "${op}" true "${SRC_DIR}/etc/pam.d" \
 		"${DEST_DIR}/etc/pam.d" 644 \
@@ -1837,8 +1885,8 @@ additem pf "pf configuration being up to
 do_pf()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_pf fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	find_file_in_dirlist pf.os "pf.os" \
 	    "${SRC_DIR}/dist/pf/etc" "${SRC_DIR}/etc" \
@@ -1864,10 +1912,10 @@ additem ptyfsoldnodes "remove legacy dev
 do_ptyfsoldnodes()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_ptyfsoldnodes fix|check"
-	_ptyfs_op="$1"
+	local op="$1"
 
 	# Check whether ptyfs is in use
-	failed=0;
+	local failed=0;
 	if ! ${GREP} -E "^ptyfs" "${DEST_DIR}/etc/fstab" > /dev/null; then
 		msg "ptyfs is not in use"
 		return 0
@@ -1888,6 +1936,7 @@ do_ptyfsoldnodes()
 	# Output from awk, used in the eval statement, looks like this:
 	# maj_ptym=6; maj_ptys=5;
 	#
+	local maj_ptym maj_ptys
 	find_makedev
 	eval "$(
 	    ${HOST_SH} "${MAKEDEV_DIR}/MAKEDEV" -s pty0 2>/dev/null \
@@ -1918,7 +1967,9 @@ do_ptyfsoldnodes()
 	#    stat: /dev/[pt]tyx?: lstat: No such file or directory
 	# and we ignore it.  XXX: We also ignore other error messages.
 	#
-	_ptyfs_tmp="$(mktemp /tmp/postinstall.ptyfs.XXXXXXXX)"
+	local d1 major node
+	local tmp="$(mktemp /tmp/postinstall.ptyfs.XXXXXXXX)"
+
 	for d1 in p q r s t u v w x y z P Q R S T; do
 		${STAT} -f "%Hr %N" "${DEST_DIR}/dev/"[pt]ty${d1}? 2>&1
 	done \
@@ -1926,23 +1977,23 @@ do_ptyfsoldnodes()
 		case "$major" in
 		${maj_ptym}|${maj_ptys}) echo "$node" ;;
 		esac
-	done >"${_ptyfs_tmp}"
+	done > "${tmp}"
 
-	_desc="legacy device node"
+	local desc="legacy device node"
 	while read node; do
-		if [ "${_ptyfs_op}" = "check" ]; then
-			msg "Remove ${_desc} ${node}"
+		if [ "${op}" = "check" ]; then
+			msg "Remove ${desc} ${node}"
 			failed=1
 		else # "fix"
-			if rm "${node}"; then
-				msg "Removed ${_desc} ${node}"
+			if ${RM} "${node}"; then
+				msg "Removed ${desc} ${node}"
 			else
-				warn "Failed to remove ${_desc} ${node}"
+				warn "Failed to remove ${desc} ${node}"
 				failed=1
 			fi
 		fi
-	done < "${_ptyfs_tmp}"
-	rm "${_ptyfs_tmp}"
+	done < "${tmp}"
+	${RM} "${tmp}"
 
 	return ${failed}
 }
@@ -1956,8 +2007,8 @@ additem pwd_mkdb "passwd database versio
 do_pwd_mkdb()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_pwd_mkdb fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
 	# XXX Ideally, we should figure out the endianness of the
 	# target machine, and add "-E B"/"-E L" to the db(1) flags,
@@ -2125,8 +2176,8 @@ do_rc()
 		${extra_scripts}
 	failed=$(( ${failed} + $? ))
 
+	local i rc_file
 	for i in ${rc_external_files}; do
-	    local rc_file
 	    case $i in
 	    *d) rc_file=${i};;
 	    *)	rc_file=${i}d;;
@@ -2214,11 +2265,11 @@ additem ssh "ssh configuration update"
 do_ssh()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_ssh fix|check"
-	op="$1"
+	local op="$1"
 
-	failed=0
-	_etcssh="${DEST_DIR}/etc/ssh"
-	if ! check_dir "${op}" "${_etcssh}" 755; then
+	local failed=0
+	local etcssh="${DEST_DIR}/etc/ssh"
+	if ! check_dir "${op}" "${etcssh}" 755; then
 		failed=1
 	fi
 
@@ -2230,7 +2281,7 @@ do_ssh()
 			    ssh_host_key ssh_host_key.pub \
 		    ; do
 			if ! move_file "${op}" \
-			    "${DEST_DIR}/etc/${f}" "${_etcssh}/${f}" ; then
+			    "${DEST_DIR}/etc/${f}" "${etcssh}/${f}" ; then
 				failed=1
 			fi
 		done
@@ -2238,7 +2289,7 @@ do_ssh()
 				# /etc/ssh/ssh{,d}.conf -> ssh{,d}_config
 				#
 			if ! move_file "${op}" \
-			    "${_etcssh}/${f}" "${_etcssh}/${f%.conf}_config" ;
+			    "${etcssh}/${f}" "${etcssh}/${f%.conf}_config" ;
 			then
 				failed=1
 			fi
@@ -2246,17 +2297,18 @@ do_ssh()
 				#
 			if ! move_file "${op}" \
 			    "${DEST_DIR}/etc/${f}" \
-			    "${_etcssh}/${f%.conf}_config" ;
+			    "${etcssh}/${f%.conf}_config" ;
 			then
 				failed=1
 			fi
 		done
 	fi
 
-	sshdconf=""
+	local sshdconf=""
+	local f
 	for f in \
-	    "${_etcssh}/sshd_config" \
-	    "${_etcssh}/sshd.conf" \
+	    "${etcssh}/sshd_config" \
+	    "${etcssh}/sshd.conf" \
 	    "${DEST_DIR}/etc/sshd.conf" ; do
 		if [ -f "${f}" ]; then
 			sshdconf="${f}"
@@ -2310,11 +2362,12 @@ additem tcpdumpchroot "remove /var/chroo
 do_tcpdumpchroot()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_tcpdumpchroot fix|check"
+	local op="$1"
 
-	failed=0;
+	local failed=0;
 	if [ -r "${DEST_DIR}/var/chroot/tcpdump/etc/protocols" ]; then
-		if [ "$1" = "fix" ]; then
-			rm "${DEST_DIR}/var/chroot/tcpdump/etc/protocols"
+		if [ "${op}" = "fix" ]; then
+			${RM} "${DEST_DIR}/var/chroot/tcpdump/etc/protocols"
 			failed=$(( ${failed} + $? ))
 			rmdir "${DEST_DIR}/var/chroot/tcpdump/etc"
 			failed=$(( ${failed} + $? ))
@@ -2427,35 +2480,36 @@ additem x11 "x11 configuration update"
 do_x11()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_x11 fix|check"
-	op="$1"
+	local p="$1"
 
-	failed=0
-	_etcx11="${DEST_DIR}/etc/X11"
-	_libx11=""
-	if [ ! -d "${_etcx11}" ]; then
-		msg "${_etcx11} is not a directory; skipping check"
+	local failed=0
+	local etcx11="${DEST_DIR}/etc/X11"
+	local libx11=""
+	if [ ! -d "${etcx11}" ]; then
+		msg "${etcx11} is not a directory; skipping check"
 		return 0
 	fi
 	if [ -d "${DEST_DIR}/usr/X11R6/." ]
 	then
-		_libx11="${DEST_DIR}/usr/X11R6/lib/X11"
-		if [ ! -d "${_libx11}" ]; then
-			msg "${_libx11} is not a directory; skipping check"
+		libx11="${DEST_DIR}/usr/X11R6/lib/X11"
+		if [ ! -d "${libx11}" ]; then
+			msg "${libx11} is not a directory; skipping check"
 			return 0
 		fi
 	fi
 
-	_notfixed=""
+	local notfixed=""
 	if [ "${op}" = "fix" ]; then
-		_notfixed="${NOT_FIXED}"
+		notfixed="${NOT_FIXED}"
 	fi
 
+	local d
 	# check if /usr/X11R6/lib/X11 needs to migrate to /etc/X11
-	if [ -n "${_libx11}" ]; then
+	if [ -n "${libx11}" ]; then
 		for d in \
-			    fs lbxproxy proxymngr rstart twm xdm xinit xserver xsm \
+		    fs lbxproxy proxymngr rstart twm xdm xinit xserver xsm \
 		    ; do
-			sd="${_libx11}/${d}"
+			sd="${libx11}/${d}"
 			ld="/etc/X11/${d}"
 			td="${DEST_DIR}${ld}"
 			if [ -h "${sd}" ]; then
@@ -2464,13 +2518,13 @@ do_x11()
 				tdfiles="$(find "${td}" \! -type d)"
 				if [ -n "${tdfiles}" ]; then
 					msg "${sd} exists yet ${td} already" \
-					    "contains files${_notfixed}"
+					    "contains files${notfixed}"
 				else
-					msg "Migrate ${sd} to ${td}${_notfixed}"
+					msg "Migrate ${sd} to ${td}${notfixed}"
 				fi
 				failed=1
 			elif [ -e "${sd}" ]; then
-				msg "Unexpected file ${sd}${_notfixed}"
+				msg "Unexpected file ${sd}${notfixed}"
 				continue
 			else
 				continue
@@ -2479,9 +2533,9 @@ do_x11()
 	fi
 
 	# check if xdm resources have been updated
-	if [ -r ${_etcx11}/xdm/Xresources ] && \
-	    ! ${GREP} 'inpColor:' ${_etcx11}/xdm/Xresources > /dev/null; then
-		msg "Update ${_etcx11}/xdm/Xresources${_notfixed}"
+	if [ -r ${etcx11}/xdm/Xresources ] && \
+	    ! ${GREP} -q 'inpColor:' ${etcx11}/xdm/Xresources; then
+		msg "Update ${etcx11}/xdm/Xresources${notfixed}"
 		failed=1
 	fi
 
@@ -2503,19 +2557,19 @@ additem xkb "clean up for xkbdata to xke
 do_xkb()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_xkb fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
 
-	pcpath="/usr/X11R7/lib/X11/xkb/symbols/pc"
-	pcsrcdir="${X11SRCDIR}/external/mit/xkeyboard-config/dist/symbols"
+	local pcpath="/usr/X11R7/lib/X11/xkb/symbols/pc"
+	local pcsrcdir="${X11SRCDIR}/external/mit/xkeyboard-config/dist/symbols"
 
-	filemsg="\
+	local filemsg="\
 ${pcpath} was a directory, should be a file.
     To fix, extract the xbase set again."
 
-	_notfixed=""
+	local notfixed=""
 	if [ "${op}" = "fix" ]; then
-		_notfixed="${NOT_FIXED}"
+		notfixed="${NOT_FIXED}"
 	fi
 
 	if [ ! -d "${DEST_DIR}${pcpath}" ]; then
@@ -2535,13 +2589,13 @@ ${pcpath} was a directory, should be a f
 	# If the directory was removed above, then try to replace it with
 	# a file.
 	if [ -d "${DEST_DIR}${pcpath}" ]; then
-		msg "${filemsg}${_notfixed}"
+		msg "${filemsg}${notfixed}"
 		failed=$(( ${failed} + 1 ))
 	else
 		if ! find_file_in_dirlist pc "${pcpath}" \
 			"${pcsrcdir}" "${SRC_DIR}${pcpath%/*}"
 		then
-			msg "${filemsg}${_notfixed}"
+			msg "${filemsg}${notfixed}"
 			failed=$(( ${failed} + 1 ))
 		else
 			# ${dir} is set by find_file_in_dirlist()
@@ -2568,6 +2622,7 @@ obsolete_stand_internal()
 	[ -n "$1" ] || err 3 "USAGE: do_obsolete_stand fix|check"
 	local op="$1"
 	local failed=0
+	local dir
 
 	for dir in \
 	    ${prefix}/stand/${MACHINE} \
@@ -2617,6 +2672,8 @@ listarchsubdirs()
 getarchsubdirs()
 {
 	local m
+	local i
+
 	case ${MACHINE_ARCH} in
 	*arm*|*aarch64*)	m=arm;;
 	x86_64)			m=amd64;;
@@ -2630,6 +2687,8 @@ getarchsubdirs()
 
 getcompatlibdirs()
 {
+	local i
+
 	for i in $(getarchsubdirs); do
 		if [ -d "${DEST_DIR}/usr/lib/$i" ]; then
 			echo /usr/lib/$i
@@ -2641,8 +2700,9 @@ additem obsolete "remove obsolete file s
 do_obsolete()
 {
 	[ -n "$1" ] || err 3 "USAGE: do_obsolete fix|check"
-	op="$1"
-	failed=0
+	local op="$1"
+	local failed=0
+	local i
 
 	${SORT} -ru "${DEST_DIR}"/var/db/obsolete/* | obsolete_paths "${op}"
 	failed=$(( ${failed} + $? ))
@@ -2720,6 +2780,7 @@ usage()
 
 list()
 {
+	local i
 	echo "Default set of items (to apply if no items are provided by user):"
 	echo " Item                 Description"
 	echo " ----                 -----------"
@@ -3041,7 +3102,7 @@ DIFF_STYLE=
 DIFF_OPT=
 NOT_FIXED=" (FIX MANUALLY)"
 SCRATCHDIR="$( mkdtemp )" || err 2 "Can't create scratch directory"
-trap "/bin/rm -rf \"\${SCRATCHDIR}\" ; exit 0" 1 2 3 15	# HUP INT QUIT TERM
+trap "${RM} -rf \"\${SCRATCHDIR}\" ; exit 0" 1 2 3 15	# HUP INT QUIT TERM
 
 umask 022
 exec 3>/dev/null
@@ -3049,5 +3110,5 @@ exec 4>/dev/null
 exitstatus=0
 
 main "$@"
-/bin/rm -rf "${SCRATCHDIR}"
+${RM} -rf "${SCRATCHDIR}"
 exit $exitstatus

Reply via email to