[Midnightbsd-cvs] src: etc/rc.d: add idmapd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jan 17 12:30:25 EST 2009


Log Message:
-----------
add idmapd

Modified Files:
--------------
    src/etc/rc.d:
        Makefile (r1.11 -> r1.12)
        pf (r1.3 -> r1.4)
        pflog (r1.4 -> r1.5)
        pfsync (r1.3 -> r1.4)

Added Files:
-----------
    src/etc/rc.d:
        hostid (r1.1)

-------------- next part --------------
Index: pfsync
===================================================================
RCS file: /home/cvs/src/etc/rc.d/pfsync,v
retrieving revision 1.3
retrieving revision 1.4
diff -L etc/rc.d/pfsync -L etc/rc.d/pfsync -u -r1.3 -r1.4
--- etc/rc.d/pfsync
+++ etc/rc.d/pfsync
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # $MidnightBSD$
-# $FreeBSD: src/etc/rc.d/pfsync,v 1.1.2.1 2005/10/08 03:32:54 yar Exp $
+# $FreeBSD: src/etc/rc.d/pfsync,v 1.5 2007/04/10 16:42:13 keramida Exp $
 #
 
 # PROVIDE: pfsync
@@ -15,33 +15,35 @@
 start_precmd="pfsync_prestart"
 start_cmd="pfsync_start"
 stop_cmd="pfsync_stop"
+required_modules="pf"
 
 pfsync_prestart()
 {
+	# XXX Currently pfsync cannot be a module as it must register
+	# a network protocol in a static kernel table.
+	if ! kldstat -q -m pfsync; then
+		warn "pfsync(4) must be statically compiled in the kernel."
+		return 1
+	fi
+
 	case "$pfsync_syncdev" in
 	'')
 		warn "pfsync_syncdev is not set."
 		return 1
 		;;
 	esac
-
-	# load pf kernel module if needed
-	if ! kldstat -q -m pf ; then
-		if kldload pf ; then
-			info "pf module loaded."
-		else
-			warn "pf module failed to load."
-			return 1
-		fi
-	fi
-
 	return 0
 }
 
 pfsync_start()
 {
+	local _syncpeer
+
 	echo "Enabling pfsync."
-	ifconfig pfsync0 syncdev $pfsync_syncdev $pfsync_ifconfig up
+	if [ -n "${pfsync_syncpeer}" ]; then
+		_syncpeer="syncpeer ${pfsync_syncpeer}"
+	fi
+	ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
 }
 
 pfsync_stop()
Index: pf
===================================================================
RCS file: /home/cvs/src/etc/rc.d/pf,v
retrieving revision 1.3
retrieving revision 1.4
diff -L etc/rc.d/pf -L etc/rc.d/pf -u -r1.3 -r1.4
--- etc/rc.d/pf
+++ etc/rc.d/pf
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/pf,v 1.7.2.4 2006/01/22 13:45:28 yar Exp $
+# $FreeBSD: src/etc/rc.d/pf,v 1.16 2007/04/09 08:53:40 des Exp $
 # $MidnightBSD$
 
 # PROVIDE: pf
@@ -13,7 +13,6 @@
 name="pf"
 rcvar=`set_rcvar`
 load_rc_config $name
-start_precmd="pf_prestart"
 start_cmd="pf_start"
 stop_cmd="pf_stop"
 check_cmd="pf_check"
@@ -22,25 +21,12 @@
 status_cmd="pf_status"
 extra_commands="check reload resync status"
 required_files="$pf_rules"
-
-pf_prestart()
-{
-	# load pf kernel module if needed
-	if ! kldstat -q -m pf ; then
-		if kldload pf ; then
-			info 'pf module loaded.'
-		else
-			warn 'pf module failed to load.'
-			return 1
-		fi
-	fi
-	return 0
-}
+required_modules="pf"
 
 pf_start()
 {
 	echo "Enabling pf."
-	$pf_program -Fall > /dev/null 2>&1
+	$pf_program -F all > /dev/null 2>&1
 	$pf_program -f "$pf_rules" $pf_flags
 	if ! $pf_program -s info | grep -q "Enabled" ; then
 		$pf_program -e
Index: pflog
===================================================================
RCS file: /home/cvs/src/etc/rc.d/pflog,v
retrieving revision 1.4
retrieving revision 1.5
diff -L etc/rc.d/pflog -L etc/rc.d/pflog -u -r1.4 -r1.5
--- etc/rc.d/pflog
+++ etc/rc.d/pflog
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/pflog,v 1.5.2.1 2006/01/22 13:40:47 yar Exp $
+# $FreeBSD: src/etc/rc.d/pflog,v 1.12 2007/04/09 08:53:40 des Exp $
 # $MidnightBSD$
 
 # PROVIDE: pflog
@@ -22,19 +22,11 @@
 
 pflog_prestart()
 {
-	# load pflog kernel module if needed
-	if ! kldstat -q -m pflog; then
-		if kldload pflog; then
-			info 'pflog module loaded.'
-		else
-			warn 'pflog module failed to load.'
-			return 1
-		fi
-	fi
+	load_kld pflog || return 1
 
 	# set pflog0 interface to up state
 	if ! ifconfig pflog0 up; then
-		warn 'could not not bring up pflog0.'
+		warn 'could not bring up pflog0.'
 		return 1
 	fi
 
--- /dev/null
+++ etc/rc.d/hostid
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $MidnightBSD: src/etc/rc.d/hostid,v 1.1 2009/01/17 17:30:24 laffer1 Exp $
+# $FreeBSD: src/etc/rc.d/hostid,v 1.7 2007/05/22 13:53:59 rse Exp $
+#
+
+# PROVIDE: hostid
+# REQUIRE: root
+# BEFORE: mountcritlocal
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+name="hostid"
+start_cmd="hostid_start"
+stop_cmd=":"
+reset_cmd="hostid_reset"
+extra_commands="reset"
+rcvar="hostid_enable"
+
+hostid_set()
+{
+	uuid=$1
+	# Generate hostid based on hostuuid - take first four bytes from md5(uuid).
+	id=`echo -n $uuid | md5`
+	id="0x${id%????????????????????????}"
+	# Set both kern.hostuuid and kern.hostid.
+	echo "Setting hostuuid: ${uuid}."
+	${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null
+	echo "Setting hostid: ${id}."
+	${SYSCTL_W} kern.hostid=${id} >/dev/null
+}
+
+hostid_hardware()
+{
+	uuid=`kenv smbios.system.uuid 2>/dev/null`
+	x="[0-9a-f]"
+	y=$x$x$x$x
+	case "${uuid}" in
+	$y$y-$y-$y-$y-$y$y$y)
+		echo "${uuid}"
+		;;
+	esac
+}
+
+hostid_reset()
+{
+	# First look for UUID in hardware.
+	uuid=`hostid_hardware`
+	if [ -z ${uuid} ]; then
+		# If not found, fall back to software-generated UUID.
+		uuid=`uuidgen`
+	fi
+	# Store newly generated UUID in ${hostid_file}.
+	echo $uuid > ${hostid_file}
+	if [ $? -ne 0 ]; then
+		warn "could not store hostuuid in ${hostid_file}."
+	fi
+	hostid_set $uuid
+}
+
+hostid_start()
+{
+	# If ${hostid_file} already exists, we take UUID from there.
+	if [ -r ${hostid_file} ]; then
+		hostid_set `cat ${hostid_file}`
+	else
+		# No hostid file, generate UUID.
+		hostid_reset
+	fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
Index: Makefile
===================================================================
RCS file: /home/cvs/src/etc/rc.d/Makefile,v
retrieving revision 1.11
retrieving revision 1.12
diff -L etc/rc.d/Makefile -L etc/rc.d/Makefile -u -r1.11 -r1.12
--- etc/rc.d/Makefile
+++ etc/rc.d/Makefile
@@ -13,9 +13,9 @@
 	firstboot fsck ftp-proxy ftpd \
 	gbde geli geli2 \
 	hcsecd \
-	hostapd hostname \
+	hostapd hostid hostname \
 	ike \
-	inetd initrandom \
+	idmapd inetd initrandom \
 	ip6addrctl ip6fw ipfilter ipfs ipfw ipmon \
 	ipnat ipsec ipxrouted isdnd \
 	jail \


More information about the Midnightbsd-cvs mailing list