[Midnightbsd-cvs] src: etc/rc.d: merge rc changes

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jan 17 20:19:30 EST 2009


Log Message:
-----------
merge rc changes

Modified Files:
--------------
    src/etc/rc.d:
        ipfilter (r1.3 -> r1.4)
        isdnd (r1.4 -> r1.5)
        jail (r1.5 -> r1.6)
        kerberos (r1.2 -> r1.3)
        ldconfig (r1.2 -> r1.3)
        localpkg (r1.2 -> r1.3)
        lpd (r1.2 -> r1.3)
        natd (r1.2 -> r1.3)
        nfsclient (r1.2 -> r1.3)
        nfsserver (r1.2 -> r1.3)
        nsswitch (r1.3 -> r1.4)
        powerd (r1.3 -> r1.4)

-------------- next part --------------
Index: kerberos
===================================================================
RCS file: /home/cvs/src/etc/rc.d/kerberos,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/kerberos -L etc/rc.d/kerberos -u -r1.2 -r1.3
--- etc/rc.d/kerberos
+++ etc/rc.d/kerberos
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/kerberos,v 1.4.2.1 2005/09/25 18:45:56 rwatson Exp $
+# $FreeBSD: src/etc/rc.d/kerberos,v 1.6.4.2 2008/01/29 07:15:46 mtm Exp $
 # $MidnightBSD$
 
 # PROVIDE: kerberos
@@ -9,9 +9,9 @@
 . /etc/rc.subr
 
 name="kerberos5"
-load_rc_config $name
 rcvar="kerberos5_server_enable"
-command="${kerberos5_server}"
-command_args="${kerberos5_server_flags} &"
 
+load_rc_config $name
+command="${kerberos5_server}"
+kerberos5_flags="${kerberos5_server_flags}"
 run_rc_command "$1"
Index: isdnd
===================================================================
RCS file: /home/cvs/src/etc/rc.d/isdnd,v
retrieving revision 1.4
retrieving revision 1.5
diff -L etc/rc.d/isdnd -L etc/rc.d/isdnd -u -r1.4 -r1.5
--- etc/rc.d/isdnd
+++ etc/rc.d/isdnd
@@ -1,7 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: isdnd,v 1.9 2002/04/10 23:37:13 martin Exp $
-# $FreeBSD: src/etc/rc.d/isdnd,v 1.20 2005/01/16 03:12:03 obrien Exp $
+# $FreeBSD: src/etc/rc.d/isdnd,v 1.23.4.1 2008/01/28 07:58:31 dougb Exp $
 # $MidnightBSD$
 #
 # Mostly based on original script (/etc/rc.isdn) written by  Hellmuth Michaelis
@@ -23,16 +22,6 @@
 {
 	echo -n 'ISDN subsystem setup:'
 
-	# Check for pcvt driver (VT100/VT220 emulator)
-	#
-	if [ -x /usr/sbin/ispcvt ]; then
-		if /usr/sbin/ispcvt; then
-			# No vidcontrol if we are using pcvt
-			#
-			isdn_screenflags=NO
-		fi
-	fi
-
 	# Start isdnd
 	#
 	echo -n ' isdnd'
Index: nfsclient
===================================================================
RCS file: /home/cvs/src/etc/rc.d/nfsclient,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/nfsclient -L etc/rc.d/nfsclient -u -r1.2 -r1.3
--- etc/rc.d/nfsclient
+++ etc/rc.d/nfsclient
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/nfsclient,v 1.5 2004/10/07 13:55:26 mtm Exp $
+# $FreeBSD: src/etc/rc.d/nfsclient,v 1.6 2006/12/31 10:37:18 yar Exp $
 # $MidnightBSD$
 
 # PROVIDE: nfsclient
@@ -12,20 +12,8 @@
 name="nfsclient"
 rcvar="nfs_client_enable"
 start_cmd="nfsclient_start"
-start_precmd="nfsclient_precmd"
 stop_cmd="unmount_all"
-
-# Load nfs module if it was not compiled into the kernel
-nfsclient_precmd()
-{
-	if ! sysctl vfs.nfs >/dev/null 2>&1; then
-		if ! kldload nfsclient; then
-			warn 'Could not load nfs client module'
-			return 1
-		fi
-	fi
-	return 0
-}
+required_modules="nfsclient:nfs"
 
 nfsclient_start()
 {
Index: lpd
===================================================================
RCS file: /home/cvs/src/etc/rc.d/lpd,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/lpd -L etc/rc.d/lpd -u -r1.2 -r1.3
--- etc/rc.d/lpd
+++ etc/rc.d/lpd
@@ -1,7 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: lpd,v 1.5 2002/03/22 04:33:59 thorpej Exp $
-# $FreeBSD: src/etc/rc.d/lpd,v 1.7 2005/03/02 02:46:47 brooks Exp $
+# $FreeBSD: src/etc/rc.d/lpd,v 1.8.4.1 2008/01/28 07:58:31 dougb Exp $
 # $MidnightBSD$
 
 # PROVIDE: lpd
@@ -14,9 +13,9 @@
 rcvar=`set_rcvar`
 command="/usr/sbin/${name}"
 required_files="/etc/printcap"
-start_precmd="_chkprintcap"
+start_precmd="chkprintcap"
 
-_chkprintcap()
+chkprintcap()
 {
 	if checkyesno chkprintcap_enable ; then
 		/usr/sbin/chkprintcap ${chkprintcap_flags}
Index: ldconfig
===================================================================
RCS file: /home/cvs/src/etc/rc.d/ldconfig,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/ldconfig -L etc/rc.d/ldconfig -u -r1.2 -r1.3
--- etc/rc.d/ldconfig
+++ etc/rc.d/ldconfig
@@ -1,8 +1,7 @@
 #!/bin/sh
 #
-# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $
-# $FreeBSD: src/etc/rc.d/ldconfig,v 1.14.2.1 2006/01/17 06:53:17 dougb Exp $
-# $MidnightBSD$ 
+# $FreeBSD: src/etc/rc.d/ldconfig,v 1.17.2.1.2.1 2008/01/28 07:58:31 dougb Exp $
+# $MidnightBSD$
 
 # PROVIDE: ldconfig
 # REQUIRE: mountcritremote cleanvar
@@ -17,6 +16,8 @@
 
 ldconfig_start()
 {
+	local _files _ins
+
 	_ins=
 	ldconfig=${ldconfig_command}
 	checkyesno ldconfig_insecure && _ins="-i"
@@ -24,7 +25,10 @@
 		_LDC="/lib /usr/lib"
 		for i in ${ldconfig_local_dirs}; do
 			if [ -d "${i}" ]; then
-				ldconfig_paths="${ldconfig_paths} `find ${i} -type f`"
+				_files=`find ${i} -type f`
+				if [ -n "${_files}" ]; then
+					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
+				fi
 			fi
 		done
 		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
@@ -39,11 +43,20 @@
 		amd64)
 			for i in ${ldconfig_local32_dirs}; do
 				if [ -d "${i}" ]; then
-					ldconfig32_paths="${ldconfig32_paths} `find ${i} -type f`"
+					_files=`find ${i} -type f`
+					if [ -n "${_files}" ]; then
+						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
+					fi
+				fi
+			done
+			_LDC=""
+			for i in ${ldconfig32_paths}; do
+				if [ -r "${i}" ]; then
+					_LDC="${_LDC} ${i}"
 				fi
 			done
-			echo '32-bit compatibility ldconfig path:' ${ldconfig32_paths}
-			${ldconfig} -32 -m ${_ins} ${ldconfig32_paths}
+			echo '32-bit compatibility ldconfig path:' ${_LDC}
+			${ldconfig} -32 -m ${_ins} ${_LDC}
 			;;
 		esac
 
Index: natd
===================================================================
RCS file: /home/cvs/src/etc/rc.d/natd,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/natd -L etc/rc.d/natd -u -r1.2 -r1.3
--- etc/rc.d/natd
+++ etc/rc.d/natd
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/natd,v 1.3 2004/10/22 19:36:03 andre Exp $
+# $FreeBSD: src/etc/rc.d/natd,v 1.5 2006/12/31 10:37:18 yar Exp $
 # $MidnightBSD$
 
 # PROVIDE: natd
@@ -12,43 +12,31 @@
 name="natd"
 rcvar=`set_rcvar`
 command="/sbin/${name}"
+pidfile="/var/run/${name}.pid"
 start_precmd="natd_precmd"
-start_cmd="natd_start"
+required_modules="ipdivert"
 
 natd_precmd()
 {
-	if ! ${SYSCTL} net.inet.divert > /dev/null 2>&1; then
-		if ! kldload ipdivert; then
-			warn unable to load IPDIVERT module.
-			return 1
-		fi
-	fi
-
-	return 0
-}
-
-natd_start()
-{
-	dhcp_list="`list_net_interfaces dhcp`"
-	for ifn in ${dhcp_list}; do
-		case ${natd_interface} in
-		${ifn})
-			natd_flags="$natd_flags -dynamic"
-			;;
-		*)
-			;;
-		esac
-	done
 	if [ -n "${natd_interface}" ]; then
-		if echo ${natd_interface} | \
-		grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
-			natd_flags="$natd_flags -a ${natd_interface}"
+		dhcp_list="`list_net_interfaces dhcp`"
+		for ifn in ${dhcp_list}; do
+			case "${natd_interface}" in
+			${ifn})
+				rc_flags="$rc_flags -dynamic"
+				;;
+			esac
+		done
+
+		if echo "${natd_interface}" | \
+		    grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
+			rc_flags="$rc_flags -a ${natd_interface}"
 		else
-			natd_flags="$natd_flags -n ${natd_interface}"
+			rc_flags="$rc_flags -n ${natd_interface}"
 		fi
 	fi
-	echo -n ' natd'
-	${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
+
+	return 0
 }
 
 load_rc_config $name
Index: powerd
===================================================================
RCS file: /home/cvs/src/etc/rc.d/powerd,v
retrieving revision 1.3
retrieving revision 1.4
diff -L etc/rc.d/powerd -L etc/rc.d/powerd -u -r1.3 -r1.4
--- etc/rc.d/powerd
+++ etc/rc.d/powerd
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/powerd,v 1.2.2.1 2005/12/16 01:42:54 dougb Exp $
+# $FreeBSD: src/etc/rc.d/powerd,v 1.4 2006/08/27 11:04:39 cperciva Exp $
 # $MidnightBSD$
 
 # PROVIDE: powerd
@@ -13,6 +13,13 @@
 name="powerd"
 rcvar=`set_rcvar`
 command="/usr/sbin/${name}"
+stop_postcmd=powerd_poststop
+
+powerd_poststop()
+{
+	sysctl dev.cpu.0.freq=`sysctl -n dev.cpu.0.freq_levels |
+	    sed -e 's:/.*::'` > /dev/null
+}
 
 load_rc_config $name
 run_rc_command "$1"
Index: nsswitch
===================================================================
RCS file: /home/cvs/src/etc/rc.d/nsswitch,v
retrieving revision 1.3
retrieving revision 1.4
diff -L etc/rc.d/nsswitch -L etc/rc.d/nsswitch -u -r1.3 -r1.4
--- etc/rc.d/nsswitch
+++ etc/rc.d/nsswitch
@@ -24,7 +24,7 @@
 # SUCH DAMAGE.
 #
 # $MidnightBSD$
-# $FreeBSD: src/etc/rc.d/nsswitch,v 1.5.2.1 2006/04/04 14:27:55 flz Exp $
+# $FreeBSD: src/etc/rc.d/nsswitch,v 1.12 2006/12/30 22:53:20 yar Exp $
 #
 
 # PROVIDE: nsswitch
@@ -37,52 +37,10 @@
 start_cmd="nsswitch_start"
 stop_cmd=":"
 
-convert_host_conf()
-{
-    host_conf=$1; shift;
-    nsswitch_conf=$1; shift;
-
-    while read line; do
-	line=${line##[ 	]}
-	case $line in
-        hosts|local|file)
-		_nsswitch="${_nsswitch}${_nsswitch+ }files"
-		;;
-	dns|bind)
-		_nsswitch="${_nsswitch}${_nsswitch+ }dns"
-		;;
-	nis)
-		_nsswitch="${_nsswitch}${_nsswitch+ }nis"
-		;;
-	'#'*)
-		;;
-	*)
-        	printf "Warning: unrecognized line [%s]", $line > "/dev/stderr"
-		;;
-		
-	esac
-    done < $host_conf
-
-    echo "hosts: $_nsswitch" > $nsswitch_conf
-}
-
-generate_nsswitch_conf()
-{
-    nsswitch_conf=$1; shift;
-
-    cat >$nsswitch_conf <<EOF
-group: compat
-group_compat: nis
-hosts: files dns
-networks: files
-passwd: compat
-passwd_compat: nis
-shells: files
-EOF
-}
-
 generate_host_conf()
 {
+    local _cont _sources
+
     nsswitch_conf=$1; shift;
     host_conf=$1; shift;
 
@@ -108,7 +66,7 @@
 	_sources="${_sources}${_sources:+ }$line"
     done < $nsswitch_conf
 
-    echo "# Auto-generated from nsswitch.conf, do not edit" > $host_conf
+    echo "# Auto-generated from nsswitch.conf" > $host_conf
     for _s in ${_sources}; do
 	case $_s in
 	files)
@@ -131,25 +89,11 @@
 
 nsswitch_start()
 {
-	# Convert host.conf to nsswitch.conf if necessary
-	#
-	if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then
-		echo ''
-		echo 'Warning: /etc/host.conf is no longer used'
-		echo '  /etc/nsswitch.conf will be created for you'
-		convert_host_conf /etc/host.conf /etc/nsswitch.conf
-	fi
-
-	# Generate default nsswitch.conf if none exists
-	#
-	if [ ! -f "/etc/nsswitch.conf" ]; then
-		echo 'Generating nsswitch.conf.'
-		generate_nsswitch_conf /etc/nsswitch.conf
-	fi
-
 	# Generate host.conf for compatibility
 	#
-	if [ ! -f "/etc/host.conf" ]; then
+	if [ ! -f "/etc/host.conf" -o \
+		"/etc/host.conf" -ot "/etc/nsswitch.conf" ]
+	then
 		echo 'Generating host.conf.'
 		generate_host_conf /etc/nsswitch.conf /etc/host.conf
 	fi
Index: jail
===================================================================
RCS file: /home/cvs/src/etc/rc.d/jail,v
retrieving revision 1.5
retrieving revision 1.6
diff -L etc/rc.d/jail -L etc/rc.d/jail -u -r1.5 -r1.6
--- etc/rc.d/jail
+++ etc/rc.d/jail
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/jail,v 1.23.2.2 2005/08/16 08:43:06 pjd Exp $
+# $FreeBSD: src/etc/rc.d/jail,v 1.37.4.1 2008/01/29 00:22:33 dougb Exp $
 # $MidnightBSD$
 
 # PROVIDE: jail
@@ -8,6 +8,12 @@
 # BEFORE: securelevel
 # KEYWORD: nojail shutdown
 
+# WARNING: This script deals with untrusted data (the data and
+# processes inside the jails) and care must be taken when changing the
+# code related to this!  If you have any doubt whether a change is
+# correct and have security impact, please get the patch reviewed by
+# laffer1@ or ctriv@ prior to commit.
+
 . /etc/rc.subr
 
 name="jail"
@@ -27,66 +33,101 @@
 		return
 	fi
 
-	eval jail_rootdir=\"\$jail_${_j}_rootdir\"
-	jail_devdir="${jail_rootdir}/dev"
-	jail_fdescdir="${jail_devdir}/fd"
-	jail_procdir="${jail_rootdir}/proc"
-	eval jail_hostname=\"\$jail_${_j}_hostname\"
-	eval jail_ip=\"\$jail_${_j}_ip\"
-	eval jail_exec=\"\$jail_${_j}_exec\"
-	eval jail_exec_start=\"\$jail_${_j}_exec_start\"
-	eval jail_exec_stop=\"\$jail_${_j}_exec_stop\"
-	if [ -n "${jail_exec}" ]; then
+	eval _rootdir=\"\$jail_${_j}_rootdir\"
+	_devdir="${_rootdir}/dev"
+	_fdescdir="${_devdir}/fd"
+	_procdir="${_rootdir}/proc"
+	eval _hostname=\"\$jail_${_j}_hostname\"
+	eval _ip=\"\$jail_${_j}_ip\"
+	eval _interface=\"\${jail_${_j}_interface:-${jail_interface}}\"
+	eval _exec=\"\$jail_${_j}_exec\"
+	eval _exec_start=\"\${jail_${_j}_exec_start:-${jail_exec_start}}\"
+
+	i=1
+	while [ true ]; do
+		eval _exec_afterstart${i}=\"\${jail_${_j}_exec_afterstart${i}:-\${jail_exec_afterstart${i}}}\"
+		[ -z "$(eval echo \"\$_exec_afterstart${i}\")" ] &&  break
+		i=$((i + 1))
+	done
+	
+	eval _exec_stop=\"\${jail_${_j}_exec_stop:-${jail_exec_stop}}\"
+	if [ -n "${_exec}" ]; then
 		#   simple/backward-compatible execution
-		jail_exec_start="${jail_exec}"
-		jail_exec_stop=""
+		_exec_start="${_exec}"
+		_exec_stop=""
 	else
 		#   flexible execution
-		if [ -z "${jail_exec_start}" ]; then
-			jail_exec_start="/bin/sh /etc/rc"
-			if [ -z "${jail_exec_stop}" ]; then
-				jail_exec_stop="/bin/sh /etc/rc.shutdown"
+		if [ -z "${_exec_start}" ]; then
+			_exec_start="/bin/sh /etc/rc"
+			if [ -z "${_exec_stop}" ]; then
+				_exec_stop="/bin/sh /etc/rc.shutdown"
 			fi
 		fi
 	fi
 
 	# The default jail ruleset will be used by rc.subr if none is specified.
-	eval jail_ruleset=\"\$jail_${_j}_devfs_ruleset\"
-	eval jail_devfs=\"\$jail_${_j}_devfs_enable\"
-	[ -z "${jail_devfs}" ] && jail_devfs="NO"
-	eval jail_fdescfs=\"\$jail_${_j}_fdescfs_enable\"
-	[ -z "${jail_fdescfs}" ] && jail_fdescfs="NO"
-	eval jail_procfs=\"\$jail_${_j}_procfs_enable\"
-	[ -z "${jail_procfs}" ] && jail_procfs="NO"
+	eval _ruleset=\"\${jail_${_j}_devfs_ruleset:-${jail_devfs_ruleset}}\"
+	eval _devfs=\"\${jail_${_j}_devfs_enable:-${jail_devfs_enable}}\"
+	[ -z "${_devfs}" ] && _devfs="NO"
+	eval _fdescfs=\"\${jail_${_j}_fdescfs_enable:-${jail_fdescfs_enable}}\"
+	[ -z "${_fdescfs}" ] && _fdescfs="NO"
+	eval _procfs=\"\${jail_${_j}_procfs_enable:-${jail_procfs_enable}}\"
+	[ -z "${_procfs}" ] && _procfs="NO"
 
-	eval jail_mount=\"\$jail_${_j}_mount_enable\"
-	[ -z "${jail_mount}" ] && jail_mount="NO"
+	eval _mount=\"\${jail_${_j}_mount_enable:-${jail_mount_enable}}\"
+	[ -z "${_mount}" ] && _mount="NO"
 	# "/etc/fstab.${_j}" will be used for {,u}mount(8) if none is specified.
-	eval jail_fstab=\"\$jail_${_j}_fstab\"
-	[ -z "${jail_fstab}" ] && jail_fstab="/etc/fstab.${_j}"
-	eval jail_flags=\"\$jail_${_j}_flags\"
-	[ -z "${jail_flags}" ] && jail_flags="-l -U root"
+	eval _fstab=\"\${jail_${_j}_fstab:-${jail_fstab}}\"
+	[ -z "${_fstab}" ] && _fstab="/etc/fstab.${_j}"
+	eval _flags=\"\${jail_${_j}_flags:-${jail_flags}}\"
+	[ -z "${_flags}" ] && _flags="-l -U root"
 	eval _consolelog=\"\${jail_${_j}_consolelog:-${jail_consolelog}}\"
 	[ -z "${_consolelog}" ] && _consolelog="/var/log/jail_${_j}_console.log"
 
 	# Debugging aid
 	#
-	debug "$_j devfs enable: $jail_devfs"
-	debug "$_j fdescfs enable: $jail_fdescfs"
-	debug "$_j procfs enable: $jail_procfs"
-	debug "$_j mount enable: $jail_mount"
-	debug "$_j hostname: $jail_hostname"
-	debug "$_j ip: $jail_ip"
-	debug "$_j root: $jail_rootdir"
-	debug "$_j devdir: $jail_devdir"
-	debug "$_j fdescdir: $jail_fdescdir"
-	debug "$_j procdir: $jail_procdir"
-	debug "$_j ruleset: $jail_ruleset"
-	debug "$_j fstab: $jail_fstab"
-	debug "$_j exec start: $jail_exec_start"
-	debug "$_j exec stop: $jail_exec_stop"
-	debug "$_j flags: $jail_flags"
+	debug "$_j devfs enable: $_devfs"
+	debug "$_j fdescfs enable: $_fdescfs"
+	debug "$_j procfs enable: $_procfs"
+	debug "$_j mount enable: $_mount"
+	debug "$_j hostname: $_hostname"
+	debug "$_j ip: $_ip"
+	debug "$_j interface: $_interface"
+	debug "$_j root: $_rootdir"
+	debug "$_j devdir: $_devdir"
+	debug "$_j fdescdir: $_fdescdir"
+	debug "$_j procdir: $_procdir"
+	debug "$_j ruleset: $_ruleset"
+	debug "$_j fstab: $_fstab"
+	debug "$_j exec start: $_exec_start"
+	debug "$_j consolelog: $_consolelog"
+
+	i=1
+	while [ true ]; do
+		eval out=\"\${_exec_afterstart${i}:-''}\"
+
+		if [ -z "$out" ]; then
+			break;
+		fi
+
+		debug "$_j exec after start #${i}: ${out}"
+		i=$((i + 1))
+	done
+
+	debug "$_j exec stop: $_exec_stop"
+	debug "$_j flags: $_flags"
 	debug "$_j consolelog: $_consolelog"
+
+	if [ -z "${_hostname}" ]; then
+		err 3 "$name: No hostname has been defined for ${_j}"
+	fi
+	if [ -z "${_rootdir}" ]; then
+		err 3 "$name: No root directory has been defined for ${_j}"
+	fi
+	if [ -z "${_ip}" ]; then
+		err 3 "$name: No IP address has been defined for ${_j}"
+	fi
+
 }
 
 # set_sysctl rc_knob mib msg
@@ -175,24 +216,24 @@
 {
 	local _device _mountpt _rest
 
-	if checkyesno jail_fdescfs; then
-		if [ -d "${jail_fdescdir}" ] ; then
-			secure_umount ${jail_fdescdir}
+	if checkyesno _fdescfs; then
+		if [ -d "${_fdescdir}" ] ; then
+			secure_umount ${_fdescdir}
 		fi
 	fi
-	if checkyesno jail_devfs; then
-		if [ -d "${jail_devdir}" ] ; then
-			secure_umount ${jail_devdir}
+	if checkyesno _devfs; then
+		if [ -d "${_devdir}" ] ; then
+			secure_umount ${_devdir}
 		fi
 	fi
-	if checkyesno jail_procfs; then
-		if [ -d "${jail_procdir}" ] ; then
-			secure_umount ${jail_procdir}
+	if checkyesno _procfs; then
+		if [ -d "${_procdir}" ] ; then
+			secure_umount ${_procdir}
 		fi
 	fi
-	if checkyesno jail_mount; then
-		[ -f "${jail_fstab}" ] || warn "${jail_fstab} does not exist"
-		tail -r ${jail_fstab} | while read _device _mountpt _rest; do
+	if checkyesno _mount; then
+		[ -f "${_fstab}" ] || warn "${_fstab} does not exist"
+		tail -r ${_fstab} | while read _device _mountpt _rest; do
 			case ":${_device}" in
 			:#* | :)
 				continue
@@ -225,11 +266,11 @@
 			;;
 		esac
 		if is_symlinked_mountpoint ${_mountpt}; then
-			warn "${_mountpt} has symlink as parent - not mounting from ${jail_fstab}"
+			warn "${_mountpt} has symlink as parent - not mounting from ${_fstab}"
 			return
 		fi
-	done <${jail_fstab}
-	mount -a -F "${jail_fstab}"
+	done <${_fstab}
+	mount -a -F "${_fstab}"
 }
 
 jail_start()
@@ -250,30 +291,33 @@
 	do
 		init_variables $_jail
 		if [ -f /var/run/jail_${_jail}.id ]; then
-			echo -n " [${jail_hostname} already running (/var/run/jail_${_jail}.id exists)]"
+			echo -n " [${_hostname} already running (/var/run/jail_${_jail}.id exists)]"
 			continue;
 		fi
-		if checkyesno jail_mount; then
-			info "Mounting fstab for jail ${_jail} (${jail_fstab})"
-			if [ ! -f "${jail_fstab}" ]; then
-				err 3 "$name: ${jail_fstab} does not exist"
+		if [ -n "${_interface}" ]; then
+			ifconfig ${_interface} alias ${_ip} netmask 255.255.255.255
+		fi
+		if checkyesno _mount; then
+			info "Mounting fstab for jail ${_jail} (${_fstab})"
+			if [ ! -f "${_fstab}" ]; then
+				err 3 "$name: ${_fstab} does not exist"
 			fi
 			jail_mount_fstab
 		fi
-		if checkyesno jail_devfs; then
+		if checkyesno _devfs; then
 			# If devfs is already mounted here, skip it.
-			df -t devfs "${jail_devdir}" >/dev/null
+			df -t devfs "${_devdir}" >/dev/null
 			if [ $? -ne 0 ]; then
-				if is_symlinked_mountpoint ${jail_devdir}; then
-					warn "${jail_devdir} has symlink as parent - not starting jail ${_jail}"
+				if is_symlinked_mountpoint ${_devdir}; then
+					warn "${_devdir} has symlink as parent - not starting jail ${_jail}"
 					continue
 				fi
-				info "Mounting devfs on ${jail_devdir}"
-				devfs_mount_jail "${jail_devdir}" ${jail_ruleset}
+				info "Mounting devfs on ${_devdir}"
+				devfs_mount_jail "${_devdir}" ${_ruleset}
 				# Transitional symlink for old binaries
-				if [ ! -L "${jail_devdir}/log" ]; then
+				if [ ! -L "${_devdir}/log" ]; then
 					__pwd="`pwd`"
-					cd "${jail_devdir}"
+					cd "${_devdir}"
 					ln -sf ../var/run/log log
 					cd "$__pwd"
 				fi
@@ -283,36 +327,58 @@
 			#	is a devfs(5) device of the same name.
 			# Jail console output
 			#	__pwd="`pwd`"
-			#	cd "${jail_devdir}"
+			#	cd "${_devdir}"
 			#	ln -sf ../var/log/console console
 			#	cd "$__pwd"
 		fi
-		if checkyesno jail_fdescfs; then
- 			if is_symlinked_mountpoint ${jail_fdescdir}; then
- 				warn "${jail_fdescdir} has symlink as parent, not mounting"
- 			else
-				info "Mounting fdescfs on ${jail_fdescdir}"
-				mount -t fdescfs fdesc "${jail_fdescdir}"
+		if checkyesno _fdescfs; then
+			if is_symlinked_mountpoint ${_fdescdir}; then
+				warn "${_fdescdir} has symlink as parent, not mounting"
+			else
+				info "Mounting fdescfs on ${_fdescdir}"
+				mount -t fdescfs fdesc "${_fdescdir}"
 			fi
 		fi
-		if checkyesno jail_procfs; then
-			if is_symlinked_mountpoint ${jail_procdir}; then
-				warn "${jail_procdir} has symlink as parent, not mounting"
+		if checkyesno _procfs; then
+			if is_symlinked_mountpoint ${_procdir}; then
+				warn "${_procdir} has symlink as parent, not mounting"
 			else
-				info "Mounting procfs onto ${jail_procdir}"
-				if [ -d "${jail_procdir}" ] ; then
-					mount -t procfs proc "${jail_procdir}"
+				info "Mounting procfs onto ${_procdir}"
+				if [ -d "${_procdir}" ] ; then
+					mount -t procfs proc "${_procdir}"
 				fi
 			fi
 		fi
 		_tmp_jail=${_tmp_dir}/jail.$$
-		eval jail ${jail_flags} -i ${jail_rootdir} ${jail_hostname} \
-			${jail_ip} ${jail_exec_start} > ${_tmp_jail} 2>&1
-		[ "$?" -eq 0 ] && echo -n " $jail_hostname"
-		_jail_id=$(head -1 ${_tmp_jail})
-		tail +2 ${_tmp_jail} >${_consolelog}
+		eval jail ${_flags} -i ${_rootdir} ${_hostname} \
+			${_ip} ${_exec_start} > ${_tmp_jail} 2>&1
+
+		if [ "$?" -eq 0 ] ; then
+			_jail_id=$(head -1 ${_tmp_jail})
+			i=1
+			while [ true ]; do
+				eval out=\"\${_exec_afterstart${i}:-''}\"
+
+				if [ -z "$out" ]; then
+					break;
+				fi
+
+				jexec "${_jail_id}" ${out}
+				i=$((i + 1))
+			done
+
+			echo -n " $_hostname"
+			tail +2 ${_tmp_jail} >${_consolelog}
+			echo ${_jail_id} > /var/run/jail_${_jail}.id
+		else
+			jail_umount_fs
+			if [ -n "${_interface}" ]; then
+				ifconfig ${_interface} -alias ${_ip}
+			fi
+			echo " cannot start jail \"${_jail}\": "
+			tail +2 ${_tmp_jail}
+		fi
 		rm -f ${_tmp_jail}
-		echo ${_jail_id} > /var/run/jail_${_jail}.id
 	done
 	rmdir ${_tmp_dir}
 	echo '.'
@@ -327,19 +393,22 @@
 			_jail_id=$(cat /var/run/jail_${_jail}.id)
 			if [ ! -z "${_jail_id}" ]; then
 				init_variables $_jail
-				if [ -n "${jail_exec_stop}" ]; then
-					eval env -i /usr/sbin/jexec ${_jail_id} ${jail_exec_stop} \
+				if [ -n "${_exec_stop}" ]; then
+					eval env -i /usr/sbin/jexec ${_jail_id} ${_exec_stop} \
 						>> ${_consolelog} 2>&1
 				fi
 				killall -j ${_jail_id} -TERM > /dev/null 2>&1
 				sleep 1
 				killall -j ${_jail_id} -KILL > /dev/null 2>&1
 				jail_umount_fs
-				echo -n " $jail_hostname"
+				echo -n " $_hostname"
+			fi
+			if [ -n "${_interface}" ]; then
+				ifconfig ${_interface} -alias ${_ip}
 			fi
 			rm /var/run/jail_${_jail}.id
 		else
-			echo "cannot stop jail ${_jail}. No jail id in /var/run"
+			echo " cannot stop jail ${_jail}. No jail id in /var/run"
 		fi
 	done
 	echo '.'
Index: ipfilter
===================================================================
RCS file: /home/cvs/src/etc/rc.d/ipfilter,v
retrieving revision 1.3
retrieving revision 1.4
diff -L etc/rc.d/ipfilter -L etc/rc.d/ipfilter -u -r1.3 -r1.4
--- etc/rc.d/ipfilter
+++ etc/rc.d/ipfilter
@@ -1,7 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: ipfilter,v 1.10 2001/02/28 17:03:50 lukem Exp $
-# $FreeBSD: src/etc/rc.d/ipfilter,v 1.24 2005/07/07 05:59:44 jkim Exp $
+# $FreeBSD: src/etc/rc.d/ipfilter,v 1.28.4.1 2008/01/28 07:58:31 dougb Exp $
 # $MidnightBSD$
 
 # PROVIDE: ipfilter
@@ -16,7 +15,7 @@
 load_rc_config $name
 stop_precmd="test -f ${ipfilter_rules} -o -f ${ipv6_ipfilter_rules}"
 
-start_precmd="ipfilter_prestart"
+start_precmd="$stop_precmd"
 start_cmd="ipfilter_start"
 stop_cmd="ipfilter_stop"
 reload_precmd="$stop_precmd"
@@ -26,35 +25,7 @@
 status_precmd="$stop_precmd"
 status_cmd="ipfilter_status"
 extra_commands="reload resync status"
-
-ipfilter_loaded()
-{
-	if ! kldstat -v | grep "ipfilter$" > /dev/null 2>&1; then
-		return 1
-	else
-		return 0
-	fi
-}
-
-ipfilter_prestart()
-{
-	# load ipfilter kernel module if needed
-	if ! ipfilter_loaded; then
-		if kldload ipl; then
-			info 'IP-filter module loaded.'
-		else
-			err 1 'IP-filter module failed to load.'
-		fi
-	fi
-
-	# check for ipfilter rules
-	if [ ! -r "${ipfilter_rules}" ] && [ ! -r "${ipv6_ipfilter_rules}" ]
-	then
-		warn 'IP-filter: NO IPF RULES'
-		return 1
-	fi
-	return 0
-}
+required_modules="ipl:ipfilter"
 
 ipfilter_start()
 {
@@ -93,11 +64,17 @@
 	if [ -r "${ipfilter_rules}" ]; then
 		${ipfilter_program:-/sbin/ipf} -I \
 		    -f "${ipfilter_rules}" ${ipfilter_flags}
+		if [ $? -ne 0 ]; then
+			err 1 'Load of rules into alternate set failed; aborting reload'
+		fi
 	fi
 	${ipfilter_program:-/sbin/ipf} -I -6 -Fa
 	if [ -r "${ipv6_ipfilter_rules}" ]; then
 		${ipfilter_program:-/sbin/ipf} -I -6 \
 		    -f "${ipv6_ipfilter_rules}" ${ipfilter_flags}
+		if [ $? -ne 0 ]; then
+			err 1 'Load of IPv6 rules into alternate set failed; aborting reload'
+		fi
 	fi
 	${ipfilter_program:-/sbin/ipf} -s
 
@@ -105,10 +82,6 @@
 
 ipfilter_resync()
 {
-	# Don't resync if ipfilter is not loaded
-	if ! ipfilter_loaded; then
-		 return
-	fi
 	${ipfilter_program:-/sbin/ipf} -y ${ipfilter_flags}
 }
 
Index: localpkg
===================================================================
RCS file: /home/cvs/src/etc/rc.d/localpkg,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/localpkg -L etc/rc.d/localpkg -u -r1.2 -r1.3
--- etc/rc.d/localpkg
+++ etc/rc.d/localpkg
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/localpkg,v 1.5.2.2 2005/12/21 07:11:34 dougb Exp $
+# $FreeBSD: src/etc/rc.d/localpkg,v 1.8 2006/02/12 10:04:56 matteo Exp $
 # $MidnightBSD$
 
 # PROVIDE: localpkg
@@ -48,6 +48,9 @@
 		find_local_scripts_old
 		for script in `reverse_list ${slist} ${zlist}`; do
 			if [ -x "${script}" ]; then
+				if [ `sysctl -n debug.bootverbose` -eq 1 ]; then
+					echo "==>" ${script}
+				fi
 				(set -T
 				trap 'exit 1' 2
 				${script} stop)
Index: nfsserver
===================================================================
RCS file: /home/cvs/src/etc/rc.d/nfsserver,v
retrieving revision 1.2
retrieving revision 1.3
diff -L etc/rc.d/nfsserver -L etc/rc.d/nfsserver -u -r1.2 -r1.3
--- etc/rc.d/nfsserver
+++ etc/rc.d/nfsserver
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/nfsserver,v 1.4 2004/10/07 13:55:26 mtm Exp $
+# $FreeBSD: src/etc/rc.d/nfsserver,v 1.5 2006/12/31 10:37:18 yar Exp $
 # $MidnightBSD$
 
 # PROVIDE: nfsserver
@@ -11,20 +11,9 @@
 
 name="nfsserver"
 rcvar="nfs_server_enable"
-start_cmd="nfsserver_start"
+start_cmd=":"
 stop_cmd=":"
-
-# Load nfs modules if they were not compiled into the kernel
-nfsserver_start()
-{
-	if ! sysctl vfs.nfsrv >/dev/null 2>&1; then
-		if ! kldload nfsserver; then
-			warn 'Could not load NFS server module'
-			return 1
-		fi
-	fi
-	return 0
-}
+required_modules="nfsserver"
 
 load_rc_config $name
 run_rc_command "$1"


More information about the Midnightbsd-cvs mailing list