summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-06-16 07:16:14 +0000
committerobrien <obrien@FreeBSD.org>2001-06-16 07:16:14 +0000
commitafad76ee76d3a58cf84a1bc6fb12c55552bc5563 (patch)
treefd0686de98f61bd8f248380d2e5aee4905a258bb
parent3cf81c35aeec9a68f04a9ff772f9d4eb26e3605b (diff)
downloadFreeBSD-src-afad76ee76d3a58cf84a1bc6fb12c55552bc5563.zip
FreeBSD-src-afad76ee76d3a58cf84a1bc6fb12c55552bc5563.tar.gz
Import the NetBSD 1.5 RC system.
Note that `rc' and `rc.shutdown' could not be imported because we already have files with those names.
-rwxr-xr-xetc/rc.d/DAEMON12
-rwxr-xr-xetc/rc.d/LOGIN15
-rwxr-xr-xetc/rc.d/Makefile20
-rwxr-xr-xetc/rc.d/NETWORK10
-rwxr-xr-xetc/rc.d/SERVERS10
-rwxr-xr-xetc/rc.d/accounting31
-rwxr-xr-xetc/rc.d/amd21
-rwxr-xr-xetc/rc.d/apmd16
-rwxr-xr-xetc/rc.d/bootconf.sh69
-rwxr-xr-xetc/rc.d/bootparams17
-rwxr-xr-xetc/rc.d/ccd23
-rwxr-xr-xetc/rc.d/cleartmp30
-rwxr-xr-xetc/rc.d/cron18
-rwxr-xr-xetc/rc.d/dhclient21
-rwxr-xr-xetc/rc.d/dhcpd18
-rwxr-xr-xetc/rc.d/dhcrelay17
-rwxr-xr-xetc/rc.d/dmesg23
-rwxr-xr-xetc/rc.d/fsck68
-rwxr-xr-xetc/rc.d/gated18
-rwxr-xr-xetc/rc.d/inetd20
-rwxr-xr-xetc/rc.d/ipfilter79
-rwxr-xr-xetc/rc.d/ipmon17
-rwxr-xr-xetc/rc.d/ipnat33
-rwxr-xr-xetc/rc.d/ipsec67
-rw-r--r--etc/rc.d/isdnd90
-rwxr-xr-xetc/rc.d/kdc18
-rwxr-xr-xetc/rc.d/ldconfig24
-rwxr-xr-xetc/rc.d/lkm139
-rwxr-xr-xetc/rc.d/lkm237
-rwxr-xr-xetc/rc.d/lkm327
-rwxr-xr-xetc/rc.d/local31
-rwxr-xr-xetc/rc.d/lpd18
-rwxr-xr-xetc/rc.d/mopd16
-rwxr-xr-xetc/rc.d/motd34
-rwxr-xr-xetc/rc.d/mountall16
-rwxr-xr-xetc/rc.d/mountcritlocal30
-rwxr-xr-xetc/rc.d/mountcritremote19
-rwxr-xr-xetc/rc.d/mountd26
-rwxr-xr-xetc/rc.d/mrouted19
-rwxr-xr-xetc/rc.d/named19
-rwxr-xr-xetc/rc.d/network387
-rwxr-xr-xetc/rc.d/newsyslog26
-rwxr-xr-xetc/rc.d/nfsd17
-rwxr-xr-xetc/rc.d/nfslocking27
-rwxr-xr-xetc/rc.d/ntpd18
-rwxr-xr-xetc/rc.d/ntpdate31
-rw-r--r--etc/rc.d/poffd17
-rwxr-xr-xetc/rc.d/postfix24
-rwxr-xr-xetc/rc.d/pwcheck26
-rwxr-xr-xetc/rc.d/quota24
-rwxr-xr-xetc/rc.d/racoon18
-rwxr-xr-xetc/rc.d/raidframe43
-rwxr-xr-xetc/rc.d/rarpd18
-rwxr-xr-xetc/rc.d/rbootd19
-rwxr-xr-xetc/rc.d/root23
-rwxr-xr-xetc/rc.d/route6d16
-rwxr-xr-xetc/rc.d/routed25
-rwxr-xr-xetc/rc.d/rpcbind17
-rwxr-xr-xetc/rc.d/rtadvd26
-rwxr-xr-xetc/rc.d/rtsold25
-rwxr-xr-xetc/rc.d/rwho16
-rwxr-xr-xetc/rc.d/savecore30
-rwxr-xr-xetc/rc.d/screenblank17
-rwxr-xr-xetc/rc.d/securelevel33
-rwxr-xr-xetc/rc.d/sendmail60
-rwxr-xr-xetc/rc.d/sshd48
-rwxr-xr-xetc/rc.d/swap123
-rwxr-xr-xetc/rc.d/swap235
-rw-r--r--etc/rc.d/sysctl47
-rwxr-xr-xetc/rc.d/sysdb34
-rwxr-xr-xetc/rc.d/syslogd31
-rwxr-xr-xetc/rc.d/timed16
-rwxr-xr-xetc/rc.d/ttys32
-rwxr-xr-xetc/rc.d/virecover29
-rwxr-xr-xetc/rc.d/wscons135
-rwxr-xr-xetc/rc.d/xdm20
-rwxr-xr-xetc/rc.d/xfs19
-rwxr-xr-xetc/rc.d/ypbind26
-rwxr-xr-xetc/rc.d/yppasswdd27
-rwxr-xr-xetc/rc.d/ypserv32
-rw-r--r--etc/rc.subr586
-rw-r--r--sbin/rcorder/Makefile13
-rw-r--r--sbin/rcorder/ealloc.c123
-rw-r--r--sbin/rcorder/ealloc.h6
-rw-r--r--sbin/rcorder/hash.c438
-rw-r--r--sbin/rcorder/hash.h130
-rw-r--r--sbin/rcorder/rcorder.8158
-rw-r--r--sbin/rcorder/rcorder.c819
-rw-r--r--sbin/rcorder/sprite.h113
89 files changed, 5015 insertions, 44 deletions
diff --git a/etc/rc.d/DAEMON b/etc/rc.d/DAEMON
new file mode 100755
index 0000000..5619e56
--- /dev/null
+++ b/etc/rc.d/DAEMON
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# $NetBSD: DAEMON,v 1.4 2000/08/21 23:39:07 lukem Exp $
+#
+
+# PROVIDE: DAEMON
+# REQUIRE: accounting aftermountlkm amd cleartmp dmesg ipmon
+# REQUIRE: ipnat ipsec ldconfig named network nonlocalswap nfslocking
+# REQUIRE: pwcheck quota savecore securelevel sysctl sysdb virecover ypbind
+
+# This is a dummy dependancy, to ensure that general purpose daemons
+# are run _after_ the above are.
diff --git a/etc/rc.d/LOGIN b/etc/rc.d/LOGIN
new file mode 100755
index 0000000..39fc88b
--- /dev/null
+++ b/etc/rc.d/LOGIN
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# $NetBSD: LOGIN,v 1.3 2000/07/20 23:36:56 lukem Exp $
+#
+
+# PROVIDE: LOGIN
+# REQUIRE: apmd bootparams dhcpd dhcrelay gated local lpd mopd motd
+# REQUIRE: mrouted ntpd rarpd rbootd route6d routed rtadvd rtsold
+# REQUIRE: rwho screenblank timed wscons xfs yppasswdd
+
+# This is a dummy dependancy to ensure user services such as xdm,
+# inetd, cron and kerberos are started after everything else, incase
+# the administrator has increased the system security level and
+# wants to delay user logins until the system is (almost) fully
+# operational.
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
new file mode 100755
index 0000000..9c26553
--- /dev/null
+++ b/etc/rc.d/Makefile
@@ -0,0 +1,20 @@
+# $NetBSD: Makefile,v 1.16 2001/01/14 15:37:22 minoura Exp $
+
+.include <bsd.own.mk>
+
+FILES= DAEMON LOGIN NETWORK SERVERS accounting amd apmd bootparams \
+ bootconf.sh ccd cleartmp cron dhclient dhcpd dhcrelay dmesg \
+ fsck gated inetd ipfilter ipmon ipnat ipsec isdnd kdc ldconfig \
+ lkm1 lkm2 lkm3 local lpd mopd motd mountall mountcritlocal \
+ mountcritremote mountd mrouted named network newsyslog nfsd \
+ nfslocking ntpd ntpdate rpcbind poffd postfix ppp pwcheck racoon \
+ quota raidframe rarpd rbootd root route6d routed rtadvd rtsold rwho \
+ savecore screenblank sendmail securelevel sshd swap1 swap2 sysdb \
+ sysctl syslogd timed ttys virecover wscons xdm xfs ypbind \
+ yppasswdd ypserv
+FILESDIR= /etc/rc.d
+FILESMODE= ${BINMODE}
+
+NOPROG= noprog
+
+.include <bsd.prog.mk>
diff --git a/etc/rc.d/NETWORK b/etc/rc.d/NETWORK
new file mode 100755
index 0000000..92040d2
--- /dev/null
+++ b/etc/rc.d/NETWORK
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: NETWORK
+# REQUIRE: network dhclient
+
+# This is a dummy dependancy, for services which require networking
+# to be operational before starting.
diff --git a/etc/rc.d/SERVERS b/etc/rc.d/SERVERS
new file mode 100755
index 0000000..99a9c17
--- /dev/null
+++ b/etc/rc.d/SERVERS
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# $NetBSD: SERVERS,v 1.4 2000/09/21 10:38:04 ad Exp $
+#
+
+# PROVIDE: SERVERS
+# REQUIRE: ipmon kdc newsyslog ppp savecore syslogd ike
+
+# This is a dummy dependancy, for early-start servers relying on
+# some basic configuration.
diff --git a/etc/rc.d/accounting b/etc/rc.d/accounting
new file mode 100755
index 0000000..aecb2ad
--- /dev/null
+++ b/etc/rc.d/accounting
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# $NetBSD: accounting,v 1.2 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: accounting
+# REQUIRE: mountall
+
+. /etc/rc.subr
+
+name="accounting"
+rcvar=$name
+start_cmd="accounting_start"
+stop_cmd="accounting_stop"
+
+accounting_start()
+{
+ if [ -f /var/account/acct ]; then
+ echo "Turning on accounting."
+ /usr/sbin/accton /var/account/acct
+ fi
+}
+
+accounting_stop()
+{
+ echo "Turning off accounting."
+ /usr/sbin/accton
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/amd b/etc/rc.d/amd
new file mode 100755
index 0000000..a674a24
--- /dev/null
+++ b/etc/rc.d/amd
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# $NetBSD: amd,v 1.6 2000/09/19 13:04:38 lukem Exp $
+#
+
+# PROVIDE: amd
+# REQUIRE: rpcbind mountall ypbind
+
+. /etc/rc.subr
+
+name="amd"
+rcvar=$name
+command="/usr/sbin/${name}"
+load_rc_config $name
+
+command_args='-p -a '$amd_dir' -F /etc/amd.conf >/var/run/amd.pid'
+required_files="/etc/amd.conf"
+required_dirs="$amd_dir"
+required_vars="rpcbind"
+
+run_rc_command "$1"
diff --git a/etc/rc.d/apmd b/etc/rc.d/apmd
new file mode 100755
index 0000000..01f26d1
--- /dev/null
+++ b/etc/rc.d/apmd
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: apmd,v 1.3 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: apmd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="apmd"
+rcvar=$name
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/bootconf.sh b/etc/rc.d/bootconf.sh
new file mode 100755
index 0000000..8f663ca
--- /dev/null
+++ b/etc/rc.d/bootconf.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# $NetBSD: bootconf.sh,v 1.2 2000/08/21 23:34:45 lukem Exp $
+#
+
+# PROVIDE: bootconf
+# REQUIRE: mountcritlocal
+
+bootconf_start()
+{
+ # Refer to newbtconf(8) for more information
+ #
+
+ if [ ! -e /etc/etc.current ]; then
+ return 0
+ fi
+ if [ -h /etc/etc.default ]; then
+ def=`ls -ld /etc/etc.default 2>&1`
+ default="${def##*-> etc.}"
+ else
+ default=current
+ fi
+ spc=""
+ for i in /etc/etc.*
+ do
+ name="${i##/etc/etc.}"
+ case $name in
+ current|default|\*)
+ continue
+ ;;
+ *)
+ if [ "$name" = "$default" ]; then
+ echo -n "${spc}[${name}]"
+ else
+ echo -n "${spc}${name}"
+ fi
+ spc=" "
+ ;;
+ esac
+ done
+ echo
+ master=$$
+ _DUMMY=/etc/passwd
+ conf=${_DUMMY}
+ while [ ! -d /etc/etc.$conf/. ]; do
+ trap "conf=$default; echo; echo Using default of $conf" 14
+ echo -n "Which configuration [$default] ? "
+ (sleep 30 && kill -ALRM $master) >/dev/null 2>&1 &
+ read conf
+ trap : 14
+ if [ -z $conf ] ; then
+ conf=$default
+ fi
+ if [ ! -d /etc/etc.$conf/. ]; then
+ conf=${_DUMMY}
+ fi
+ done
+ rm -f /etc/etc.current
+ ln -s /etc/etc.$conf /etc/etc.current
+ if [ -f /etc/rc.conf ] ; then
+ . /etc/rc.conf
+ fi
+}
+
+case "$1" in
+*start)
+ bootconf_start
+ ;;
+esac
diff --git a/etc/rc.d/bootparams b/etc/rc.d/bootparams
new file mode 100755
index 0000000..2f27d4f
--- /dev/null
+++ b/etc/rc.d/bootparams
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: bootparams,v 1.4 2000/06/02 22:54:11 fvdl Exp $
+#
+
+# PROVIDE: bootparams
+# REQUIRE: rpcbind DAEMON
+
+. /etc/rc.subr
+
+name="bootparamd"
+rcvar=$name
+command="/usr/sbin/rpc.${name}"
+required_files="/etc/bootparams"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ccd b/etc/rc.d/ccd
new file mode 100755
index 0000000..57c6406
--- /dev/null
+++ b/etc/rc.d/ccd
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $NetBSD: ccd,v 1.2 2000/04/26 05:13:51 thorpej Exp $
+#
+
+# PROVIDE: disks
+
+. /etc/rc.subr
+
+name="ccd"
+start_cmd="ccd_start"
+stop_cmd=":"
+
+ccd_start()
+{
+ if [ -f /etc/ccd.conf ]; then
+ echo "Configuring CCD devices."
+ ccdconfig -C
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/cleartmp b/etc/rc.d/cleartmp
new file mode 100755
index 0000000..943e5ca
--- /dev/null
+++ b/etc/rc.d/cleartmp
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# $NetBSD: cleartmp,v 1.2 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: cleartmp
+# REQUIRE: mountall
+
+. /etc/rc.subr
+
+name="cleartmp"
+rcvar="clear_tmp"
+start_cmd="cleartmp_start"
+stop_cmd=":"
+
+cleartmp_start()
+{
+ echo "Clearing /tmp."
+ #
+ # Prune quickly with one rm, then use find to clean up
+ # /tmp/[lq]* (this is not needed with mfs /tmp, but
+ # doesn't hurt anything).
+ #
+ (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
+ find -x . ! -name . ! -name lost+found ! -name quota.user \
+ ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/cron b/etc/rc.d/cron
new file mode 100755
index 0000000..9363443
--- /dev/null
+++ b/etc/rc.d/cron
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: cron,v 1.4 2000/07/17 15:24:48 lukem Exp $
+#
+
+# PROVIDE: cron
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="cron"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient
new file mode 100755
index 0000000..453062e
--- /dev/null
+++ b/etc/rc.d/dhclient
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# $NetBSD: dhclient,v 1.6 2000/07/26 00:11:49 lukem Exp $
+#
+
+# PROVIDE: dhclient
+# REQUIRE: network mountcritlocal
+#
+# Note that there no syslog logging of dhclient messages at boot because
+# dhclient needs to start before services that syslog depends upon do.
+#
+
+. /etc/rc.subr
+
+name="dhclient"
+rcvar=$name
+command="/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/dhcpd b/etc/rc.d/dhcpd
new file mode 100755
index 0000000..1126769
--- /dev/null
+++ b/etc/rc.d/dhcpd
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: dhcpd,v 1.3 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: dhcpd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="dhcpd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf /var/db/${name}.leases"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/dhcrelay b/etc/rc.d/dhcrelay
new file mode 100755
index 0000000..4d76dba
--- /dev/null
+++ b/etc/rc.d/dhcrelay
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: dhcrelay,v 1.3 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: dhcrelay
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="dhcrelay"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/dmesg b/etc/rc.d/dmesg
new file mode 100755
index 0000000..41ad00f
--- /dev/null
+++ b/etc/rc.d/dmesg
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $NetBSD: dmesg,v 1.4 2000/07/26 00:11:49 lukem Exp $
+#
+
+# PROVIDE: dmesg
+# REQUIRE: mountcritremote
+
+. /etc/rc.subr
+
+name="dmesg"
+rcvar=$name
+start_cmd="do_dmesg"
+stop_cmd=":"
+
+do_dmesg()
+{
+ rm -f /var/run/dmesg.boot
+ dmesg $dmesg_flags > /var/run/dmesg.boot
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/fsck b/etc/rc.d/fsck
new file mode 100755
index 0000000..ddd4302
--- /dev/null
+++ b/etc/rc.d/fsck
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: fsck
+# REQUIRE: localswap
+
+. /etc/rc.subr
+
+name="fsck"
+start_cmd="fsck_start"
+stop_cmd=":"
+
+stop_boot()
+{
+ # Terminate the process (which may include the parent /etc/rc)
+ # if booting directly to multiuser mode.
+ #
+ if [ "$autoboot" = yes ]; then
+ kill -TERM $$
+ fi
+ exit 1
+}
+
+fsck_start()
+{
+ if [ -e /fastboot ]; then
+ echo "Fast boot: skipping disk checks."
+ elif [ "$autoboot" = yes ]; then
+ # During fsck ignore SIGQUIT
+ trap : 3
+
+ echo "Automatic boot in progress: starting file system checks."
+ fsck -p
+ case $? in
+ 0)
+ ;;
+ 2)
+ stop_boot
+ ;;
+ 4)
+ echo "Rebooting..."
+ reboot
+ echo "Reboot failed; help!"
+ stop_boot
+ ;;
+ 8)
+ echo "Automatic file system check failed; help!"
+ stop_boot
+ ;;
+ 12)
+ echo "Boot interrupted."
+ stop_boot
+ ;;
+ 130)
+ stop_boot
+ ;;
+ *)
+ echo "Unknown error; help!"
+ stop_boot
+ ;;
+ esac
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/gated b/etc/rc.d/gated
new file mode 100755
index 0000000..7a11e8c
--- /dev/null
+++ b/etc/rc.d/gated
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: gated,v 1.3 2000/05/13 08:45:06 lukem Exp $
+#
+
+# PROVIDE: gated
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="gated"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/inetd b/etc/rc.d/inetd
new file mode 100755
index 0000000..8f6249f
--- /dev/null
+++ b/etc/rc.d/inetd
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# $NetBSD: inetd,v 1.5 2000/07/17 15:24:48 lukem Exp $
+#
+
+# PROVIDE: inetd
+# REQUIRE: DAEMON LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="inetd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ipfilter b/etc/rc.d/ipfilter
new file mode 100755
index 0000000..a2d0c20
--- /dev/null
+++ b/etc/rc.d/ipfilter
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# $NetBSD: ipfilter,v 1.8 2000/10/01 05:58:06 lukem Exp $
+#
+
+# PROVIDE: ipfilter
+# REQUIRE: root beforenetlkm mountcritlocal tty
+
+. /etc/rc.subr
+
+name="ipfilter"
+rcvar=$name
+start_precmd="ipfilter_prestart"
+start_cmd="ipfilter_start"
+stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf"
+stop_cmd="ipfilter_stop"
+reload_precmd="$stop_precmd"
+reload_cmd="ipfilter_reload"
+status_precmd="$stop_precmd"
+status_cmd="ipfilter_status"
+extra_commands="reload status"
+
+ipfilter_prestart()
+{
+ if [ ! -f /etc/ipf.conf ] && [ ! -f /etc/ipf6.conf ]; then
+ warn "/etc/ipf*.conf not readable; ipfilter start aborted."
+ #
+ # If booting directly to multiuser, send SIGTERM to
+ # the parent (/etc/rc) to abort the boot
+ #
+ if [ "$autoboot" = yes ]; then
+ echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
+ kill -TERM $$
+ exit 1
+ fi
+ return 1
+ fi
+ return 0
+}
+
+ipfilter_start()
+{
+ echo "Enabling ipfilter."
+ /sbin/ipf -E -Fa
+ if [ -f /etc/ipf.conf ]; then
+ /sbin/ipf -f /etc/ipf.conf
+ fi
+ if [ -f /etc/ipf6.conf ]; then
+ /sbin/ipf -6 -f /etc/ipf6.conf
+ fi
+}
+
+ipfilter_stop()
+{
+ echo "Disabling ipfilter."
+ /sbin/ipf -D
+}
+
+ipfilter_reload()
+{
+ echo "Reloading ipfilter rules."
+
+ /sbin/ipf -I -Fa
+ if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -f /etc/ipf.conf; then
+ err 1 "reload of ipf.conf failed; not swapping to new ruleset."
+ fi
+ if [ -f /etc/ipf6.conf ] && ! /sbin/ipf -I -6 -f /etc/ipf6.conf; then
+ err 1 "reload of ipf6.conf failed; not swapping to new ruleset."
+ fi
+ /sbin/ipf -s
+}
+
+ipfilter_status()
+{
+ /sbin/ipf -V
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ipmon b/etc/rc.d/ipmon
new file mode 100755
index 0000000..6f635c5
--- /dev/null
+++ b/etc/rc.d/ipmon
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: ipmon,v 1.2 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: ipmon
+# REQUIRE: syslogd
+
+. /etc/rc.subr
+
+name="ipmon"
+rcvar=$name
+command="/usr/sbin/${name}"
+command_args="&"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ipnat b/etc/rc.d/ipnat
new file mode 100755
index 0000000..1ac21c0
--- /dev/null
+++ b/etc/rc.d/ipnat
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $NetBSD: ipnat,v 1.5 2000/08/21 23:33:50 lukem Exp $
+#
+
+# PROVIDE: ipnat
+# REQUIRE: ipfilter mountcritremote
+
+. /etc/rc.subr
+
+name="ipnat"
+rcvar=$name
+config="/etc/ipnat.conf"
+start_cmd="ipnat_start"
+stop_cmd="/usr/sbin/ipnat -F -C"
+reload_cmd="/usr/sbin/ipnat -F -C -f ${config}"
+extra_commands="reload"
+
+ipnat_start()
+{
+ if [ ! -f ${config} ]; then
+ return 0
+ fi
+ if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then
+ echo "Enabling ipfilter for NAT."
+ /sbin/ipf -E -Fa
+ fi
+ echo -n "Installing NAT rules ... "
+ /usr/sbin/ipnat -F -f ${config}
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ipsec b/etc/rc.d/ipsec
new file mode 100755
index 0000000..01313f9
--- /dev/null
+++ b/etc/rc.d/ipsec
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# $NetBSD: ipsec,v 1.5 2000/07/21 01:16:07 lukem Exp $
+#
+
+# PROVIDE: ipsec
+# REQUIRE: root beforenetlkm mountcritlocal tty
+
+# it does not really require beforenetlkm.
+
+. /etc/rc.subr
+
+name="ipsec"
+rcvar=$name
+start_precmd="ipsec_prestart"
+start_cmd="ipsec_start"
+stop_precmd="test -f /etc/ipsec.conf"
+stop_cmd="ipsec_stop"
+reload_cmd="ipsec_reload"
+extra_commands="reload"
+
+ipsec_prestart()
+{
+ if [ ! -f /etc/ipsec.conf ]; then
+ warn "/etc/ipsec.conf not readable; ipsec start aborted."
+ #
+ # If booting directly to multiuser, send SIGTERM to
+ # the parent (/etc/rc) to abort the boot
+ #
+ if [ "$autoboot" = yes ]; then
+ echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
+ kill -TERM $$
+ exit 1
+ fi
+ return 1
+ fi
+ return 0
+}
+
+ipsec_start()
+{
+ echo "Installing ipsec manual keys/policies."
+ /sbin/setkey -f /etc/ipsec.conf
+}
+
+ipsec_stop()
+{
+ echo "Clearing ipsec manual keys/policies."
+
+ # still not 100% sure if we would like to do this.
+ # it is very questionable to do this during shutdown session, since
+ # it can hang any of remaining IPv4/v6 session.
+ #
+ /sbin/setkey -F
+ /sbin/setkey -FP
+}
+
+ipsec_reload()
+{
+ echo "Reloading ipsec manual keys/policies."
+ /sbin/setkey -F
+ /sbin/setkey -FP
+ /sbin/setkey -f /etc/ipsec.conf
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/isdnd b/etc/rc.d/isdnd
index ec159cc..87c8a40 100644
--- a/etc/rc.d/isdnd
+++ b/etc/rc.d/isdnd
@@ -1,44 +1,66 @@
#!/bin/sh
-#---------------------------------------------------------------------------
#
-# /etc/rc.isdn - isdn4bsd startup script
-# --------------------------------------
+# $NetBSD: isdnd,v 1.2 2001/01/07 17:53:36 martin Exp $
#
-# last edit-date: [Tue Jan 12 15:35:36 1999]
-#
-# $Id:$
-#
-#---------------------------------------------------------------------------
-if [ "X${isdn_enable}" = X"YES" ] ; then
+# PROVIDE: isdnd
+# REQUIRE: NETWORK syslogd mountcritremote
- # terminal type for fullscreen mode, default to syscons driver
- isdn_ttype=cons25
+. /etc/rc.subr
- # check for pcvt driver (VT100/VT220 emulator)
- if [ -x /usr/sbin/ispcvt ] ; then
- if /usr/sbin/ispcvt ; then
- isdn_ttype=pcvt25
- fi
- fi
-
- if [ "X${isdn_flags}" = X"NO" ] ; then
- isdn_flags=""
- fi
+name="isdnd"
+rcvar=$name
+required_files="/etc/isdn/${name}.rc"
+
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
+
+if checkyesno isdnd && checkyesno isdn_autoupdown; then
- # start the isdn daemon
- if [ -x /usr/sbin/isdnd ] ; then
- echo -n ' isdnd'
- if [ "X${isdn_fsdev}" = X"NO" ] ; then
- /usr/sbin/isdnd ${isdn_flags}
- else
- /usr/sbin/isdnd ${isdn_flags} -f -r ${isdn_fsdev} -t ${isdn_ttype}
- fi
- fi
+ # The isdn network interfaces could not be marked UP in the
+ # ifconfig.* files, since the daemon wasn't available then.
+ # If we are doing start: now it's running, so figure which
+ # interfaces these applies to and UP them. If doing stop:
+ # down them (for symetry, and effectively they are down).
- # start isdntrace
- if [ "X${isdn_trace}" = X"YES" -a -x /usr/sbin/isdntrace ] ; then
- echo -n ' isdntrace'
- nohup /usr/sbin/isdntrace ${isdn_traceflags} >/dev/null 2>&1 &
+ case "$_arg" in
+ start)
+ ifflag="-d"
+ ifcmd="up"
+ ;;
+ stop)
+ ifflag="-u"
+ ifcmd="down"
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+
+ if [ -z "$isdn_interfaces" ]; then
+ # the user has not specified a list of interface
+ # to track isdnd - try to figure ourselfs
+ tmp=`ifconfig -l $ifflag`
+ for int in $tmp; do
+ # Check if the interface has been configured at all
+ # XXX - does this work with IPv6 ?
+ if ifconfig $int | fgrep inet >/dev/null; then
+ case $int in
+ isp*)
+ isdn_interfaces="$isdn_interfaces $int"
+ ;;
+ ipr*)
+ isdn_interfaces="$isdn_interfaces $int"
+ ;;
+ esac
+ fi
+ done
fi
+ for int in $isdn_interfaces; do
+ ifconfig $int $ifcmd
+ done
fi
+
diff --git a/etc/rc.d/kdc b/etc/rc.d/kdc
new file mode 100755
index 0000000..0d887f3
--- /dev/null
+++ b/etc/rc.d/kdc
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: kdc,v 1.2 2000/09/19 13:04:38 lukem Exp $
+#
+
+# PROVIDE: kdc
+# REQUIRE: NETWORK
+
+. /etc/rc.subr
+
+name="kdc"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/krb5.conf"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ldconfig b/etc/rc.d/ldconfig
new file mode 100755
index 0000000..73cbba5
--- /dev/null
+++ b/etc/rc.d/ldconfig
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# $NetBSD: ldconfig,v 1.2 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: ldconfig
+# REQUIRE: mountall
+
+. /etc/rc.subr
+
+name="ldconfig"
+start_cmd="ldconfig_start"
+stop_cmd=":"
+
+ldconfig_start()
+{
+ if [ -f /sbin/ldconfig ]; then
+ echo "Creating a.out runtime link editor directory cache."
+ ldconfig
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/lkm1 b/etc/rc.d/lkm1
new file mode 100755
index 0000000..8e71daf
--- /dev/null
+++ b/etc/rc.d/lkm1
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# $NetBSD: lkm1,v 1.5 2000/09/19 13:04:38 lukem Exp $
+#
+
+# PROVIDE: beforenetlkm
+# REQUIRE: root bootconf
+
+. /etc/rc.subr
+
+name="lkm1"
+rcvar="lkm"
+start_cmd="lkm1_start"
+stop_cmd="lkm1_stop"
+
+lkm1_start()
+{
+# load kernel modules specified in /etc/lkm.conf if the /usr
+# filesystem is already present with "/" or can be mounted now
+#
+ if [ -f /etc/rc.lkm ]; then
+ mount /usr >/dev/null 2>&1
+ if [ -x /usr/bin/ld ]; then
+ lkmstage=BEFORENET
+ set start ; . /etc/rc.lkm
+ fi
+ fi
+}
+
+lkm1_stop()
+{
+ if [ -f /etc/rc.lkm ] && [ -x /usr/bin/ld ]; then
+ lkmstage=BEFORENET
+ set stop ; . /etc/rc.lkm
+ fi
+}
+
+load_rc_config lkm
+run_rc_command "$1"
diff --git a/etc/rc.d/lkm2 b/etc/rc.d/lkm2
new file mode 100755
index 0000000..b7b69b9
--- /dev/null
+++ b/etc/rc.d/lkm2
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# $NetBSD: lkm2,v 1.3 2000/07/15 02:30:18 lukem Exp $
+#
+
+# PROVIDE: beforemountlkm
+# REQUIRE: syslogd
+
+. /etc/rc.subr
+
+name="lkm2"
+rcvar="lkm"
+start_cmd="lkm2_start"
+stop_cmd="lkm2_stop"
+
+# load kernel modules specified in /etc/lkm.conf
+#
+lkm2_start()
+{
+ if [ -r /etc/rc.lkm ]; then
+ lkmstage=BEFOREMOUNT
+ set start ; . /etc/rc.lkm
+ else
+ warn "/etc/rc.lkm not found; LKMs not loaded."
+ fi
+}
+
+lkm2_stop()
+{
+ if [ -r /etc/rc.lkm ]; then
+ lkmstage=BEFOREMOUNT
+ set stop ; . /etc/rc.lkm
+ fi
+}
+
+load_rc_config lkm
+run_rc_command "$1"
diff --git a/etc/rc.d/lkm3 b/etc/rc.d/lkm3
new file mode 100755
index 0000000..a02e0dc
--- /dev/null
+++ b/etc/rc.d/lkm3
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# $NetBSD: lkm3,v 1.4 2000/07/15 02:30:18 lukem Exp $
+#
+
+# PROVIDE: aftermountlkm
+# REQUIRE: mountall
+
+. /etc/rc.subr
+
+name="lkm3"
+rcvar="lkm"
+start_cmd="do_lkm3 start"
+stop_cmd="do_lkm3 stop"
+
+do_lkm3()
+{
+ # (un)load kernel modules specified in /etc/lkm.conf
+ #
+ if [ -f /etc/rc.lkm ]; then
+ lkmstage=AFTERMOUNT
+ set $1 ; . /etc/rc.lkm
+ fi
+}
+
+load_rc_config lkm
+run_rc_command "$1"
diff --git a/etc/rc.d/local b/etc/rc.d/local
new file mode 100755
index 0000000..8d6926f
--- /dev/null
+++ b/etc/rc.d/local
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# $NetBSD: local,v 1.4 2000/05/13 08:45:07 lukem Exp $
+#
+
+# REQUIRE: DAEMON
+# PROVIDE: local
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="local"
+start_cmd="local_start"
+stop_cmd="local_stop"
+
+local_start()
+{
+ if [ -f /etc/rc.local ]; then
+ . /etc/rc.local
+ fi
+}
+
+local_stop()
+{
+ if [ -f /etc/rc.shutdown.local ]; then
+ . /etc/rc.shutdown.local
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/lpd b/etc/rc.d/lpd
new file mode 100755
index 0000000..83a543a
--- /dev/null
+++ b/etc/rc.d/lpd
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: lpd,v 1.3 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: lpd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="lpd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/printcap"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mopd b/etc/rc.d/mopd
new file mode 100755
index 0000000..888c4d6
--- /dev/null
+++ b/etc/rc.d/mopd
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: mopd,v 1.3 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: mopd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="mopd"
+rcvar=$name
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/motd b/etc/rc.d/motd
new file mode 100755
index 0000000..f000364
--- /dev/null
+++ b/etc/rc.d/motd
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $
+#
+
+# PROVIDE: motd
+# REQUIRE: mountcritremote
+
+. /etc/rc.subr
+
+name="motd"
+rcvar="update_motd"
+start_cmd="motd_start"
+stop_cmd=":"
+
+motd_start()
+{
+ # Update kernel info in /etc/motd
+ # Must be done *before* interactive logins are possible
+ # to prevent possible race conditions.
+ #
+ echo "Updating motd."
+ if [ ! -f /etc/motd ]; then
+ install -c -o root -g wheel -m 664 /dev/null /etc/motd
+ fi
+ T=/etc/_motd
+ sysctl -n kern.version | while read i; do echo $i; break; done > $T
+ sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T
+ cmp -s $T /etc/motd || cp $T /etc/motd
+ rm -f $T
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mountall b/etc/rc.d/mountall
new file mode 100755
index 0000000..2fd80eb
--- /dev/null
+++ b/etc/rc.d/mountall
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: mountall,v 1.2 2000/04/27 21:00:50 veego Exp $
+#
+
+# PROVIDE: mountall
+# REQUIRE: beforemountlkm
+
+. /etc/rc.subr
+
+name="mountall"
+start_cmd="echo 'Mounting all filesystems...'; mount -a"
+stop_cmd="echo 'Unmounting all filesystems...'; umount -a"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mountcritlocal b/etc/rc.d/mountcritlocal
new file mode 100755
index 0000000..38b75f4
--- /dev/null
+++ b/etc/rc.d/mountcritlocal
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# $NetBSD: mountcritlocal,v 1.3 2000/07/26 00:11:49 lukem Exp $
+#
+
+# PROVIDE: mountcritlocal
+# REQUIRE: root
+
+. /etc/rc.subr
+
+name="mountcritlocal"
+start_cmd="mountcritlocal_start"
+stop_cmd=":"
+
+mountcritlocal_start()
+{
+ # mount critical local filesystems
+ # (as specified in $critical_filesystems_beforenet)
+ #
+ mount_critical_filesystems local
+
+ # clean up left-over files.
+ # this could include the cleanup of lock files and /var/run, etc.
+ #
+ rm -f /etc/nologin /var/spool/lock/LCK.* /var/spool/uucp/STST/*
+ (cd /var/run && rm -rf -- *)
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mountcritremote b/etc/rc.d/mountcritremote
new file mode 100755
index 0000000..6479ea1
--- /dev/null
+++ b/etc/rc.d/mountcritremote
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $NetBSD: mountcritremote,v 1.2 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: mountcritremote
+# REQUIRE: NETWORK root mountcritlocal
+
+. /etc/rc.subr
+
+# mount critical remote filesystems
+# (as specified in $critical_filesystems)
+#
+name="mountcritremote"
+start_cmd="mount_critical_filesystems remote"
+stop_cmd=":"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mountd b/etc/rc.d/mountd
new file mode 100755
index 0000000..d1a64bf
--- /dev/null
+++ b/etc/rc.d/mountd
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $NetBSD: mountd,v 1.6 2000/06/02 22:54:11 fvdl Exp $
+#
+
+# PROVIDE: mountd
+# REQUIRE: NETWORK mountall beforemountlkm rpcbind quota
+
+. /etc/rc.subr
+
+name="mountd"
+rcvar="nfs_server"
+command="/usr/sbin/${name}"
+required_files="/etc/exports"
+start_precmd="mountd_precmd"
+extra_commands="reload"
+
+mountd_precmd()
+{
+ rm -f /var/db/mountdtab
+ echo -n > /var/db/mountdtab
+ return 0
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/mrouted b/etc/rc.d/mrouted
new file mode 100755
index 0000000..8239384
--- /dev/null
+++ b/etc/rc.d/mrouted
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $NetBSD: mrouted,v 1.4 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: mrouted
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="mrouted"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/named b/etc/rc.d/named
new file mode 100755
index 0000000..b311822
--- /dev/null
+++ b/etc/rc.d/named
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $NetBSD: named,v 1.5 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: named
+# REQUIRE: SERVERS
+
+. /etc/rc.subr
+
+name="named"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/network b/etc/rc.d/network
new file mode 100755
index 0000000..c9856b6
--- /dev/null
+++ b/etc/rc.d/network
@@ -0,0 +1,387 @@
+#!/bin/sh
+#
+# $NetBSD: network,v 1.29 2001/01/11 17:56:16 itojun Exp $
+#
+
+# PROVIDE: network
+# REQUIRE: ipfilter ipsec mountcritlocal root tty sysctl
+
+. /etc/rc.subr
+
+name="network"
+start_cmd="network_start"
+stop_cmd="network_stop"
+
+network_start()
+{
+ # set hostname, turn on network
+ #
+ echo "Starting network."
+
+ # If $hostname is set, use it for my Internet name,
+ # otherwise use /etc/myname
+ #
+ if [ -z "$hostname" ] && [ -f /etc/myname ]; then
+ hostname=`cat /etc/myname`
+ fi
+ if [ -n "$hostname" ]; then
+ echo "Hostname: $hostname"
+ hostname $hostname
+ else
+ # Don't warn about it if we're going to run
+ # DHCP later, as we will probably get the
+ # hostname at that time.
+ #
+ if ! checkyesno dhclient && [ -z "`hostname`" ]; then
+ warn "\$hostname not set."
+ fi
+ fi
+
+ # Check $domainname first, then /etc/defaultdomain,
+ # for NIS/YP domain name
+ #
+ if [ -z "$domainname" ] && [ -f /etc/defaultdomain ]; then
+ domainname=`cat /etc/defaultdomain`
+ fi
+ if [ -n "$domainname" ]; then
+ echo "NIS domainname: $domainname"
+ domainname $domainname
+ fi
+
+ # Flush all routes just to make sure it is clean
+ if checkyesno flushroutes; then
+ route -n flush
+ fi
+
+ # Set the address for the first loopback interface, so that the
+ # auto-route from a newly configured interface's address to lo0
+ # works correctly.
+ #
+ # NOTE: obscure networking problems may occur if lo0 isn't configured...
+ #
+ ifconfig lo0 inet 127.0.0.1
+
+ # According to RFC1122, 127.0.0.0/8 should not leave the node.
+ #
+ route add -inet 127.0.0.0 -netmask 0xff000000 127.0.0.1 -reject
+
+ # IPv6 routing setups, and host/router mode selection.
+ #
+ if ifconfig lo0 inet6 >/dev/null 2>&1; then
+ # We have IPv6 support in kernel.
+
+ # disallow link-local unicast dest without outgoing scope
+ # identifiers.
+ #
+ route add -inet6 fe80:: -prefixlen 10 ::1 -reject
+
+ # disallow site-local unicast dest without outgoing scope
+ # identifiers.
+ # If you configure site-locals without scope id (it is
+ # permissible config for routers that are not on scope
+ # boundary), you may want to comment the following one out.
+ #
+ if ! checkyesno ip6sitelocal; then
+ route add -inet6 fec0:: -prefixlen 10 ::1 -reject
+ fi
+
+ # disallow "internal" addresses to appear on the wire.
+ #
+ route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
+
+ # disallow packets to malicious IPv4 compatible prefix
+ #
+ route add -inet6 ::224.0.0.0 -prefixlen 100 ::1 -reject
+ route add -inet6 ::127.0.0.0 -prefixlen 104 ::1 -reject
+ route add -inet6 ::0.0.0.0 -prefixlen 104 ::1 -reject
+ route add -inet6 ::255.0.0.0 -prefixlen 104 ::1 -reject
+
+ # disallow packets to malicious 6to4 prefix
+ #
+ route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject
+ route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject
+ route add -inet6 2002:0000:: -prefixlen 24 ::1 -reject
+ route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject
+
+ # Completely disallow packets to IPv4 compatible prefix.
+ # This may conflict with RFC1933 under following circumstances:
+ # (1) An IPv6-only KAME node tries to originate packets to IPv4
+ # comatible destination. The KAME node has no IPv4
+ # compatible support. Under RFC1933, it should transmit
+ # native IPv6 packets toward IPv4 compatible destination,
+ # hoping it would reach a router that forwards the packet
+ # toward auto-tunnel interface.
+ # (2) An IPv6-only node originates a packet to IPv4 compatible
+ # destination. A KAME node is acting as an IPv6 router, and
+ # asked to forward it.
+ # Due to rare use of IPv4 compatible address, and security
+ # issues with it, we disable it by default.
+ #
+ route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
+
+ sysctl -w net.inet6.ip6.forwarding=0 >/dev/null
+ sysctl -w net.inet6.ip6.accept_rtadv=0 >/dev/null
+
+ # backward compatibility
+ #
+ if [ -z "$ip6mode" ] && [ -n "$ip6forwarding" ]; then
+ warn 'Please migrate to newer rc.conf' \
+ '(use ip6mode, not ip6forwarding)'
+ if checkyesno ip6forwarding; then
+ ip6mode=router
+ elif checkyesno rtsol; then
+ ip6mode=autohost
+ else
+ ip6mode=host
+ fi
+ fi
+
+ case $ip6mode in
+ router)
+ echo 'IPv6 mode: router'
+ sysctl -w net.inet6.ip6.forwarding=1 >/dev/null
+ ;;
+
+ autohost)
+ echo 'IPv6 mode: autoconfigured host'
+ sysctl -w net.inet6.ip6.accept_rtadv=1 >/dev/null
+ ;;
+
+ host)
+ echo 'IPv6 mode: host'
+ ;;
+
+ *) echo 'WARNING: invalid value in ip6mode'
+ ;;
+
+ esac
+ fi
+
+ # Configure all of the network interfaces listed in $net_interfaces;
+ # if $auto_ifconfig is YES, grab all interfaces from ifconfig.
+ # In the following, "xxN" stands in for interface names, like "le0".
+ # For any interfaces that has an $ifconfig_xxN variable associated,
+ # we do "ifconfig xxN $ifconfig_xxN".
+ # If there is no such variable, we take the contents of the file
+ # /etc/ifconfig.xxN, and run "ifconfig xxN" repeatedly, using each
+ # line of the file as the arguments for a seperate "ifconfig"
+ # invocation.
+ #
+ # In order to configure an interface reasonably, you at the very least
+ # need to specify "[addr_family] [hostname]" (e.g "inet my.domain.org"),
+ # and probably a netmask (as in "netmask 0xffffffe0"). You will
+ # frequently need to specify a media type, as in "media UTP", for
+ # interface cards with multiple media connections that do not
+ # autoconfigure. See the ifconfig manual page for details.
+ #
+ # Note that /etc/ifconfig.xxN takes multiple lines. The following
+ # configuration is possible:
+ # inet 10.1.1.1 netmask 0xffffff00
+ # inet 10.1.1.2 netmask 0xffffff00 alias
+ # inet6 fec0::1 prefixlen 64 alias
+ #
+ # You can put shell script fragment into /etc/ifconfig.xxN by
+ # starting a line with "!". Refer to ifconfig.if(5) for details.
+ #
+ if [ "$net_interfaces" != NO ]; then
+ if checkyesno auto_ifconfig; then
+ tmp=`ifconfig -l`
+ for cloner in `ifconfig -C 2>/dev/null`; do
+ for int in /etc/ifconfig.${cloner}[0-9]*; do
+ [ ! -f $int ] && break
+ tmp="$tmp ${int##*.}"
+ done
+ done
+ else
+ tmp="$net_interfaces"
+ fi
+ echo -n 'Configuring network interfaces:'
+ for int in $tmp; do
+ eval args=\$ifconfig_$int
+ if [ -n "$args" ]; then
+ echo -n " $int"
+ ifconfig $int $args
+ elif [ -f /etc/ifconfig.$int ]; then
+ echo -n " $int"
+ while read args; do
+ [ -z "$args" ] && continue
+ case "$args" in
+ "#"*)
+ ;;
+ "!"*)
+ eval ${args#*!}
+ ;;
+ *)
+ ifconfig $int $args
+ ;;
+ esac
+ done < /etc/ifconfig.$int
+ else
+ if ! checkyesno auto_ifconfig; then
+ echo
+ warn \
+ "/etc/ifconfig.$int missing and ifconfig_$int not set;"
+ warn "interface $int not configured."
+ fi
+ continue
+ fi
+ configured_interfaces="$configured_interfaces $int"
+ done
+ echo "."
+ fi
+
+ # Check $defaultroute, then /etc/mygate, for the name of my gateway
+ # host. That name must be in /etc/hosts.
+ #
+ if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then
+ defaultroute=`cat /etc/mygate`
+ fi
+ if [ -n "$defaultroute" ]; then
+ route add default $defaultroute
+ fi
+
+ # Check if each configured interface xxN has an $ifaliases_xxN variable
+ # associated, then configure additional IP addresses for that interface.
+ # The variable contains a list of "address netmask" pairs, with
+ # "netmask" set to "-" if the interface default netmask is to be used.
+ #
+ # Note that $ifaliases_xxN works only with certain configurations and
+ # considered not recommended. Use /etc/ifconfig.xxN if possible.
+ #
+ #
+ if [ -n "$configured_interfaces" ]; then
+ echo "Adding interface aliases:"
+ done_aliases_message=yes
+ fi
+ for int in $configured_interfaces; do
+ eval args=\$ifaliases_$int
+ if [ -n "$args" ]; then
+ set -- $args
+ while [ $# -ge 2 ]; do
+ addr=$1 ; net=$2 ; shift 2
+ if [ "$net" = "-" ]; then
+ # for compatibility only, obsolete
+ ifconfig $int inet alias $addr
+ else
+ ifconfig $int inet alias $addr \
+ netmask $net
+ fi
+ # Use loopback, not the wire
+ route add $addr 127.0.0.1
+ done
+ fi
+ done
+
+ # /etc/ifaliases, if it exists, contains the names of additional IP
+ # addresses for each interface. It is formatted as a series of lines
+ # that contain
+ # address interface netmask
+ #
+ # Note that /etc/ifaliases works only with certain cases only and its
+ # use is not recommended. Use /etc/ifconfig.xxN instead.
+ #
+ #
+ if [ -f /etc/ifaliases ]; then
+ if [ "$done_aliases_message" != yes ]; then
+ echo "Adding interface aliases:"
+ fi
+ while read addr int net; do
+ if [ -z "$net" ]; then
+ # for compatibility only, obsolete
+ ifconfig $int inet alias $addr
+ else
+ ifconfig $int inet alias $addr netmask $net
+ fi
+ # use loopback, not the wire
+ route add $addr 127.0.0.1
+ done < /etc/ifaliases
+ fi
+
+ # IPv6 interface autoconfiguration.
+ #
+ if ifconfig lo0 inet6 >/dev/null 2>&1; then
+ # wait till DAD is completed. always invoke it in case
+ # if are configured manually by ifconfig
+ #
+ dadcount=`sysctl -n net.inet6.ip6.dad_count 2>/dev/null`
+ sleep $dadcount
+ sleep 1
+
+ if checkyesno rtsol; then
+ if [ "$ip6mode" = "autohost" ]; then
+ echo 'Sending router solicitation...'
+ rtsol $rtsol_flags
+ else
+ echo
+ warn \
+ "ip6mode must be set to 'autohost' to use rtsol."
+ fi
+
+ # wait till DAD is completed, for global addresses
+ # configured by router advert message.
+ #
+ sleep $dadcount
+ sleep 1
+ fi
+ fi
+
+ # XXX this must die
+ if [ -s /etc/netstart.local ]; then
+ sh /etc/netstart.local start
+ fi
+}
+
+network_stop()
+{
+ echo "Stopping network."
+
+ # XXX this must die
+ if [ -s /etc/netstart.local ]; then
+ sh /etc/netstart.local stop
+ fi
+
+ echo "Deleting aliases."
+ if [ -f /etc/ifaliases ]; then
+ while read addr int net; do
+ ifconfig $int inet delete $addr
+ done < /etc/ifaliases
+ fi
+
+ for int in `ifconfig -lu`; do
+ eval args=\$ifaliases_$int
+ if [ -n "$args" ]; then
+ set -- $args
+ while [ $# -ge 2 ]; do
+ addr=$1 ; net=$2 ; shift 2
+ ifconfig $int inet delete $addr
+ done
+ fi
+ done
+
+ # down interfaces
+ #
+ echo -n 'Downing network interfaces:'
+ if [ "$net_interfaces" != NO ]; then
+ if checkyesno auto_ifconfig; then
+ tmp=`ifconfig -l`
+ else
+ tmp="$net_interfaces"
+ fi
+ for int in $tmp; do
+ eval args=\$ifconfig_$int
+ if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then
+ echo -n " $int"
+ ifconfig $int down
+ fi
+ done
+ echo "."
+ fi
+
+ # flush routes
+ #
+ route -n flush
+
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/newsyslog b/etc/rc.d/newsyslog
new file mode 100755
index 0000000..a842e40
--- /dev/null
+++ b/etc/rc.d/newsyslog
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: newsyslog
+# REQUIRE: mountcritremote sysdb
+# BEFORE: syslogd
+
+. /etc/rc.subr
+
+name="newsyslog"
+required_files="/etc/newsyslog.conf"
+start_precmd="checkyesno newsyslog"
+start_cmd="newsyslog_start"
+stop_cmd=":"
+
+newsyslog_start()
+{
+ echo -n "Trimming log files:"
+ /usr/bin/newsyslog -s $newsyslog_flags
+ echo " done."
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/nfsd b/etc/rc.d/nfsd
new file mode 100755
index 0000000..a0d3aa1
--- /dev/null
+++ b/etc/rc.d/nfsd
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: nfsd,v 1.2 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: nfsd
+# REQUIRE: mountd
+
+. /etc/rc.subr
+
+name="nfsd"
+rcvar="nfs_server"
+command="/usr/sbin/${name}"
+required_vars="rpcbind"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/nfslocking b/etc/rc.d/nfslocking
new file mode 100755
index 0000000..bddec82
--- /dev/null
+++ b/etc/rc.d/nfslocking
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# $NetBSD: nfslocking,v 1.3 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: nfslocking
+# REQUIRE: nfsd
+
+. /etc/rc.subr
+
+arg=$1
+
+start_precmd='checkyesno nfs_server || checkyesno nfs_client'
+stop_precmd=$start_precmd
+status_precmd=$start_precmd
+
+name="statd"
+rcvar=$name
+command="/usr/sbin/rpc.${name}"
+load_rc_config $name
+run_rc_command "$arg"
+
+name="lockd"
+rcvar=$name
+command="/usr/sbin/rpc.${name}"
+load_rc_config $name
+run_rc_command "$arg"
diff --git a/etc/rc.d/ntpd b/etc/rc.d/ntpd
new file mode 100755
index 0000000..b09c4d1
--- /dev/null
+++ b/etc/rc.d/ntpd
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: ntpd,v 1.2 2000/05/13 08:45:07 lukem Exp $
+#
+
+# PROVIDE: ntpd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="ntpd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/ntp.conf"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ntpdate b/etc/rc.d/ntpdate
new file mode 100755
index 0000000..d0a8a18
--- /dev/null
+++ b/etc/rc.d/ntpdate
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# $NetBSD: ntpdate,v 1.5 2000/08/21 14:48:39 abs Exp $
+#
+
+# PROVIDE: ntpdate
+# REQUIRE: NETWORK syslogd
+
+. /etc/rc.subr
+
+name="ntpdate"
+rcvar=$name
+start_cmd="ntpdate_start"
+stop_cmd=":"
+
+ntpdate_start()
+{
+ if [ -z "$ntpdate_hosts" ]; then
+ ntpdate_hosts=`awk '
+ /^server[ \t]*127.127/ {next}
+ /^(server|peer)/ {print $2}
+ ' </etc/ntp.conf`
+ fi
+ if [ -n "$ntpdate_hosts" ]; then
+ echo "Setting date via ntp."
+ ntpdate $ntpdate_flags $ntpdate_hosts
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/poffd b/etc/rc.d/poffd
new file mode 100644
index 0000000..12422c4
--- /dev/null
+++ b/etc/rc.d/poffd
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: poffd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="poffd"
+rcvar=$name
+command="/usr/sbin/${name}"
+start_precmd="test -c /dev/pow0"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/postfix b/etc/rc.d/postfix
new file mode 100755
index 0000000..b453464
--- /dev/null
+++ b/etc/rc.d/postfix
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# $NetBSD: postfix,v 1.4 2000/05/13 08:45:08 lukem Exp $
+#
+
+# PROVIDE: mail
+# REQUIRE: LOGIN
+
+# we could do this, but make mail start late, so that things like
+# .forward's are not processed until the system is fully operational
+## REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="postfix"
+rcvar=$name
+required_files="/etc/${name}/main.cf"
+start_cmd="postfix start"
+stop_cmd="postfix stop"
+reload_cmd="postfix reload"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/pwcheck b/etc/rc.d/pwcheck
new file mode 100755
index 0000000..80949e9
--- /dev/null
+++ b/etc/rc.d/pwcheck
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $NetBSD: pwcheck,v 1.2 2000/05/13 08:45:08 lukem Exp $
+#
+
+# PROVIDE: pwcheck
+# REQUIRE: mountcritremote syslogd
+
+. /etc/rc.subr
+
+name="pwcheck"
+start_cmd="pwcheck_start"
+stop_cmd=":"
+
+pwcheck_start()
+{
+ # check the password temp/lock file
+ #
+ if [ -f /etc/ptmp ]; then
+ logger -s -p auth.err \
+ "password file may be incorrect -- /etc/ptmp exists"
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/quota b/etc/rc.d/quota
new file mode 100755
index 0000000..8f63255
--- /dev/null
+++ b/etc/rc.d/quota
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# $NetBSD: quota,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $
+#
+
+# PROVIDE: quota
+# REQUIRE: mountall
+
+. /etc/rc.subr
+
+name="quota"
+start_cmd="quota_start"
+stop_cmd="/usr/sbin/quotaoff -a"
+
+quota_start()
+{
+ echo -n "Checking quotas:"
+ /usr/sbin/quotacheck -a
+ echo " done."
+ /usr/sbin/quotaon -a
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/racoon b/etc/rc.d/racoon
new file mode 100755
index 0000000..ebc0627
--- /dev/null
+++ b/etc/rc.d/racoon
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: ike
+# REQUIRE: kdc ppp
+
+. /etc/rc.subr
+
+name="racoon"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/racoon/racoon.conf"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/raidframe b/etc/rc.d/raidframe
new file mode 100755
index 0000000..640ad6f
--- /dev/null
+++ b/etc/rc.d/raidframe
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# $NetBSD: raidframe,v 1.4 2000/05/16 16:54:33 oster Exp $
+#
+
+# PROVIDE: disks
+
+. /etc/rc.subr
+
+name="raidframe"
+start_cmd="raidframe_start"
+stop_cmd=":"
+
+raidframe_start()
+{
+ # Configure raid devices.
+ # Ensure order by globbing raid[0-9].conf before raid[0-9][0-9].conf.
+ #
+ for cfg in /etc/raid[0-9].conf /etc/raid[0-9][0-9].conf ; do
+ [ ! -f $cfg ] && continue
+ dev=${cfg##*/}
+ dev=${dev%%.conf}
+ raidctl -c $cfg $dev
+ done
+
+ # Initiate parity/mirror reconstruction as needed.
+ # Backgrounded, and sequentially ordered.
+ #
+ # XXX: this currently doesn't work for autoconfigured raid devices
+ # that don't have a corresponding raidN.conf
+ #
+ (
+ for cfg in /etc/raid[0-9].conf /etc/raid[0-9][0-9].conf ; do
+ [ ! -f $cfg ] && continue
+ dev=${cfg##*/}
+ dev=${dev%%.conf}
+ raidctl -P $dev
+ done
+ ) &
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rarpd b/etc/rc.d/rarpd
new file mode 100755
index 0000000..b0e4212
--- /dev/null
+++ b/etc/rc.d/rarpd
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# $NetBSD: rarpd,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: rarpd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="rarpd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/ethers"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rbootd b/etc/rc.d/rbootd
new file mode 100755
index 0000000..ba64fdf
--- /dev/null
+++ b/etc/rc.d/rbootd
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $NetBSD: rbootd,v 1.4 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: rbootd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="rbootd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/root b/etc/rc.d/root
new file mode 100755
index 0000000..8a7e3b0
--- /dev/null
+++ b/etc/rc.d/root
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $NetBSD: root,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $
+#
+
+# PROVIDE: root
+# REQUIRE: fsck
+
+. /etc/rc.subr
+
+name="root"
+start_cmd="root_start"
+stop_cmd=":"
+
+root_start()
+{
+ umount -a >/dev/null 2>&1
+ mount /
+ rm -f /fastboot
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/route6d b/etc/rc.d/route6d
new file mode 100755
index 0000000..0edfcb3
--- /dev/null
+++ b/etc/rc.d/route6d
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: route6d,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: route6d
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="route6d"
+rcvar=$name
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/routed b/etc/rc.d/routed
new file mode 100755
index 0000000..c9ae523
--- /dev/null
+++ b/etc/rc.d/routed
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $NetBSD: routed,v 1.4 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: routed
+# REQUIRE: DAEMON gated
+
+. /etc/rc.subr
+
+name="routed"
+rcvar=$name
+command="/sbin/${name}"
+start_precmd="routed_precmd"
+
+routed_precmd()
+{
+ if checkyesno gated && checkyesno routed; then
+ warn "gated and routed both requested to be run: only running gated."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rpcbind b/etc/rc.d/rpcbind
new file mode 100755
index 0000000..1715975
--- /dev/null
+++ b/etc/rc.d/rpcbind
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: rpcbind,v 1.4 2000/07/26 00:11:49 lukem Exp $
+#
+
+# PROVIDE: rpcbind
+# REQUIRE: NETWORK ntpdate syslogd named ppp
+
+. /etc/rc.subr
+
+name="rpcbind"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rtadvd b/etc/rc.d/rtadvd
new file mode 100755
index 0000000..7347035
--- /dev/null
+++ b/etc/rc.d/rtadvd
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $NetBSD: rtadvd,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: rtadvd
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="rtadvd"
+rcvar=$name
+command="/usr/sbin/${name}"
+start_precmd="rtadvd_precmd"
+
+rtadvd_precmd()
+{
+ if [ "$ip6mode" != "router" ]; then
+ warn \
+ "${name} cannot be used on IPv6 host, only on an IPv6 router."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rtsold b/etc/rc.d/rtsold
new file mode 100755
index 0000000..840ab2a
--- /dev/null
+++ b/etc/rc.d/rtsold
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $NetBSD: rtsold,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: rtsold
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="rtsold"
+rcvar=$name
+command="/usr/sbin/${name}"
+start_precmd="rtsold_precmd"
+
+rtsold_precmd()
+{
+ if [ "$ip6mode" != "autohost" ]; then
+ warn "\$ip6mode must be set to 'autohost' to use ${name}."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/rwho b/etc/rc.d/rwho
new file mode 100755
index 0000000..e628171
--- /dev/null
+++ b/etc/rc.d/rwho
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: rwho,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: rwho
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="rwhod"
+rcvar=$name
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/savecore b/etc/rc.d/savecore
new file mode 100755
index 0000000..5b6e115
--- /dev/null
+++ b/etc/rc.d/savecore
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# $NetBSD: savecore,v 1.2 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: savecore
+# REQUIRE: syslogd
+
+. /etc/rc.subr
+
+name="savecore"
+rcvar=$name
+start_cmd="savecore_start"
+stop_cmd=":"
+
+savecore_start()
+{
+ # /var/crash should be a directory or a symbolic link
+ # to the crash directory if core dumps are to be saved.
+ #
+ if [ -d /var/crash/. ]; then
+ echo "Checking for core dump..."
+ savecore $savecore_flags /var/crash
+ else
+ warn "No /var/crash directory; savecore not run."
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/screenblank b/etc/rc.d/screenblank
new file mode 100755
index 0000000..6ac8f5e
--- /dev/null
+++ b/etc/rc.d/screenblank
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: screenblank,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: screenblank
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="screenblank"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/securelevel b/etc/rc.d/securelevel
new file mode 100755
index 0000000..a683a74
--- /dev/null
+++ b/etc/rc.d/securelevel
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $NetBSD: securelevel,v 1.1 2000/08/21 23:31:24 lukem Exp $
+#
+
+# PROVIDE: securelevel
+# REQUIRE: aftermountlkm ipnat mountd
+
+. /etc/rc.subr
+
+name="securelevel"
+start_cmd="securelevel_start"
+stop_cmd=":"
+
+securelevel_start()
+{
+ # if $securelevel is set, change it here, else if it is 0,
+ # change it to 1 here, before we start daemons or login services.
+ #
+ if [ -n "$securelevel" ]; then
+ echo -n "Setting securelevel: "
+ sysctl -w kern.securelevel=$securelevel
+ else
+ securelevel=`sysctl -n kern.securelevel`
+ if [ x"$securelevel" = x0 ]; then
+ echo -n "Setting securelevel: "
+ sysctl -w kern.securelevel=1
+ fi
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/sendmail b/etc/rc.d/sendmail
new file mode 100755
index 0000000..61a0b6f
--- /dev/null
+++ b/etc/rc.d/sendmail
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# $NetBSD: sendmail,v 1.12 2000/10/09 06:11:38 nisimura Exp $
+#
+
+# PROVIDE: mail
+# REQUIRE: LOGIN
+
+# we could do this, but make mail start late, so that things like
+# .forward's are not processed until the system is fully operational
+## REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="sendmail"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/mail/${name}.cf"
+start_precmd="sendmail_precmd"
+
+sendmail_precmd()
+{
+ # Die if there's pre-8.10 custom configuration file. This check is
+ # mandatory for smooth upgrade. See NetBSD PR 10100 for details.
+ #
+ if checkyesno sendmail && [ -f "/etc/${name}.cf" ]; then
+ if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
+ warn \
+ "${name} was not started; you have multiple copies of sendmail.cf."
+ return 1
+ fi
+ fi
+
+ # check modifications on /etc/mail/aliases
+ if [ -f "/etc/mail/aliases.db" ]; then
+ if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
+ echo \
+ "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
+ /usr/bin/newaliases
+ fi
+ else
+ echo \
+ "${name}: /etc/mail/aliases.db not present, generating"
+ /usr/bin/newaliases
+ fi
+
+ # check couple of common db files, too
+ for f in genericstable virtusertable domaintable mailertable; do
+ if [ -r "/etc/mail/$f" ] && [ "/etc/mail/$f" -nt "/etc/mail/$f.db" ];
+ then
+ echo \
+ "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
+ /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
+ fi
+ done
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/sshd b/etc/rc.d/sshd
new file mode 100755
index 0000000..e31a028
--- /dev/null
+++ b/etc/rc.d/sshd
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# $NetBSD: sshd,v 1.7 2000/08/10 22:49:43 lukem Exp $
+#
+
+# PROVIDE: sshd
+# REQUIRE: LOGIN
+
+. /etc/rc.subr
+
+name="sshd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/${name}.conf"
+extra_commands="keygen reload"
+
+sshd_keygen()
+{
+ if [ -f /etc/ssh_host_key ]; then
+ echo "You already have an RSA host key in /etc/ssh_host_key"
+ echo "Skipping RSA Key Generation"
+ else
+ umask 022
+ /usr/bin/ssh-keygen -b 1024 -f /etc/ssh_host_key -N ''
+ fi
+
+ if [ -f /etc/ssh_host_dsa_key ]; then
+ echo "You already have a DSA host key in /etc/ssh_host_dsa_key"
+ echo "Skipping DSA Key Generation"
+ else
+ umask 022
+ /usr/bin/ssh-keygen -d -f /etc/ssh_host_dsa_key -N ''
+ fi
+}
+
+sshd_precmd()
+{
+ if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key ]; then
+ /etc/rc.d/sshd keygen
+ fi
+}
+
+keygen_cmd=sshd_keygen
+start_precmd=sshd_precmd
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/swap1 b/etc/rc.d/swap1
new file mode 100755
index 0000000..0582498
--- /dev/null
+++ b/etc/rc.d/swap1
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $NetBSD: swap1,v 1.4 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: localswap
+# REQUIRE: disks
+
+. /etc/rc.subr
+
+name="swap1"
+
+# Add all block-type swap devices; these might be necessary
+# during disk checks.
+#
+start_cmd='swapctl -A -t blk'
+
+# Remove all block-type swap devices
+#
+stop_cmd="swapctl -U -t blk"
+
+load_rc_config swap
+run_rc_command "$1"
diff --git a/etc/rc.d/swap2 b/etc/rc.d/swap2
new file mode 100755
index 0000000..288e620
--- /dev/null
+++ b/etc/rc.d/swap2
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# $NetBSD: swap2,v 1.4 2000/07/17 12:27:04 lukem Exp $
+#
+
+# PROVIDE: nonlocalswap
+# REQUIRE: mountcritremote
+
+. /etc/rc.subr
+
+name="swap2"
+start_cmd="swap2_start"
+
+swap2_start()
+{
+ # "Critical" file systems are now mounted. Go ahead and swap
+ # to files now, since they will be residing in the critical file
+ # systems (or, at least, they should be...).
+ # Check for no swap, and warn about it unless that is desired.
+ #
+ swapctl -A -t noblk;
+ if ! checkyesno no_swap; then
+ if swapctl -s | grep "no swap devices configured" > /dev/null;
+ then
+ warn "No swap space configured!"
+ fi
+ fi
+}
+
+# Remove all non-block-type swap devices
+#
+stop_cmd="swapctl -U -t noblk"
+
+load_rc_config swap
+run_rc_command "$1"
diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl
index 8b1f447..90c4f2c 100644
--- a/etc/rc.d/sysctl
+++ b/etc/rc.d/sysctl
@@ -1,13 +1,40 @@
#!/bin/sh
#
-# Read in /etc/sysctl.conf and set things accordingly
+# $NetBSD: sysctl,v 1.8 2000/06/13 16:29:55 itojun Exp $
#
-# $Id:$
-if [ -f /etc/sysctl.conf ]; then
- 3< /etc/sysctl.conf
- while read 0<&3 var;
- do
- sysctl -w $var
- done
- 3<&-
-fi
+
+# PROVIDE: sysctl
+# REQUIRE: root ipfilter ipsec
+
+. /etc/rc.subr
+
+name="sysctl"
+start_cmd="sysctl_start"
+stop_cmd=":"
+
+sysctl_start()
+{
+ if [ -n "$defcorename" ]; then
+ cat <<__EOF__
+*** WARNING: /etc/rc.conf \$defcorename setting is obsolete. Please
+*** set kern.defcorename in /etc/sysctl.conf
+__EOF__
+ sysctl -w kern.defcorename=$defcorename
+ fi
+
+ if [ -n "$nfsiod_flags" ]; then
+ cat <<__EOF__
+*** WARNING: /etc/rc.conf \$nfsiod_flags setting is obsolete. Please
+*** remove it. If it was set to other than the default of "-n 4", then
+*** set vfs.nfs.iothreads in /etc/sysctl.conf
+__EOF__
+ fi
+
+ if [ -r /etc/sysctl.conf ]; then
+ echo "Setting sysctl variables:"
+ sysctl -f /etc/sysctl.conf
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/sysdb b/etc/rc.d/sysdb
new file mode 100755
index 0000000..29b0d3b
--- /dev/null
+++ b/etc/rc.d/sysdb
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# $NetBSD: sysdb,v 1.6 2000/10/09 05:02:14 nisimura Exp $
+#
+
+# PROVIDE: sysdb
+# REQUIRE: mountcritremote
+
+. /etc/rc.subr
+
+name="sysdb"
+start_cmd="sysdb_start"
+stop_cmd=":"
+
+sysdb_start()
+{
+ # Build ps databases. If this kernel supports
+ # machdep.booted_kernel, use that to build the KVM db so dmesg
+ # will run work when we boot /netbsd.new, etc.
+ #
+ echo "Building databases..."
+ booted_kernel=`sysctl -n machdep.booted_kernel 2>/dev/null`
+ kvm_mkdb ${booted_kernel:-/netbsd}
+ dev_mkdb
+
+ # Re-create /var/run/utmp, which is deleted by mountcritlocal
+ # but can't be recreated by it because install and chown may
+ # not be available then (possibly no /usr).
+ #
+ install -c -m 664 -g utmp /dev/null /var/run/utmp
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/syslogd b/etc/rc.d/syslogd
new file mode 100755
index 0000000..2c8caea
--- /dev/null
+++ b/etc/rc.d/syslogd
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# $NetBSD: syslogd,v 1.6 2000/07/29 21:50:20 veego Exp $
+#
+
+# PROVIDE: syslogd
+# REQUIRE: mountcritremote sysdb wscons
+
+. /etc/rc.subr
+
+name="syslogd"
+rcvar=$name
+command="/usr/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/etc/syslog.conf"
+start_precmd="syslogd_precmd"
+extra_commands="reload"
+
+syslogd_precmd()
+{
+ # Transitional symlink for old binaries
+ #
+ if [ ! -h /dev/log ]; then
+ ln -sf /var/run/log /dev/log
+ fi
+ rm -f /var/run/log
+ return 0
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/timed b/etc/rc.d/timed
new file mode 100755
index 0000000..097a53c0
--- /dev/null
+++ b/etc/rc.d/timed
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# $NetBSD: timed,v 1.3 2000/05/13 08:45:09 lukem Exp $
+#
+
+# PROVIDE: timed
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="timed"
+rcvar=$name
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ttys b/etc/rc.d/ttys
new file mode 100755
index 0000000..6e12854
--- /dev/null
+++ b/etc/rc.d/ttys
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# $NetBSD: ttys,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $
+#
+
+# PROVIDE: tty
+# REQUIRE: root
+
+. /etc/rc.subr
+
+name="ttyflags"
+start_cmd="ttyflags_start"
+stop_cmd=":"
+
+ttyflags_start()
+{
+ # set flags on ttys.
+ # (do early, in case they use tty for SLIP in network)
+ #
+ echo "Setting tty flags."
+ ttyflags -a
+
+ # setup ptys
+ #
+ # XXX: there may be more ptys than this; maybe use
+ # sysctl to find out how many?
+ #
+ chmod 666 /dev/tty[pqrs]*
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/virecover b/etc/rc.d/virecover
new file mode 100755
index 0000000..aad6295
--- /dev/null
+++ b/etc/rc.d/virecover
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $NetBSD: virecover,v 1.3 2000/07/26 00:11:49 lukem Exp $
+#
+
+# PROVIDE: virecover
+# REQUIRE: mountcritremote
+#
+# XXX: should require `mail'!
+
+. /etc/rc.subr
+
+name="virecover"
+start_cmd="virecover_start"
+stop_cmd=":"
+
+virecover_start()
+{
+ recover=`find /var/tmp/vi.recover -name 'recover.*' -type f -print`
+ if [ -n "$recover" ]; then
+ echo "Preserving editor files."
+ for i in $recover; do
+ sendmail -t < $i
+ done
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/wscons b/etc/rc.d/wscons
new file mode 100755
index 0000000..a8a7398
--- /dev/null
+++ b/etc/rc.d/wscons
@@ -0,0 +1,135 @@
+#!/bin/sh
+#
+# $NetBSD: wscons,v 1.5 2000/08/21 23:02:25 lukem Exp $
+#
+
+# PROVIDE: wscons
+# REQUIRE: mountcritremote
+
+. /etc/rc.subr
+
+name="wscons"
+rcvar=$name
+start_cmd="wscons_start"
+stop_cmd=":"
+
+wscons_start()
+{
+ wscfg=/usr/sbin/wsconscfg
+ wsfld=/usr/sbin/wsfontload
+ config=/etc/wscons.conf
+ usage="Usage: wsconfig [-n] [-f configfile] [-font fontpgm] [-screen screenpgm]"
+ DOIT=
+
+ while [ $# -gt 0 ]; do
+ case $1 in
+ -n)
+ DOIT=echo
+ ;;
+ -f)
+ config=$2
+ shift
+ ;;
+ -font)
+ wsfld=$2
+ shift
+ ;;
+ -screen)
+ wscfg=$2
+ shift
+ ;;
+ *)
+ echo $usage
+ exit 1
+ ;;
+ esac
+ shift
+ done
+
+
+ # args mean:
+ # screen idx scr emul
+ # font name width height enc file
+ ( while read type arg1 arg2 arg3 arg4 arg5; do
+ case "$type" in
+ \#*|"")
+ continue
+ ;;
+ font)
+ name=$arg1
+ width=$arg2
+ height=$arg3
+ enc=$arg4
+ file=$arg5
+ cmd=$wsfld
+
+ case $width in
+ -)
+ ;;
+ *)
+ cmd="$cmd -w $width"
+ ;;
+ esac
+ case $height in
+ -)
+ ;;
+ *)
+ cmd="$cmd -h $height"
+ ;;
+ esac
+ case $enc in
+ -)
+ ;;
+ *)
+ cmd="$cmd -e $enc"
+ ;;
+ esac
+ cmd="$cmd -N $name $file"
+ eval $DOIT $cmd
+ ;;
+ screen)
+ idx=$arg1
+ scr=$arg2
+ emul=$arg3
+ cmd=$wscfg
+
+ case $scr in
+ -)
+ ;;
+ *)
+ cmd="$cmd -t $scr"
+ ;;
+ esac
+ case $emul in
+ -)
+ ;;
+ *)
+ cmd="$cmd -e $emul"
+ ;;
+ esac
+ cmd="$cmd $idx"
+ eval $DOIT $cmd
+ ;;
+ keyboard)
+ kbd=$arg1
+ cmd=$wscfg
+ case $kbd in
+ -|auto)
+ cmd="$cmd -k"
+ ;;
+ *)
+ cmd="$cmd -k $kbd"
+ ;;
+ esac
+ eval $DOIT $cmd
+ ;;
+ mux)
+ cmd="$wscfg -m $arg1"
+ eval $DOIT $cmd
+ ;;
+ esac
+ done ) < $config
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/xdm b/etc/rc.d/xdm
new file mode 100755
index 0000000..a5c6b76
--- /dev/null
+++ b/etc/rc.d/xdm
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# $NetBSD: xdm,v 1.5 2000/07/17 15:24:48 lukem Exp $
+#
+
+# PROVIDE: xdm
+# REQUIRE: DAEMON LOGIN wscons
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="xdm"
+rcvar=$name
+command="/usr/X11R6/bin/${name}"
+pidfile="/var/run/${name}.pid"
+required_files="/usr/X11R6/lib/X11/xdm/xdm-config"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/xfs b/etc/rc.d/xfs
new file mode 100755
index 0000000..f1b4dad
--- /dev/null
+++ b/etc/rc.d/xfs
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $NetBSD: xfs,v 1.4 2000/09/19 13:04:39 lukem Exp $
+#
+
+# PROVIDE: xfs
+# REQUIRE: mountall cleartmp
+
+. /etc/rc.subr
+
+name="xfs"
+rcvar=$name
+command="/usr/X11R6/bin/${name}"
+command_args="& sleep 2"
+required_files="/usr/X11R6/lib/X11/fs/config"
+extra_commands="reload"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind
new file mode 100755
index 0000000..7549087
--- /dev/null
+++ b/etc/rc.d/ypbind
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $NetBSD: ypbind,v 1.3 2000/05/13 08:45:10 lukem Exp $
+#
+
+# PROVIDE: ypbind
+# REQUIRE: ypserv
+
+. /etc/rc.subr
+
+name="ypbind"
+rcvar=$name
+command="/usr/sbin/${name}"
+start_precmd="ypbind_precmd"
+
+ypbind_precmd()
+{
+ _domain=`domainname`
+ if [ -z "$_domain" ]; then
+ warn "domainname(1) is not set."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/yppasswdd b/etc/rc.d/yppasswdd
new file mode 100755
index 0000000..4b3ab70
--- /dev/null
+++ b/etc/rc.d/yppasswdd
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# $NetBSD: yppasswdd,v 1.4 2000/06/02 22:54:13 fvdl Exp $
+#
+
+# PROVIDE: yppasswdd
+# REQUIRE: ypserv ypbind
+
+. /etc/rc.subr
+
+name="yppasswdd"
+rcvar=$name
+command="/usr/sbin/rpc.${name}"
+required_vars="rpcbind ypserv"
+start_precmd="yppasswdd_precmd"
+
+yppasswdd_precmd()
+{
+ _domain=`domainname`
+ if [ -z "$_domain" ]; then
+ warn "domainname(1) is not set."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.d/ypserv b/etc/rc.d/ypserv
new file mode 100755
index 0000000..69fdd20
--- /dev/null
+++ b/etc/rc.d/ypserv
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# $NetBSD: ypserv,v 1.4 2000/06/02 22:54:13 fvdl Exp $
+#
+
+# PROVIDE: ypserv
+# REQUIRE: rpcbind
+
+. /etc/rc.subr
+
+name="ypserv"
+rcvar=$name
+command="/usr/sbin/${name}"
+required_vars="rpcbind"
+start_precmd="ypserv_precmd"
+
+ypserv_precmd()
+{
+ _domain=`domainname`
+ if [ -z "$_domain" ]; then
+ warn "domainname(1) is not set."
+ return 1
+ fi
+
+ if [ ! -d /var/yp/$_domain/. ]; then
+ warn "/var/yp/$_domain is not a directory."
+ return 1
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/etc/rc.subr b/etc/rc.subr
new file mode 100644
index 0000000..5292a32
--- /dev/null
+++ b/etc/rc.subr
@@ -0,0 +1,586 @@
+# $NetBSD: rc.subr,v 1.28 2000/11/06 00:08:30 lukem Exp $
+#
+# Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Luke Mewburn.
+#
+# 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.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+# rc.subr
+# functions used by various rc scripts
+#
+
+#
+# functions
+# ---------
+
+#
+# checkyesno var
+# Test $1 variable, and warn if not set to YES or NO.
+# Return 0 if it's "yes" (et al), nonzero otherwise.
+#
+checkyesno()
+{
+ eval _value=\$${1}
+ case $_value in
+
+ # "yes", "true", "on", or "1"
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ return 0
+ ;;
+
+ # "no", "false", "off", or "0"
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+ return 1
+ ;;
+ *)
+ warn "\$${1} is not set properly."
+ return 1
+ ;;
+ esac
+}
+
+#
+# mount_critical_filesystems
+# Go through the list of critical filesystems, checking each one
+# to see if it is mounted, and if it is not, mounting it.
+#
+mount_critical_filesystems()
+{
+ if [ $1 = local ]; then
+ _fslist=$critical_filesystems_beforenet
+ else
+ _fslist=$critical_filesystems
+ fi
+ for _fs in $_fslist; do
+ mount | (
+ _ismounted=no
+ while read what _on on _type type; do
+ if [ $on = $_fs ]; then
+ _ismounted=yes
+ fi
+ done
+ if [ $_ismounted = no ]; then
+ mount $_fs >/dev/null 2>&1
+ fi
+ )
+ done
+}
+
+#
+# check_pidfile pidfile procname
+# Parses the first line of pidfile for a pid, and ensures
+# that the process is running and matches procname.
+# Prints the matching pid upon success, nothing otherwise.
+#
+check_pidfile()
+{
+ _pidfile=$1
+ _procname=$2
+ if [ -z "$_pidfile" -o -z "$_procname" ]; then
+ err 3 'USAGE: check_pidfile pidfile procname'
+ fi
+ if [ ! -f $_pidfile ]; then
+ return
+ fi
+ read _pid _junk < $_pidfile
+ if [ -z "$_pid" ]; then
+ return
+ fi
+ _procnamebn=${_procname##*/}
+ ps -p $_pid -o 'pid,command' | while read _npid _arg0 _argv; do
+ if [ "$_npid" = "PID" ]; then
+ continue
+ fi
+ if [ "$_arg0" = "$_procname" \
+ -o "$_arg0" = "$_procnamebn" \
+ -o "$_arg0" = "${_procnamebn}:" \
+ -o "$_arg0" = "(${_procnamebn})" ]; then
+ echo $_npid
+ return
+ fi
+ done
+}
+
+#
+# check_process procname
+# Ensures that a process (or processes) named procname is running.
+# Prints a list of matching pids.
+#
+check_process()
+{
+ _procname=$1
+ if [ -z "$_procname" ]; then
+ err 3 'USAGE: check_process procname'
+ fi
+ _procnamebn=${_procname##*/}
+ _pref=
+ ps -ax -o 'pid,command' | while read _npid _arg0 _argv; do
+ if [ "$_npid" = "PID" ]; then
+ continue
+ fi
+ if [ "$_arg0" = "$_procname" \
+ -o "$_arg0" = "$_procnamebn" \
+ -o "$_arg0" = "${_procnamebn}:" \
+ -o "$_arg0" = "(${_procnamebn})" ]; then
+ echo -n "$_pref$_npid"
+ _pref=" "
+ fi
+ done
+}
+
+#
+# run_rc_command arg
+# Search for arg in the list of supported commands, which is:
+# "start stop restart rcvar status ${extra_commands}"
+# If there's a match, run ${arg}_cmd or the default command (see below).
+#
+# If arg has a given prefix, then change the operation as follows:
+# prefix operation
+# ------ ---------
+# fast Skip the pid check.
+# force Set ${rcvar} to YES.
+#
+# The following globals are used:
+#
+# name needed function
+# ---- ------ --------
+# name y Name of script.
+#
+# command n Full path to command.
+# Not needed if ${arg}_cmd is set for
+# each keyword.
+#
+# command_args n Optional args/shell directives for command.
+#
+# extra_commands n List of extra commands supported.
+#
+# pidfile n If set, use check_pidfile $pidfile, else if
+# $command is set, use check_process $command.
+#
+# rcvar n This is checked with checkyesno to determine
+# if the action should be run.
+#
+# ${name}_chroot n Directory to chroot to before running ${command}
+#
+# ${name}_chdir n Directory to cd to before running ${command}
+# (if not using ${name}_chroot).
+#
+# ${name}_flags n Arguments to call ${command} with.
+# NOTE: $flags from the parent environment
+# can be used to override this.
+#
+# ${name}_nice n Nice level to run ${command} at.
+#
+# ${name}_user n User to run ${command} as, using su(1) if not
+# using ${name}_chroot.
+#
+# ${name}_group n Group to run chrooted ${command} as.
+#
+# ${name}_groups n Supplementary group list to run chrooted
+# ${command} with.
+#
+# ${_arg}_cmd n If set, use this as the action when invoked;
+# $_arg is available to the action to use.
+# Otherwise, use default command (see below)
+#
+# ${_arg}_precmd n If set, run just before performing the main
+# action in the default command (i.e, after
+# checking for required bits and process
+# (non)existance).
+# If this completes with a non-zero exit code,
+# don't run ${_arg}_cmd.
+#
+# required_dirs n If set, check for the existence of the given
+# directories before running the default
+# (re)start command.
+#
+# required_files n If set, check for the readability of the given
+# files before running the default (re)start
+# command.
+#
+# required_vars n If set, perform checkyesno on each of the
+# listed variables before running the default
+# (re)start command.
+#
+# Default commands for a given arg:
+#
+# arg default
+# --- -------
+# status Show if ${command} is running, etc.
+#
+# start if !running && checkyesno ${rcvar}
+# ${command}
+#
+# stop if ${pidfile}
+# kill $sig_stop `check_pidfile $pidfile`
+# else
+# kill $sig_stop `check_process $command`
+# $sig_stop defaults to TERM.
+#
+# reload As stop, except use $sig_reload instead.
+# $sig_reload defaults to HUP.
+#
+# restart Run `stop' then `start'.
+#
+#
+run_rc_command()
+{
+ _arg=$1
+ if [ -z "$name" ]; then
+ err 3 '$name is not set.'
+ fi
+
+ case "$_arg" in
+ fast*) # "fast" prefix; don't check pid
+ _arg=${_arg#fast}
+ _rc_fast_run=YES
+ ;;
+ force*) # "force prefix; always start
+ _arg=${_arg#force}
+ _rc_force_run=YES
+ if [ -n "${rcvar}" ]; then
+ eval ${rcvar}=YES
+ fi
+ ;;
+ esac
+
+ _keywords="start stop restart rcvar $extra_commands"
+ _pid=
+ _pidcmd=
+ # setup pid check command if not fast
+ if [ -z "$_rc_fast_run" ]; then
+ if [ -n "$pidfile" ]; then
+ _pidcmd='_pid=`check_pidfile '$pidfile' '$command'`'
+ elif [ -n "$command" ]; then
+ _pidcmd='_pid=`check_process '$command'`'
+ fi
+ if [ -n "$_pidcmd" ]; then
+ _keywords="${_keywords} status"
+ fi
+ fi
+
+ if [ -z "$_arg" ]; then
+ rc_usage "$_keywords"
+ fi
+
+ if [ -n "$flags" ]; then # allow override from environment
+ _flags=$flags
+ else
+ eval _flags=\$${name}_flags
+ fi
+ eval _chdir=\$${name}_chdir
+ eval _chroot=\$${name}_chroot
+ eval _nice=\$${name}_nice
+ eval _user=\$${name}_user
+ eval _group=\$${name}_group
+ eval _groups=\$${name}_groups
+
+ # if ${rcvar} is set, and $1 is not
+ # "rcvar" or "status", then run
+ # checkyesno ${rcvar}
+ # and return if that failed
+ #
+ if [ -n "${rcvar}" -a "$_arg" != "rcvar" -a "$_arg" != "status" ]; then
+ if ! checkyesno ${rcvar}; then
+ return 0
+ fi
+ fi
+
+ eval $_pidcmd # determine the pid if necessary
+
+ for _elem in $_keywords; do
+ if [ "$_elem" != "$_arg" ]; then
+ continue
+ fi
+
+ # if there's a custom ${XXX_cmd},
+ # run that instead of the default
+ #
+ eval _cmd=\$${_arg}_cmd
+ eval _precmd=\$${_arg}_precmd
+ if [ -n "$_cmd" ]; then
+ # if the precmd failed and force
+ # isn't set, exit
+ #
+ if ! eval $_precmd && [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+
+ eval $_cmd
+ return 0
+ fi
+
+ case "$_arg" in # default operations...
+
+ status)
+ if [ -n "$_pid" ]; then
+ echo "${name} is running as pid $_pid."
+ else
+ echo "${name} is not running."
+ return 1
+ fi
+ ;;
+
+ start)
+ if [ -n "$_pid" ]; then
+ echo "${name} already running? (pid=$_pid)."
+ exit 1
+ fi
+
+ if [ ! -x $command ]; then
+ return 0
+ fi
+
+ # check for required variables,
+ # directories, and files
+ #
+ for _f in $required_vars; do
+ if ! checkyesno $_f; then
+ warn "\$${_f} is not set."
+ if [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ fi
+ done
+ for _f in $required_dirs; do
+ if [ ! -d "${_f}/." ]; then
+ warn "${_f} is not a directory."
+ if [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ fi
+ done
+ for _f in $required_files; do
+ if [ ! -r "${_f}" ]; then
+ warn "${_f} is not readable."
+ if [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ fi
+ done
+
+ # if the precmd failed and force
+ # isn't set, exit
+ #
+ if ! eval $_precmd && [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+
+
+ # setup the command to run, and run it
+ #
+ echo "Starting ${name}."
+ if [ -n "$_chroot" ]; then
+ _doit="\
+${_nice:+nice -n $_nice }\
+chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
+$_chroot $command $_flags $command_args"
+ else
+ _doit="\
+${_user:+su -m $_user -c 'sh -c \"}\
+${_chdir:+cd $_chdir; }\
+${_nice:+nice -n $_nice }\
+$command $_flags $command_args\
+${_user:+\"'}"
+ fi
+ eval $_doit
+ ;;
+
+ stop)
+ if [ -z "$_pid" ]; then
+ if [ -n "$pidfile" ]; then
+ echo \
+ "${name} not running? (check $pidfile)."
+ else
+ echo "${name} not running?"
+ fi
+ exit 1
+ fi
+
+ if ! eval $_precmd && [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ echo "Stopping ${name}."
+ _doit=\
+"${_user:+su -m $_user -c '}kill -${sig_stop:-TERM} $_pid${_user:+'}"
+ eval $_doit
+ ;;
+
+ reload)
+ if [ -z "$_pid" ]; then
+ if [ -n "$pidfile" ]; then
+ echo \
+ "${name} not running? (check $pidfile)."
+ else
+ echo "${name} not running?"
+ fi
+ exit 1
+ fi
+ echo "Reloading ${name} config files."
+ if ! eval $_precmd && [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ _doit=\
+"${_user:+su -m $_user -c '}kill -${sig_reload:-HUP} $_pid${_user:+'}"
+ eval $_doit
+ ;;
+
+ restart)
+ if ! eval $_precmd && [ -z "$_rc_force_run" ]; then
+ return 1
+ fi
+ # prevent restart being called more
+ # than once by any given script
+ #
+ if [ -n "$_rc_restart_done" ]; then
+ return 0
+ fi
+ _rc_restart_done=YES
+ ( $0 ${_rc_force_run:+force}stop )
+ sleep 1
+ $0 ${_rc_force_run:+force}start
+
+ ;;
+
+ rcvar)
+ echo "# $name"
+ if [ -n "$rcvar" ]; then
+ if checkyesno ${rcvar}; then
+ echo "\$${rcvar}=YES"
+ else
+ echo "\$${rcvar}=NO"
+ fi
+ fi
+ ;;
+
+ *)
+ rc_usage "$_keywords"
+ ;;
+
+ esac
+ return 0
+ done
+
+ echo 1>&2 "$0: unknown directive '$_arg'."
+ rc_usage "$_keywords"
+ exit 1
+}
+
+#
+# run_rc_script file arg
+# Start the script `file' with `arg', and correctly handle the
+# return value from the script. If `file' ends with `.sh', it's
+# sourced into the current environment. Otherwise it's run as
+# a child process.
+#
+# Note: because `.sh' files are sourced into the current environment
+# run_rc_command shouldn't be used because its difficult to ensure
+# that the global variable state before and after the sourcing of
+# the .sh file won't adversely affect other scripts.
+#
+run_rc_script()
+{
+ _file=$1
+ _arg=$2
+ if [ -z "$_file" -o -z "$_arg" ]; then
+ err 3 'USAGE: run_rc_script file arg'
+ fi
+
+ case "$_file" in
+ *.sh) # run in current shell
+ set $_arg ; . $_file
+ ;;
+ *) # run in subshell
+ ( set $_arg ; . $_file )
+ ;;
+ esac
+}
+
+#
+# load_rc_config
+# Source in the configuration file for a given command.
+#
+load_rc_config()
+{
+ _command=$1
+ if [ -z "$_command" ]; then
+ err 3 'USAGE: load_rc_config command'
+ fi
+
+ . /etc/rc.conf
+ if [ -f /etc/rc.conf.d/"$_command" ]; then
+ . /etc/rc.conf.d/"$_command"
+ fi
+}
+
+
+#
+# rc_usage commands
+# Print a usage string for $0, with `commands' being a list of
+# valid commands.
+#
+rc_usage()
+{
+ echo -n 1>&2 "Usage: $0 [fast|force]("
+
+ _sep=
+ for _elem in $*; do
+ echo -n 1>&2 "$_sep$_elem"
+ _sep="|"
+ done
+ echo 1>&2 ")"
+ exit 1
+}
+
+#
+# err exitval message
+# Display message to stderr and log to the syslog, and exit with exitval.
+#
+err()
+{
+ exitval=$1
+ shift
+
+ logger "$0: ERROR: $*"
+ echo 1>&2 "$0: ERROR: $*"
+ exit $exitval
+}
+
+#
+# warn message
+# Display message to stderr and log to the syslog.
+#
+warn()
+{
+ logger "$0: WARNING: $*"
+ echo 1>&2 "$0: WARNING: $*"
+}
diff --git a/sbin/rcorder/Makefile b/sbin/rcorder/Makefile
new file mode 100644
index 0000000..ccac08a
--- /dev/null
+++ b/sbin/rcorder/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 1999/11/23 05:28:20 mrg Exp $
+
+PROG= rcorder
+SRCS= ealloc.c hash.c rcorder.c
+MAN= rcorder.8
+
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
+
+# XXX hack for make's hash.[ch]
+CPPFLAGS+= -DORDER
+
+.include <bsd.prog.mk>
diff --git a/sbin/rcorder/ealloc.c b/sbin/rcorder/ealloc.c
new file mode 100644
index 0000000..9accebe
--- /dev/null
+++ b/sbin/rcorder/ealloc.c
@@ -0,0 +1,123 @@
+/* $NetBSD: ealloc.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: ealloc.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $");
+#endif /* not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+
+#include "ealloc.h"
+
+static void enomem __P((void));
+
+/*
+ * enomem --
+ * die when out of memory.
+ */
+static void
+enomem()
+{
+ errx(2, "Cannot allocate memory.");
+}
+
+/*
+ * emalloc --
+ * malloc, but die on error.
+ */
+void *
+emalloc(len)
+ size_t len;
+{
+ void *p;
+
+ if ((p = malloc(len)) == NULL)
+ enomem();
+ return(p);
+}
+
+/*
+ * estrdup --
+ * strdup, but die on error.
+ */
+char *
+estrdup(str)
+ const char *str;
+{
+ char *p;
+
+ if ((p = strdup(str)) == NULL)
+ enomem();
+ return(p);
+}
+
+/*
+ * erealloc --
+ * realloc, but die on error.
+ */
+void *
+erealloc(ptr, size)
+ void *ptr;
+ size_t size;
+{
+ if ((ptr = realloc(ptr, size)) == NULL)
+ enomem();
+ return(ptr);
+}
+
+/*
+ * ecalloc --
+ * calloc, but die on error.
+ */
+void *
+ecalloc(nmemb, size)
+ size_t nmemb;
+ size_t size;
+{
+ void *ptr;
+
+ if ((ptr = calloc(nmemb, size)) == NULL)
+ enomem();
+ return(ptr);
+}
diff --git a/sbin/rcorder/ealloc.h b/sbin/rcorder/ealloc.h
new file mode 100644
index 0000000..fb753d5f
--- /dev/null
+++ b/sbin/rcorder/ealloc.h
@@ -0,0 +1,6 @@
+/* $NetBSD: ealloc.h,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ */
+
+void *emalloc __P((size_t len));
+char *estrdup __P((const char *str));
+void *erealloc __P((void *ptr, size_t size));
+void *ecalloc __P((size_t nmemb, size_t size));
diff --git a/sbin/rcorder/hash.c b/sbin/rcorder/hash.c
new file mode 100644
index 0000000..5ec335a
--- /dev/null
+++ b/sbin/rcorder/hash.c
@@ -0,0 +1,438 @@
+/* $NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+#ifdef MAKE_BOOTSTRAP
+static char rcsid[] = "$NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $";
+#else
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
+#else
+__RCSID("$NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $");
+#endif
+#endif /* not lint */
+#endif
+
+#include <sys/types.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* hash.c --
+ *
+ * This module contains routines to manipulate a hash table.
+ * See hash.h for a definition of the structure of the hash
+ * table. Hash tables grow automatically as the amount of
+ * information increases.
+ */
+#include "sprite.h"
+#ifndef ORDER
+#include "make.h"
+#endif /* ORDER */
+#include "hash.h"
+#include "ealloc.h"
+
+/*
+ * Forward references to local procedures that are used before they're
+ * defined:
+ */
+
+static void RebuildTable __P((Hash_Table *));
+
+/*
+ * The following defines the ratio of # entries to # buckets
+ * at which we rebuild the table to make it larger.
+ */
+
+#define rebuildLimit 8
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_InitTable --
+ *
+ * This routine just sets up the hash table.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Memory is allocated for the initial bucket area.
+ *
+ *---------------------------------------------------------
+ */
+
+void
+Hash_InitTable(t, numBuckets)
+ register Hash_Table *t; /* Structure to use to hold table. */
+ int numBuckets; /* How many buckets to create for starters.
+ * This number is rounded up to a power of
+ * two. If <= 0, a reasonable default is
+ * chosen. The table will grow in size later
+ * as needed. */
+{
+ register int i;
+ register struct Hash_Entry **hp;
+
+ /*
+ * Round up the size to a power of two.
+ */
+ if (numBuckets <= 0)
+ i = 16;
+ else {
+ for (i = 2; i < numBuckets; i <<= 1)
+ continue;
+ }
+ t->numEntries = 0;
+ t->size = i;
+ t->mask = i - 1;
+ t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
+ while (--i >= 0)
+ *hp++ = NULL;
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_DeleteTable --
+ *
+ * This routine removes everything from a hash table
+ * and frees up the memory space it occupied (except for
+ * the space in the Hash_Table structure).
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Lots of memory is freed up.
+ *
+ *---------------------------------------------------------
+ */
+
+void
+Hash_DeleteTable(t)
+ Hash_Table *t;
+{
+ register struct Hash_Entry **hp, *h, *nexth = NULL;
+ register int i;
+
+ for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
+ for (h = *hp++; h != NULL; h = nexth) {
+ nexth = h->next;
+ free((char *)h);
+ }
+ }
+ free((char *)t->bucketPtr);
+
+ /*
+ * Set up the hash table to cause memory faults on any future access
+ * attempts until re-initialization.
+ */
+ t->bucketPtr = NULL;
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_FindEntry --
+ *
+ * Searches a hash table for an entry corresponding to key.
+ *
+ * Results:
+ * The return value is a pointer to the entry for key,
+ * if key was present in the table. If key was not
+ * present, NULL is returned.
+ *
+ * Side Effects:
+ * None.
+ *
+ *---------------------------------------------------------
+ */
+
+Hash_Entry *
+Hash_FindEntry(t, key)
+ Hash_Table *t; /* Hash table to search. */
+ char *key; /* A hash key. */
+{
+ register Hash_Entry *e;
+ register unsigned h;
+ register char *p;
+
+ for (h = 0, p = key; *p;)
+ h = (h << 5) - h + *p++;
+ p = key;
+ for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next)
+ if (e->namehash == h && strcmp(e->name, p) == 0)
+ return (e);
+ return (NULL);
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_CreateEntry --
+ *
+ * Searches a hash table for an entry corresponding to
+ * key. If no entry is found, then one is created.
+ *
+ * Results:
+ * The return value is a pointer to the entry. If *newPtr
+ * isn't NULL, then *newPtr is filled in with TRUE if a
+ * new entry was created, and FALSE if an entry already existed
+ * with the given key.
+ *
+ * Side Effects:
+ * Memory may be allocated, and the hash buckets may be modified.
+ *---------------------------------------------------------
+ */
+
+Hash_Entry *
+Hash_CreateEntry(t, key, newPtr)
+ register Hash_Table *t; /* Hash table to search. */
+ char *key; /* A hash key. */
+ Boolean *newPtr; /* Filled in with TRUE if new entry created,
+ * FALSE otherwise. */
+{
+ register Hash_Entry *e;
+ register unsigned h;
+ register char *p;
+ int keylen;
+ struct Hash_Entry **hp;
+
+ /*
+ * Hash the key. As a side effect, save the length (strlen) of the
+ * key in case we need to create the entry.
+ */
+ for (h = 0, p = key; *p;)
+ h = (h << 5) - h + *p++;
+ keylen = p - key;
+ p = key;
+ for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
+ if (e->namehash == h && strcmp(e->name, p) == 0) {
+ if (newPtr != NULL)
+ *newPtr = FALSE;
+ return (e);
+ }
+ }
+
+ /*
+ * The desired entry isn't there. Before allocating a new entry,
+ * expand the table if necessary (and this changes the resulting
+ * bucket chain).
+ */
+ if (t->numEntries >= rebuildLimit * t->size)
+ RebuildTable(t);
+ e = (Hash_Entry *) emalloc(sizeof(*e) + keylen);
+ hp = &t->bucketPtr[h & t->mask];
+ e->next = *hp;
+ *hp = e;
+ e->clientData = NULL;
+ e->namehash = h;
+ (void) strcpy(e->name, p);
+ t->numEntries++;
+
+ if (newPtr != NULL)
+ *newPtr = TRUE;
+ return (e);
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_DeleteEntry --
+ *
+ * Delete the given hash table entry and free memory associated with
+ * it.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Hash chain that entry lives in is modified and memory is freed.
+ *
+ *---------------------------------------------------------
+ */
+
+void
+Hash_DeleteEntry(t, e)
+ Hash_Table *t;
+ Hash_Entry *e;
+{
+ register Hash_Entry **hp, *p;
+
+ if (e == NULL)
+ return;
+ for (hp = &t->bucketPtr[e->namehash & t->mask];
+ (p = *hp) != NULL; hp = &p->next) {
+ if (p == e) {
+ *hp = p->next;
+ free((char *)p);
+ t->numEntries--;
+ return;
+ }
+ }
+ (void)write(2, "bad call to Hash_DeleteEntry\n", 29);
+ abort();
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_EnumFirst --
+ * This procedure sets things up for a complete search
+ * of all entries recorded in the hash table.
+ *
+ * Results:
+ * The return value is the address of the first entry in
+ * the hash table, or NULL if the table is empty.
+ *
+ * Side Effects:
+ * The information in searchPtr is initialized so that successive
+ * calls to Hash_Next will return successive HashEntry's
+ * from the table.
+ *
+ *---------------------------------------------------------
+ */
+
+Hash_Entry *
+Hash_EnumFirst(t, searchPtr)
+ Hash_Table *t; /* Table to be searched. */
+ register Hash_Search *searchPtr;/* Area in which to keep state
+ * about search.*/
+{
+ searchPtr->tablePtr = t;
+ searchPtr->nextIndex = 0;
+ searchPtr->hashEntryPtr = NULL;
+ return Hash_EnumNext(searchPtr);
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * Hash_EnumNext --
+ * This procedure returns successive entries in the hash table.
+ *
+ * Results:
+ * The return value is a pointer to the next HashEntry
+ * in the table, or NULL when the end of the table is
+ * reached.
+ *
+ * Side Effects:
+ * The information in searchPtr is modified to advance to the
+ * next entry.
+ *
+ *---------------------------------------------------------
+ */
+
+Hash_Entry *
+Hash_EnumNext(searchPtr)
+ register Hash_Search *searchPtr; /* Area used to keep state about
+ search. */
+{
+ register Hash_Entry *e;
+ Hash_Table *t = searchPtr->tablePtr;
+
+ /*
+ * The hashEntryPtr field points to the most recently returned
+ * entry, or is nil if we are starting up. If not nil, we have
+ * to start at the next one in the chain.
+ */
+ e = searchPtr->hashEntryPtr;
+ if (e != NULL)
+ e = e->next;
+ /*
+ * If the chain ran out, or if we are starting up, we need to
+ * find the next nonempty chain.
+ */
+ while (e == NULL) {
+ if (searchPtr->nextIndex >= t->size)
+ return (NULL);
+ e = t->bucketPtr[searchPtr->nextIndex++];
+ }
+ searchPtr->hashEntryPtr = e;
+ return (e);
+}
+
+/*
+ *---------------------------------------------------------
+ *
+ * RebuildTable --
+ * This local routine makes a new hash table that
+ * is larger than the old one.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The entire hash table is moved, so any bucket numbers
+ * from the old table are invalid.
+ *
+ *---------------------------------------------------------
+ */
+
+static void
+RebuildTable(t)
+ register Hash_Table *t;
+{
+ register Hash_Entry *e, *next = NULL, **hp, **xp;
+ register int i, mask;
+ register Hash_Entry **oldhp;
+ int oldsize;
+
+ oldhp = t->bucketPtr;
+ oldsize = i = t->size;
+ i <<= 1;
+ t->size = i;
+ t->mask = mask = i - 1;
+ t->bucketPtr = hp = (struct Hash_Entry **) emalloc(sizeof(*hp) * i);
+ while (--i >= 0)
+ *hp++ = NULL;
+ for (hp = oldhp, i = oldsize; --i >= 0;) {
+ for (e = *hp++; e != NULL; e = next) {
+ next = e->next;
+ xp = &t->bucketPtr[e->namehash & mask];
+ e->next = *xp;
+ *xp = e;
+ }
+ }
+ free((char *)oldhp);
+}
diff --git a/sbin/rcorder/hash.h b/sbin/rcorder/hash.h
new file mode 100644
index 0000000..cf15256
--- /dev/null
+++ b/sbin/rcorder/hash.h
@@ -0,0 +1,130 @@
+/* $NetBSD: hash.h,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: @(#)hash.h 8.1 (Berkeley) 6/6/93
+ */
+
+/* hash.h --
+ *
+ * This file contains definitions used by the hash module,
+ * which maintains hash tables.
+ */
+
+#ifndef _HASH
+#define _HASH
+
+/*
+ * The following defines one entry in the hash table.
+ */
+
+typedef struct Hash_Entry {
+ struct Hash_Entry *next; /* Used to link together all the
+ * entries associated with the same
+ * bucket. */
+ ClientData clientData; /* Arbitrary piece of data associated
+ * with key. */
+ unsigned namehash; /* hash value of key */
+ char name[1]; /* key string */
+} Hash_Entry;
+
+typedef struct Hash_Table {
+ struct Hash_Entry **bucketPtr;
+ /* Pointers to Hash_Entry, one
+ * for each bucket in the table. */
+ int size; /* Actual size of array. */
+ int numEntries; /* Number of entries in the table. */
+ int mask; /* Used to select bits for hashing. */
+} Hash_Table;
+
+/*
+ * The following structure is used by the searching routines
+ * to record where we are in the search.
+ */
+
+typedef struct Hash_Search {
+ Hash_Table *tablePtr; /* Table being searched. */
+ int nextIndex; /* Next bucket to check (after
+ * current). */
+ Hash_Entry *hashEntryPtr; /* Next entry to check in current
+ * bucket. */
+} Hash_Search;
+
+/*
+ * Macros.
+ */
+
+/*
+ * ClientData Hash_GetValue(h)
+ * Hash_Entry *h;
+ */
+
+#define Hash_GetValue(h) ((h)->clientData)
+
+/*
+ * Hash_SetValue(h, val);
+ * Hash_Entry *h;
+ * char *val;
+ */
+
+#define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val))
+
+#ifdef ORDER
+/*
+ * Hash_GetKey(h);
+ * Hash_Entry *h;
+ */
+
+#define Hash_GetKey(h) ((h)->name)
+#endif /* ORDER */
+
+/*
+ * Hash_Size(n) returns the number of words in an object of n bytes
+ */
+
+#define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int))
+
+void Hash_InitTable __P((Hash_Table *, int));
+void Hash_DeleteTable __P((Hash_Table *));
+Hash_Entry *Hash_FindEntry __P((Hash_Table *, char *));
+Hash_Entry *Hash_CreateEntry __P((Hash_Table *, char *, Boolean *));
+void Hash_DeleteEntry __P((Hash_Table *, Hash_Entry *));
+Hash_Entry *Hash_EnumFirst __P((Hash_Table *, Hash_Search *));
+Hash_Entry *Hash_EnumNext __P((Hash_Search *));
+
+#endif /* _HASH */
diff --git a/sbin/rcorder/rcorder.8 b/sbin/rcorder/rcorder.8
new file mode 100644
index 0000000..2ba623b
--- /dev/null
+++ b/sbin/rcorder/rcorder.8
@@ -0,0 +1,158 @@
+.\" $NetBSD: rcorder.8,v 1.2 2000/07/05 15:45:30 msaitoh Exp $
+.\"
+.\" Copyright (c) 1998
+.\" Perry E. Metzger. 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.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgment:
+.\" This product includes software developed for the NetBSD Project
+.\" by Perry E. Metzger.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+.\"
+.\"
+.Dd July 17, 2000
+.Dt RCORDER 8
+.Os
+.Sh NAME
+.Nm rcorder
+.Nd print a dependency ordering of interdependent files
+.Sh SYNOPSIS
+.Nm
+.Op Fl k Ar keep
+.Op Fl s Ar skip
+.Ar
+.Sh DESCRIPTION
+.Nm
+is designed to print out a dependency ordering of a set of
+interdependent files. Typically it is used to find an execution
+sequence for a set of shell scripts in which certain files must be
+executed before others.
+.Pp
+Each file passed to
+.Nm
+must be annotated with special lines (which look like comments to the
+shell) which indicate the dependencies the files have upon certain
+points in the sequence, known as
+.Dq conditions ,
+and which indicate, for each file, which
+.Dq conditions
+may be expected to be filled by that file.
+.Pp
+Within each file, a block containing a series of
+.Dq REQUIRE ,
+.Dq PROVIDE ,
+.Dq BEFORE
+and
+.Dq KEYWORD
+lines must appear.
+The format of the lines is rigid. Each line must begin with a single
+.Dq # ,
+followed by a single space, followed by
+.Dq PROVIDE: ,
+.Dq REQUIRE: ,
+.Dq BEFORE: ,
+or
+.Dq KEYWORD: .
+No deviation is permitted.
+Each dependency line is then followed by a series of conditions,
+separated by whitespace. Multiple
+.Dq PROVIDE ,
+.Dq REQUIRE ,
+.Dq BEFORE
+and
+.Dq KEYWORD
+lines may appear, but all such lines must appear in a sequence without
+any intervening lines, as once a line that does not follow the format
+is reached, parsing stops.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl k
+Add the specified keyword to the
+.Dq keep list .
+If any
+.Fl k
+option is given, only those files containing the matching keyword are listed.
+.It Fl s
+Add the specified keyword to the
+.Dq skip list .
+If any
+.Fl s
+option is given, files containing the matching keyword are not listed.
+.El
+.Pp
+ An example block follows:
+.Bd -literal -offset indent
+# REQUIRE: networking syslog
+# REQUIRE: usr
+# PROVIDE: dns nscd
+.Ed
+.Pp
+This block states that the file in which it appears depends upon the
+.Dq networking ,
+.Dq syslog ,
+and
+.Dq usr
+conditions, and provides the
+.Dq dns
+and
+.Dq nscd
+conditions.
+.Pp
+A file may contain zero
+.Dq PROVIDE
+lines, in which case it provides no conditions, and may contain zero
+.Dq REQUIRE
+lines, in which case it has no dependencies.
+There must be at least one file with no dependencies in the set of
+arguments passed to
+.Nm
+in order for it to find a starting place in the dependency ordering.
+.Sh DIAGNOSTICS
+.Nm
+may print one of the following error messages and exit with a non-zero
+status if it encounters an error while processing the file list.
+.Bl -diag
+.It "Requirement %s has no providers, aborting."
+No file has a
+.Dq PROVIDE
+line corresponding to a condition present in a
+.Dq REQUIRE
+line in another file.
+.It "Circular dependency on provision %s, aborting."
+A set of files has a circular dependency which was detected while
+processing the stated condition.
+.It "Circular dependency on file %s, aborting."
+A set of files has a circular dependency which was detected while
+processing the stated file.
+.El
+.Sh SEE ALSO
+.Xr rc 8
+.Sh HISTORY
+The
+.Nm
+program first appeared in
+.Nx 1.5 .
+.Sh AUTHORS
+Written by Perry E. Metzger (perry@piermont.com) and Matthew R.
+Green (mrg@eterna.com.au).
diff --git a/sbin/rcorder/rcorder.c b/sbin/rcorder/rcorder.c
new file mode 100644
index 0000000..03a397f
--- /dev/null
+++ b/sbin/rcorder/rcorder.c
@@ -0,0 +1,819 @@
+/* $NetBSD: rcorder.c,v 1.6 2000/07/19 09:58:03 enami Exp $ */
+
+/*
+ * Copyright (c) 1998, 1999 Matthew R. Green
+ * All rights reserved.
+ * Copyright (c) 1998
+ * Perry E. Metzger. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Perry E. Metzger.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+
+#include "ealloc.h"
+#include "sprite.h"
+#include "hash.h"
+
+#ifdef DEBUG
+int debug = 0;
+# define DPRINTF(args) if (debug) { fflush(stdout); fprintf args; }
+#else
+# define DPRINTF(args)
+#endif
+
+#define REQUIRE_STR "# REQUIRE:"
+#define REQUIRE_LEN (sizeof(REQUIRE_STR) - 1)
+#define REQUIRES_STR "# REQUIRES:"
+#define REQUIRES_LEN (sizeof(REQUIRES_STR) - 1)
+#define PROVIDE_STR "# PROVIDE:"
+#define PROVIDE_LEN (sizeof(PROVIDE_STR) - 1)
+#define PROVIDES_STR "# PROVIDES:"
+#define PROVIDES_LEN (sizeof(PROVIDES_STR) - 1)
+#define BEFORE_STR "# BEFORE:"
+#define BEFORE_LEN (sizeof(BEFORE_STR) - 1)
+#define KEYWORD_STR "# KEYWORD:"
+#define KEYWORD_LEN (sizeof(KEYWORD_STR) - 1)
+#define KEYWORDS_STR "# KEYWORDS:"
+#define KEYWORDS_LEN (sizeof(KEYWORDS_STR) - 1)
+
+int exit_code;
+int file_count;
+char **file_list;
+
+typedef int bool;
+#define TRUE 1
+#define FALSE 0
+typedef bool flag;
+#define SET TRUE
+#define RESET FALSE
+
+Hash_Table provide_hash_s, *provide_hash;
+
+typedef struct provnode provnode;
+typedef struct filenode filenode;
+typedef struct f_provnode f_provnode;
+typedef struct f_reqnode f_reqnode;
+typedef struct strnodelist strnodelist;
+
+struct provnode {
+ flag head;
+ flag in_progress;
+ filenode *fnode;
+ provnode *next, *last;
+};
+
+struct f_provnode {
+ provnode *pnode;
+ f_provnode *next;
+};
+
+struct f_reqnode {
+ Hash_Entry *entry;
+ f_reqnode *next;
+};
+
+struct strnodelist {
+ filenode *node;
+ strnodelist *next;
+ char s[1];
+};
+
+struct filenode {
+ char *filename;
+ flag in_progress;
+ filenode *next, *last;
+ f_reqnode *req_list;
+ f_provnode *prov_list;
+ strnodelist *keyword_list;
+};
+
+filenode fn_head_s, *fn_head;
+
+strnodelist *bl_list;
+strnodelist *keep_list;
+strnodelist *skip_list;
+
+void do_file __P((filenode *fnode));
+void strnode_add __P((strnodelist **, char *, filenode *));
+int skip_ok __P((filenode *fnode));
+int keep_ok __P((filenode *fnode));
+void satisfy_req __P((f_reqnode *rnode, char *filename));
+void crunch_file __P((char *));
+void parse_require __P((filenode *, char *));
+void parse_provide __P((filenode *, char *));
+void parse_before __P((filenode *, char *));
+void parse_keywords __P((filenode *, char *));
+filenode *filenode_new __P((char *));
+void add_require __P((filenode *, char *));
+void add_provide __P((filenode *, char *));
+void add_before __P((filenode *, char *));
+void add_keyword __P((filenode *, char *));
+void insert_before __P((void));
+Hash_Entry *make_fake_provision __P((filenode *));
+void crunch_all_files __P((void));
+void initialize __P((void));
+void generate_ordering __P((void));
+int main __P((int, char *[]));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int ch;
+
+ while ((ch = getopt(argc, argv, "dk:s:")) != -1)
+ switch (ch) {
+ case 'd':
+#ifdef DEBUG
+ debug = 1;
+#else
+ warnx("debugging not compiled in, -d ignored");
+#endif
+ break;
+ case 'k':
+ strnode_add(&keep_list, optarg, 0);
+ break;
+ case 's':
+ strnode_add(&skip_list, optarg, 0);
+ break;
+ default:
+ /* XXX should crunch it? */
+ break;
+ }
+ argc -= optind;
+ argv += optind;
+
+ file_count = argc;
+ file_list = argv;
+
+ DPRINTF((stderr, "parse_args\n"));
+ initialize();
+ DPRINTF((stderr, "initialize\n"));
+ crunch_all_files();
+ DPRINTF((stderr, "crunch_all_files\n"));
+ generate_ordering();
+ DPRINTF((stderr, "generate_ordering\n"));
+
+ exit(exit_code);
+}
+
+/*
+ * initialise various variables.
+ */
+void
+initialize()
+{
+
+ fn_head = &fn_head_s;
+
+ provide_hash = &provide_hash_s;
+ Hash_InitTable(provide_hash, file_count);
+}
+
+/* generic function to insert a new strnodelist element */
+void
+strnode_add(listp, s, fnode)
+ strnodelist **listp;
+ char *s;
+ filenode *fnode;
+{
+ strnodelist *ent;
+
+ ent = emalloc(sizeof *ent + strlen(s));
+ ent->node = fnode;
+ strcpy(ent->s, s);
+ ent->next = *listp;
+ *listp = ent;
+}
+
+/*
+ * below are the functions that deal with creating the lists
+ * from the filename's given and the dependancies and provisions
+ * in each of these files. no ordering or checking is done here.
+ */
+
+/*
+ * we have a new filename, create a new filenode structure.
+ * fill in the bits, and put it in the filenode linked list
+ */
+filenode *
+filenode_new(filename)
+ char *filename;
+{
+ filenode *temp;
+
+ temp = emalloc(sizeof(*temp));
+ memset(temp, 0, sizeof(*temp));
+ temp->filename = estrdup(filename);
+ temp->req_list = NULL;
+ temp->prov_list = NULL;
+ temp->keyword_list = NULL;
+ temp->in_progress = RESET;
+ /*
+ * link the filenode into the list of filenodes.
+ * note that the double linking means we can delete a
+ * filenode without searching for where it belongs.
+ */
+ temp->next = fn_head->next;
+ if (temp->next != NULL)
+ temp->next->last = temp;
+ temp->last = fn_head;
+ fn_head->next = temp;
+ return (temp);
+}
+
+/*
+ * add a requirement to a filenode.
+ */
+void
+add_require(fnode, s)
+ filenode *fnode;
+ char *s;
+{
+ Hash_Entry *entry;
+ f_reqnode *rnode;
+ int new;
+
+ entry = Hash_CreateEntry(provide_hash, s, &new);
+ if (new)
+ Hash_SetValue(entry, NULL);
+ rnode = emalloc(sizeof(*rnode));
+ rnode->entry = entry;
+ rnode->next = fnode->req_list;
+ fnode->req_list = rnode;
+}
+
+/*
+ * add a provision to a filenode. if this provision doesn't
+ * have a head node, create one here.
+ */
+void
+add_provide(fnode, s)
+ filenode *fnode;
+ char *s;
+{
+ Hash_Entry *entry;
+ f_provnode *f_pnode;
+ provnode *pnode, *head;
+ int new;
+
+ entry = Hash_CreateEntry(provide_hash, s, &new);
+ head = Hash_GetValue(entry);
+
+ /* create a head node if necessary. */
+ if (head == NULL) {
+ head = emalloc(sizeof(*head));
+ head->head = SET;
+ head->in_progress = RESET;
+ head->fnode = NULL;
+ head->last = head->next = NULL;
+ Hash_SetValue(entry, head);
+ }
+#if 0
+ /*
+ * Don't warn about this. We want to be able to support
+ * scripts that do two complex things:
+ *
+ * - Two independent scripts which both provide the
+ * same thing. Both scripts must be executed in
+ * any order to meet the barrier. An example:
+ *
+ * Script 1:
+ *
+ * PROVIDE: mail
+ * REQUIRE: LOGIN
+ *
+ * Script 2:
+ *
+ * PROVIDE: mail
+ * REQUIRE: LOGIN
+ *
+ * - Two interdependent scripts which both provide the
+ * same thing. Both scripts must be executed in
+ * graph order to meet the barrier. An example:
+ *
+ * Script 1:
+ *
+ * PROVIDE: nameservice dnscache
+ * REQUIRE: SERVERS
+ *
+ * Script 2:
+ *
+ * PROVIDE: nameservice nscd
+ * REQUIRE: dnscache
+ */
+ else if (new == 0) {
+ warnx("file `%s' provides `%s'.", fnode->filename, s);
+ warnx("\tpreviously seen in `%s'.",
+ head->next->fnode->filename);
+ }
+#endif
+
+ pnode = emalloc(sizeof(*pnode));
+ pnode->head = RESET;
+ pnode->in_progress = RESET;
+ pnode->fnode = fnode;
+ pnode->next = head->next;
+ pnode->last = head;
+ head->next = pnode;
+ if (pnode->next != NULL)
+ pnode->next->last = pnode;
+
+ f_pnode = emalloc(sizeof(*f_pnode));
+ f_pnode->pnode = pnode;
+ f_pnode->next = fnode->prov_list;
+ fnode->prov_list = f_pnode;
+}
+
+/*
+ * put the BEFORE: lines to a list and handle them later.
+ */
+void
+add_before(fnode, s)
+ filenode *fnode;
+ char *s;
+{
+ strnodelist *bf_ent;
+
+ bf_ent = emalloc(sizeof *bf_ent + strlen(s));
+ bf_ent->node = fnode;
+ strcpy(bf_ent->s, s);
+ bf_ent->next = bl_list;
+ bl_list = bf_ent;
+}
+
+/*
+ * add a key to a filenode.
+ */
+void
+add_keyword(fnode, s)
+ filenode *fnode;
+ char *s;
+{
+
+ strnode_add(&fnode->keyword_list, s, fnode);
+}
+
+/*
+ * loop over the rest of a REQUIRE line, giving each word to
+ * add_require() to do the real work.
+ */
+void
+parse_require(node, buffer)
+ filenode *node;
+ char *buffer;
+{
+ char *s;
+
+ while ((s = strsep(&buffer, " \t\n")) != NULL)
+ if (*s != '\0')
+ add_require(node, s);
+}
+
+/*
+ * loop over the rest of a PROVIDE line, giving each word to
+ * add_provide() to do the real work.
+ */
+void
+parse_provide(node, buffer)
+ filenode *node;
+ char *buffer;
+{
+ char *s;
+
+ while ((s = strsep(&buffer, " \t\n")) != NULL)
+ if (*s != '\0')
+ add_provide(node, s);
+}
+
+/*
+ * loop over the rest of a BEFORE line, giving each word to
+ * add_before() to do the real work.
+ */
+void
+parse_before(node, buffer)
+ filenode *node;
+ char *buffer;
+{
+ char *s;
+
+ while ((s = strsep(&buffer, " \t\n")) != NULL)
+ if (*s != '\0')
+ add_before(node, s);
+}
+
+/*
+ * loop over the rest of a KEYWORD line, giving each word to
+ * add_keyword() to do the real work.
+ */
+void
+parse_keywords(node, buffer)
+ filenode *node;
+ char *buffer;
+{
+ char *s;
+
+ while ((s = strsep(&buffer, " \t\n")) != NULL)
+ if (*s != '\0')
+ add_keyword(node, s);
+}
+
+/*
+ * given a file name, create a filenode for it, read in lines looking
+ * for provision and requirement lines, building the graphs as needed.
+ */
+void
+crunch_file(filename)
+ char *filename;
+{
+ FILE *fp;
+ char *buf;
+ int require_flag, provide_flag, before_flag, keywords_flag;
+ enum { BEFORE_PARSING, PARSING, PARSING_DONE } state;
+ filenode *node;
+ char delims[3] = { '\\', '\\', '\0' };
+ struct stat st;
+
+ if ((fp = fopen(filename, "r")) == NULL) {
+ warn("could not open %s", filename);
+ return;
+ }
+
+ if (fstat(fileno(fp), &st) == -1) {
+ warn("could not stat %s", filename);
+ fclose(fp);
+ return;
+ }
+
+ if (!S_ISREG(st.st_mode)) {
+ warnx("%s is not a file", filename);
+ fclose(fp);
+ return;
+ }
+
+ node = filenode_new(filename);
+
+ /*
+ * we don't care about length, line number, don't want # for comments,
+ * and have no flags.
+ */
+ for (state = BEFORE_PARSING; state != PARSING_DONE &&
+ (buf = fparseln(fp, NULL, NULL, delims, 0)) != NULL; free(buf)) {
+ require_flag = provide_flag = before_flag = keywords_flag = 0;
+ if (strncmp(REQUIRE_STR, buf, REQUIRE_LEN) == 0)
+ require_flag = REQUIRE_LEN;
+ else if (strncmp(REQUIRES_STR, buf, REQUIRES_LEN) == 0)
+ require_flag = REQUIRES_LEN;
+ else if (strncmp(PROVIDE_STR, buf, PROVIDE_LEN) == 0)
+ provide_flag = PROVIDE_LEN;
+ else if (strncmp(PROVIDES_STR, buf, PROVIDES_LEN) == 0)
+ provide_flag = PROVIDES_LEN;
+ else if (strncmp(BEFORE_STR, buf, BEFORE_LEN) == 0)
+ before_flag = BEFORE_LEN;
+ else if (strncmp(KEYWORD_STR, buf, KEYWORD_LEN) == 0)
+ keywords_flag = KEYWORD_LEN;
+ else if (strncmp(KEYWORDS_STR, buf, KEYWORDS_LEN) == 0)
+ keywords_flag = KEYWORDS_LEN;
+ else {
+ if (state == PARSING)
+ state = PARSING_DONE;
+ continue;
+ }
+
+ state = PARSING;
+ if (require_flag)
+ parse_require(node, buf + require_flag);
+ else if (provide_flag)
+ parse_provide(node, buf + provide_flag);
+ else if (before_flag)
+ parse_before(node, buf + before_flag);
+ else if (keywords_flag)
+ parse_keywords(node, buf + keywords_flag);
+ }
+ fclose(fp);
+}
+
+Hash_Entry *
+make_fake_provision(node)
+ filenode *node;
+{
+ Hash_Entry *entry;
+ f_provnode *f_pnode;
+ provnode *head, *pnode;
+ static int i = 0;
+ int new;
+ char buffer[30];
+
+ do {
+ snprintf(buffer, sizeof buffer, "fake_prov_%08d", i++);
+ entry = Hash_CreateEntry(provide_hash, buffer, &new);
+ } while (new == 0);
+ head = emalloc(sizeof(*head));
+ head->head = SET;
+ head->in_progress = RESET;
+ head->fnode = NULL;
+ head->last = head->next = NULL;
+ Hash_SetValue(entry, head);
+
+ pnode = emalloc(sizeof(*pnode));
+ pnode->head = RESET;
+ pnode->in_progress = RESET;
+ pnode->fnode = node;
+ pnode->next = head->next;
+ pnode->last = head;
+ head->next = pnode;
+ if (pnode->next != NULL)
+ pnode->next->last = pnode;
+
+ f_pnode = emalloc(sizeof(*f_pnode));
+ f_pnode->pnode = pnode;
+ f_pnode->next = node->prov_list;
+ node->prov_list = f_pnode;
+
+ return (entry);
+}
+
+/*
+ * go through the BEFORE list, inserting requirements into the graph(s)
+ * as required. in the before list, for each entry B, we have a file F
+ * and a string S. we create a "fake" provision (P) that F provides.
+ * for each entry in the provision list for S, add a requirement to
+ * that provisions filenode for P.
+ */
+void
+insert_before()
+{
+ Hash_Entry *entry, *fake_prov_entry;
+ provnode *pnode;
+ f_reqnode *rnode;
+ strnodelist *bl;
+ int new;
+
+ while (bl_list != NULL) {
+ bl = bl_list->next;
+
+ fake_prov_entry = make_fake_provision(bl_list->node);
+
+ entry = Hash_CreateEntry(provide_hash, bl_list->s, &new);
+ if (new == 1)
+ warnx("file `%s' is before unknown provision `%s'", bl_list->node->filename, bl_list->s);
+
+ for (pnode = Hash_GetValue(entry); pnode; pnode = pnode->next) {
+ if (pnode->head)
+ continue;
+
+ rnode = emalloc(sizeof(*rnode));
+ rnode->entry = fake_prov_entry;
+ rnode->next = pnode->fnode->req_list;
+ pnode->fnode->req_list = rnode;
+ }
+
+ free(bl_list);
+ bl_list = bl;
+ }
+}
+
+/*
+ * loop over all the files calling crunch_file() on them to do the
+ * real work. after we have built all the nodes, insert the BEFORE:
+ * lines into graph(s).
+ */
+void
+crunch_all_files()
+{
+ int i;
+
+ for (i = 0; i < file_count; i++)
+ crunch_file(file_list[i]);
+ insert_before();
+}
+
+/*
+ * below are the functions that traverse the graphs we have built
+ * finding out the desired ordering, printing each file in turn.
+ * if missing requirements, or cyclic graphs are detected, a
+ * warning will be issued, and we will continue on..
+ */
+
+/*
+ * given a requirement node (in a filename) we attempt to satisfy it.
+ * we do some sanity checking first, to ensure that we have providers,
+ * aren't already satisfied and aren't already being satisfied (ie,
+ * cyclic). if we pass all this, we loop over the provision list
+ * calling do_file() (enter recursion) for each filenode in this
+ * provision.
+ */
+void
+satisfy_req(rnode, filename)
+ f_reqnode *rnode;
+ char *filename;
+{
+ Hash_Entry *entry;
+ provnode *head;
+
+ entry = rnode->entry;
+ head = Hash_GetValue(entry);
+
+ if (head == NULL) {
+ warnx("requirement `%s' in file `%s' has no providers.",
+ Hash_GetKey(entry), filename);
+ exit_code = 1;
+ return;
+ }
+
+ /* return if the requirement is already satisfied. */
+ if (head->next == NULL)
+ return;
+
+ /*
+ * if list is marked as in progress,
+ * print that there is a circular dependency on it and abort
+ */
+ if (head->in_progress == SET) {
+ warnx("Circular dependency on provision `%s' in file `%s'.",
+ Hash_GetKey(entry), filename);
+ exit_code = 1;
+ return;
+ }
+
+ head->in_progress = SET;
+
+ /*
+ * while provision_list is not empty
+ * do_file(first_member_of(provision_list));
+ */
+ while (head->next != NULL)
+ do_file(head->next->fnode);
+}
+
+int
+skip_ok(fnode)
+ filenode *fnode;
+{
+ strnodelist *s;
+ strnodelist *k;
+
+ for (s = skip_list; s; s = s->next)
+ for (k = fnode->keyword_list; k; k = k->next)
+ if (strcmp(k->s, s->s) == 0)
+ return (0);
+
+ return (1);
+}
+
+int
+keep_ok(fnode)
+ filenode *fnode;
+{
+ strnodelist *s;
+ strnodelist *k;
+
+ for (s = keep_list; s; s = s->next)
+ for (k = fnode->keyword_list; k; k = k->next)
+ if (strcmp(k->s, s->s) == 0)
+ return (1);
+
+ /* an empty keep_list means every one */
+ return (!keep_list);
+}
+
+/*
+ * given a filenode, we ensure we are not a cyclic graph. if this
+ * is ok, we loop over the filenodes requirements, calling satisfy_req()
+ * for each of them.. once we have done this, remove this filenode
+ * from each provision table, as we are now done.
+ */
+void
+do_file(fnode)
+ filenode *fnode;
+{
+ f_reqnode *r, *r_tmp;
+ f_provnode *p, *p_tmp;
+ provnode *pnode;
+ int was_set;
+
+ DPRINTF((stderr, "do_file on %s.\n", fnode->filename));
+
+ /*
+ * if fnode is marked as in progress,
+ * print that fnode; is circularly depended upon and abort.
+ */
+ if (fnode->in_progress == SET) {
+ warnx("Circular dependency on file `%s'.",
+ fnode->filename);
+ was_set = exit_code = 1;
+ } else
+ was_set = 0;
+
+ /* mark fnode */
+ fnode->in_progress = SET;
+
+ /*
+ * for each requirement of fnode -> r
+ * satisfy_req(r, filename)
+ */
+ r = fnode->req_list;
+ while (r != NULL) {
+ r_tmp = r;
+ satisfy_req(r, fnode->filename);
+ r = r->next;
+ free(r_tmp);
+ }
+ fnode->req_list = NULL;
+
+ /*
+ * for each provision of fnode -> p
+ * remove fnode from provision list for p in hash table
+ */
+ p = fnode->prov_list;
+ while (p != NULL) {
+ p_tmp = p;
+ pnode = p->pnode;
+ if (pnode->next != NULL) {
+ pnode->next->last = pnode->last;
+ }
+ if (pnode->last != NULL) {
+ pnode->last->next = pnode->next;
+ }
+ free(pnode);
+ p = p->next;
+ free(p_tmp);
+ }
+ fnode->prov_list = NULL;
+
+ /* do_it(fnode) */
+ DPRINTF((stderr, "next do: "));
+
+ /* if we were already in progress, don't print again */
+ if (was_set == 0 && skip_ok(fnode) && keep_ok(fnode))
+ printf("%s\n", fnode->filename);
+
+ if (fnode->next != NULL) {
+ fnode->next->last = fnode->last;
+ }
+ if (fnode->last != NULL) {
+ fnode->last->next = fnode->next;
+ }
+
+ DPRINTF((stderr, "nuking %s\n", fnode->filename));
+ free(fnode->filename);
+ free(fnode);
+}
+
+void
+generate_ordering()
+{
+
+ /*
+ * while there remain undone files{f},
+ * pick an arbitrary f, and do_file(f)
+ * Note that the first file in the file list is perfectly
+ * arbitrary, and easy to find, so we use that.
+ */
+
+ /*
+ * N.B.: the file nodes "self delete" after they execute, so
+ * after each iteration of the loop, the head will be pointing
+ * to something totally different. The loop ends up being
+ * executed only once for every strongly connected set of
+ * nodes.
+ */
+ while (fn_head->next != NULL) {
+ DPRINTF((stderr, "generate on %s\n", fn_head->next->filename));
+ do_file(fn_head->next);
+ }
+}
diff --git a/sbin/rcorder/sprite.h b/sbin/rcorder/sprite.h
new file mode 100644
index 0000000..5e5d7f3
--- /dev/null
+++ b/sbin/rcorder/sprite.h
@@ -0,0 +1,113 @@
+/* $NetBSD: sprite.h,v 1.1 1999/11/23 05:28:22 mrg Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93
+ */
+
+/*
+ * sprite.h --
+ *
+ * Common constants and type declarations for Sprite.
+ */
+
+#ifndef _SPRITE
+#define _SPRITE
+
+
+/*
+ * A boolean type is defined as an integer, not an enum. This allows a
+ * boolean argument to be an expression that isn't strictly 0 or 1 valued.
+ */
+
+typedef int Boolean;
+#ifndef TRUE
+#define TRUE 1
+#endif /* TRUE */
+#ifndef FALSE
+#define FALSE 0
+#endif /* FALSE */
+
+/*
+ * Functions that must return a status can return a ReturnStatus to
+ * indicate success or type of failure.
+ */
+
+typedef int ReturnStatus;
+
+/*
+ * The following statuses overlap with the first 2 generic statuses
+ * defined in status.h:
+ *
+ * SUCCESS There was no error.
+ * FAILURE There was a general error.
+ */
+
+#define SUCCESS 0x00000000
+#define FAILURE 0x00000001
+
+
+/*
+ * A nil pointer must be something that will cause an exception if
+ * referenced. There are two nils: the kernels nil and the nil used
+ * by user processes.
+ */
+
+#define NIL ~0
+#define USER_NIL 0
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+/*
+ * An address is just a pointer in C. It is defined as a character pointer
+ * so that address arithmetic will work properly, a byte at a time.
+ */
+
+typedef char *Address;
+
+/*
+ * ClientData is an uninterpreted word. It is defined as an int so that
+ * kdbx will not interpret client data as a string. Unlike an "Address",
+ * client data will generally not be used in arithmetic.
+ * But we don't have kdbx anymore so we define it as void (christos)
+ */
+
+typedef void *ClientData;
+
+#endif /* _SPRITE */
OpenPOWER on IntegriCloud