diff options
author | gordon <gordon@FreeBSD.org> | 2002-07-18 05:00:17 +0000 |
---|---|---|
committer | gordon <gordon@FreeBSD.org> | 2002-07-18 05:00:17 +0000 |
commit | 259601fa05ee9132dd014304b820ec38b47a67e4 (patch) | |
tree | 375610a72b2ea83aa73c7881302e5615e9cb7552 /etc/network.subr | |
parent | c8703a911ad83b0f513197689a88ec949871f7ea (diff) | |
download | FreeBSD-src-259601fa05ee9132dd014304b820ec38b47a67e4.zip FreeBSD-src-259601fa05ee9132dd014304b820ec38b47a67e4.tar.gz |
Merge in all the changes that Mike Makonnen has been maintaining for a
while. This is only the script pieces, the glue for the build comes next.
Submitted by: Mike Makonnen <makonnen@pacbell.net>
Reviewed by: silence on -current and -hackers
Prodded by: rwatson
Diffstat (limited to 'etc/network.subr')
-rw-r--r-- | etc/network.subr | 1023 |
1 files changed, 196 insertions, 827 deletions
diff --git a/etc/network.subr b/etc/network.subr index febaf83..b2c3ddb 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -1,42 +1,71 @@ -#!/bin/sh - -# -# Copyright (c) 1993 The FreeBSD Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +#!/bin/sh -x # # $FreeBSD$ -# From: @(#)netstart 5.9 (Berkeley) 3/30/91 # -# Note that almost all of the user-configurable behavior is no longer in -# this file, but rather in /etc/defaults/rc.conf. Please check that file -# first before contemplating any changes here. If you do need to change -# this file for some reason, we would like to know about it. +# PROVIDE: network1 +# REQUIRE: atm1 ipfilter mountcritlocal pccard serial sppp sysctl tty +# KEYWORD: FreeBSD -# First pass startup stuff. -# -network_pass1() { - echo -n 'Doing initial network setup:' +. /etc/rc.subr + +name="network1" +start_cmd="network_start" +stop_cmd="network_stop" + +convert_host_conf() +{ + host_conf=$1; shift; + nsswitch_conf=$1; shift; + awk ' \ + /^[:blank:]*#/ { next } \ + /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next } \ + /(dns|bind)/ { nsswitch[c] = "dns"; c++; next } \ + /nis/ { nsswitch[c] = "nis"; c++; next } \ + { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" } \ + END { \ + printf "hosts: "; \ + for (i in nsswitch) printf "%s ", nsswitch[i]; \ + printf "\n"; \ + }' < $host_conf > $nsswitch_conf +} + +generate_host_conf() +{ + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; + cont = 0; +} +sub(/^[\t ]*hosts:/, "") || cont { + if (!cont) + srcs = "" + sub(/#.*/, "") + gsub(/[][]/, " & ") + cont = sub(/\\$/, "") + srcs = srcs " " $0 +} +END { + print "# Auto-generated from nsswitch.conf, do not edit" + ns = split(srcs, s) + for (n = 1; n <= ns; ++n) { + if (s[n] in xlat) + print xlat[s[n]] + } +} +' <$nsswitch_conf >$host_conf +} + +network_start() +{ + # set hostname, turn on network + # + echo -n "Doing initial network setup:" # Generate host.conf for compatibility # @@ -61,131 +90,18 @@ network_pass1() { echo -n ' hostname' fi - # Establish ipfilter ruleset as early as possible (best in - # addition to IPFILTER_DEFAULT_BLOCK in the kernel config file) - - # check whether ipfilter and/or ipnat is enabled - ipfilter_active="NO" - case ${ipfilter_enable} in - [Yy][Ee][Ss]) - ipfilter_active="YES" - ;; - esac - case ${ipnat_enable} in - [Yy][Ee][Ss]) - ipfilter_active="YES" - ;; - esac - case ${ipfilter_active} in - [Yy][Ee][Ss]) - # load ipfilter kernel module if needed - if ! sysctl net.inet.ipf.fr_pass > /dev/null 2>&1; then - if kldload ipl; then - echo 'IP-filter module loaded.' - else - echo 'Warning: IP-filter module failed to load.' - # avoid further errors - ipfilter_active="NO" - ipmon_enable="NO" - ipfilter_enable="NO" - ipnat_enable="NO" - ipfs_enable="NO" - fi - fi - # start ipmon before loading any rules - case "${ipmon_enable}" in - [Yy][Ee][Ss]) - echo -n ' ipmon' - ${ipmon_program:-/sbin/ipmon} ${ipmon_flags} - ;; - esac - case "${ipfilter_enable}" in - [Yy][Ee][Ss]) - if [ -r "${ipfilter_rules}" ]; then - echo -n ' ipfilter' - ${ipfilter_program:-/sbin/ipf} -Fa -f \ - "${ipfilter_rules}" ${ipfilter_flags} - else - ipfilter_enable="NO" - echo -n ' NO IPF RULES' - fi - ;; - esac - case "${ipnat_enable}" in - [Yy][Ee][Ss]) - if [ -r "${ipnat_rules}" ]; then - echo -n ' ipnat' - eval ${ipnat_program:-/sbin/ipnat} -CF -f \ - "${ipnat_rules}" ${ipnat_flags} - else - ipnat_enable="NO" - echo -n ' NO IPNAT RULES' - fi - ;; - esac - # restore filter/NAT state tables after loading the rules - case "${ipfs_enable}" in - [Yy][Ee][Ss]) - if [ -r "/var/db/ipf/ipstate.ipf" ]; then - echo -n ' ipfs' - ${ipfs_program:-/sbin/ipfs} -R ${ipfs_flags} - # remove files to avoid reloading old state - # after an ungraceful shutdown - rm -f /var/db/ipf/ipstate.ipf - rm -f /var/db/ipf/ipnat.ipf - fi - ;; - esac - ;; - esac - # Set the domainname if we're using NIS # - case ${nisdomainname} in - [Nn][Oo] | '') - ;; - *) + if checkyesno nisdomainname ; then domainname ${nisdomainname} echo -n ' domain' - ;; - esac - - echo '.' - - # Initial ATM interface configuration - # - case ${atm_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/rc.atm ]; then - . /etc/rc.atm - atm_pass1 - fi - ;; - esac + fi # Attempt to create cloned interfaces. for ifn in ${cloned_interfaces}; do ifconfig ${ifn} create done - # Special options for sppp(4) interfaces go here. These need - # to go _before_ the general ifconfig section, since in the case - # of hardwired (no link1 flag) but required authentication, you - # cannot pass auth parameters down to the already running interface. - # - for ifn in ${sppp_interfaces}; do - eval spppcontrol_args=\$spppconfig_${ifn} - if [ -n "${spppcontrol_args}" ]; then - # The auth secrets might contain spaces; in order - # to retain the quotation, we need to eval them - # here. - eval spppcontrol ${ifn} ${spppcontrol_args} - fi - done - - # gifconfig - network_gif_setup - # Set up all the network interfaces, calling startup scripts if needed # case ${network_interfaces} in @@ -224,8 +140,7 @@ network_pass1() { done if [ ! -z "${dhcp_interfaces}" ]; then - ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces} - fi + ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces} fi for ifn in ${network_interfaces}; do # Check to see if aliases need to be added @@ -251,6 +166,7 @@ network_pass1() { fi done + # catch-all for interfaces that haven't been 'ifconfig'ed so far for ifn in ${network_interfaces}; do eval showstat=\$showstat_${ifn} if [ ! -z ${showstat} ]; then @@ -258,712 +174,165 @@ network_pass1() { fi done - # ISDN subsystem startup - # - case ${isdn_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/rc.isdn ]; then - . /etc/rc.isdn - fi - ;; - esac + - # Start user ppp if required. This must happen before natd. + # Check $defaultroute, then /etc/mygate, for the name of my gateway + # host. That name must be in /etc/hosts. # - case ${ppp_enable} in - [Yy][Ee][Ss]) - # Establish ppp mode. - # - if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ - -a "${ppp_mode}" != "dedicated" \ - -a "${ppp_mode}" != "background" ]; then - ppp_mode="auto" - fi - - ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}" - - # Switch on NAT mode? - # - case ${ppp_nat} in - [Yy][Ee][Ss]) - ppp_command="${ppp_command} -nat" - ;; - esac - - ppp_command="${ppp_command} ${ppp_profile}" - - echo "Starting ppp as \"${ppp_user}\"" - su -m ${ppp_user} -c "exec ${ppp_command}" - ;; - esac + if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then + defaultroute=`cat /etc/mygate` + fi + if [ -n "$defaultroute" ]; then + route add default $defaultroute + fi - # Re-Sync ipfilter so it picks up any new network interfaces + # 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. # - case ${ipfilter_active} in - [Yy][Ee][Ss]) - ${ipfilter_program:-/sbin/ipf} -y ${ipfilter_flags} >/dev/null - ;; - esac - unset ipfilter_active - - # Initialize IP filtering using ipfw + # Note that $ifaliases_xxN works only with certain configurations and + # considered not recommended. Use /etc/ifconfig.xxN if possible. + # # - if /sbin/ipfw -q flush > /dev/null 2>&1; then - firewall_in_kernel=1 - else - firewall_in_kernel=0 + if [ -n "$configured_interfaces" ]; then + echo "Adding interface aliases:" + done_aliases_message=yes fi - - case ${firewall_enable} in - [Yy][Ee][Ss]) - if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then - firewall_in_kernel=1 - echo 'Kernel firewall module loaded' - elif [ "${firewall_in_kernel}" -eq 0 ]; then - echo 'Warning: firewall kernel module failed to load' + 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 - ;; - esac + done - # Load the filters if required + # /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 # - case ${firewall_in_kernel} in - 1) - if [ -z "${firewall_script}" ]; then - firewall_script=/etc/rc.firewall + # 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 - - case ${firewall_enable} in - [Yy][Ee][Ss]) - if [ -r "${firewall_script}" ]; then - . "${firewall_script}" - echo -n 'Firewall rules loaded, starting divert daemons:' - - # Network Address Translation daemon - # - case ${natd_enable} in - [Yy][Ee][Ss]) - if [ -n "${natd_interface}" ]; then - if echo ${natd_interface} | \ - grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then - natd_flags="$natd_flags -a ${natd_interface}" - else - natd_flags="$natd_flags -n ${natd_interface}" - fi - fi - echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} - ;; - esac - - echo '.' - - elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then - echo 'Warning: kernel has firewall functionality,' \ - 'but firewall rules are not enabled.' - echo ' All ip services are disabled.' + 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 - - case ${firewall_logging} in - [Yy][Ee][Ss] | '') - echo 'Firewall logging=YES' - sysctl net.inet.ip.fw.verbose=1 >/dev/null - ;; - *) - ;; - esac - - ;; - esac - ;; - esac - - # Additional ATM interface configuration - # - if [ -n "${atm_pass1_done}" ]; then - atm_pass2 + # use loopback, not the wire + route add $addr 127.0.0.1 + done < /etc/ifaliases fi - # Configure routing - # - case ${defaultrouter} in - [Nn][Oo] | '') - ;; - *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" - ;; - esac - - # Set up any static routes. This should be done before router discovery. + # IPv6 interface autoconfiguration. # - if [ -n "${static_routes}" ]; then - for i in ${static_routes}; do - eval route_args=\$route_${i} - route add ${route_args} - done - fi - - echo -n 'Additional routing options:' - case ${tcp_extensions} in - [Yy][Ee][Ss] | '') - ;; - *) - echo -n ' tcp extensions=NO' - sysctl net.inet.tcp.rfc1323=0 >/dev/null - ;; - esac - - case ${icmp_bmcastecho} in - [Yy][Ee][Ss]) - echo -n ' broadcast ping responses=YES' - sysctl net.inet.icmp.bmcastecho=1 >/dev/null - ;; - esac - - case ${icmp_drop_redirect} in - [Yy][Ee][Ss]) - echo -n ' ignore ICMP redirect=YES' - sysctl net.inet.icmp.drop_redirect=1 >/dev/null - ;; - esac - - case ${icmp_log_redirect} in - [Yy][Ee][Ss]) - echo -n ' log ICMP redirect=YES' - sysctl net.inet.icmp.log_redirect=1 >/dev/null - ;; - esac - - case ${gateway_enable} in - [Yy][Ee][Ss]) - echo -n ' IP gateway=YES' - sysctl net.inet.ip.forwarding=1 >/dev/null - ;; - esac - - case ${forward_sourceroute} in - [Yy][Ee][Ss]) - echo -n ' do source routing=YES' - sysctl net.inet.ip.sourceroute=1 >/dev/null - ;; - esac - - case ${accept_sourceroute} in - [Yy][Ee][Ss]) - echo -n ' accept source routing=YES' - sysctl net.inet.ip.accept_sourceroute=1 >/dev/null - ;; - esac - - case ${tcp_keepalive} in - [Nn][Oo]) - echo -n ' TCP keepalive=NO' - sysctl net.inet.tcp.always_keepalive=0 >/dev/null - ;; - esac - - case ${tcp_drop_synfin} in - [Yy][Ee][Ss]) - echo -n ' drop SYN+FIN packets=YES' - sysctl net.inet.tcp.drop_synfin=1 >/dev/null - ;; - esac - - case ${ipxgateway_enable} in - [Yy][Ee][Ss]) - echo -n ' IPX gateway=YES' - sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null - ;; - esac - - case ${arpproxy_all} in - [Yy][Ee][Ss]) - echo -n ' ARP proxyall=YES' - sysctl net.link.ether.inet.proxyall=1 >/dev/null - ;; - esac - - case ${ip_portrange_first} in - [Nn][Oo] | '') - ;; - *) - echo -n " ip_portrange_first=$ip_portrange_first" - sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null - ;; - esac - - case ${ip_portrange_last} in - [Nn][Oo] | '') - ;; - *) - echo -n " ip_portrange_last=$ip_portrange_last" - sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null - ;; - esac - - echo '.' + 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 - case ${ipsec_enable} in - [Yy][Ee][Ss]) - if [ -f ${ipsec_file} ]; then - echo ' ipsec: enabled' - setkey -f ${ipsec_file} - else - echo ' ipsec: file not found' + # wait till DAD is completed, for global addresses + # configured by router advert message. + # + sleep $dadcount + sleep 1 fi - ;; - esac - - echo -n 'Routing daemons:' - case ${router_enable} in - [Yy][Ee][Ss]) - echo -n " ${router}"; ${router} ${router_flags} - ;; - esac - - case ${ipxrouted_enable} in - [Yy][Ee][Ss]) - echo -n ' IPXrouted' - IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 - ;; - esac - - case ${mrouted_enable} in - [Yy][Ee][Ss]) - echo -n ' mrouted'; mrouted ${mrouted_flags} - ;; - esac + fi - case ${rarpd_enable} in - [Yy][Ee][Ss]) - echo -n ' rarpd'; rarpd ${rarpd_flags} - ;; - esac + # XXX this must die + if [ -s /etc/netstart.local ]; then + sh /etc/netstart.local start + fi + fi echo '.' - # Let future generations know we made it. - # - network_pass1_done=YES + # Resync ipfilter + /etc/rc.d/ipfilter resync } -network_pass2() { - echo -n 'Doing additional network setup:' - case ${named_enable} in - [Yy][Ee][Ss]) - echo -n ' named'; ${named_program:-named} ${named_flags} - ;; - esac - - case ${ntpdate_enable} in - [Yy][Ee][Ss]) - echo -n ' ntpdate' - ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1 - ;; - esac - - case ${xntpd_enable} in - [Yy][Ee][Ss]) - echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags} - ;; - esac - - case ${timed_enable} in - [Yy][Ee][Ss]) - echo -n ' timed'; timed ${timed_flags} - ;; - esac - - case ${portmap_enable} in - [Yy][Ee][Ss]) - echo -n ' rpcbind'; ${portmap_program:-/usr/sbin/rpcbind} \ - ${portmap_flags} +network_stop() +{ + echo "Stopping network." - # Start ypserv if we're an NIS server. - # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. - # - case ${nis_server_enable} in - [Yy][Ee][Ss]) - echo -n ' ypserv'; ypserv ${nis_server_flags} - - case ${nis_ypxfrd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.ypxfrd' - rpc.ypxfrd ${nis_ypxfrd_flags} - ;; - esac - - case ${nis_yppasswdd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.yppasswdd' - rpc.yppasswdd ${nis_yppasswdd_flags} - ;; - esac - ;; - esac - - # Start ypbind if we're an NIS client - # - case ${nis_client_enable} in - [Yy][Ee][Ss]) - echo -n ' ypbind'; ypbind ${nis_client_flags} - case ${nis_ypset_enable} in - [Yy][Ee][Ss]) - echo -n ' ypset'; ypset ${nis_ypset_flags} - ;; - esac - ;; - esac - - # Start keyserv if we are running Secure RPC - # - case ${keyserv_enable} in - [Yy][Ee][Ss]) - echo -n ' keyserv'; keyserv ${keyserv_flags} - ;; - esac - - # Start ypupdated if we are running Secure RPC - # and we are NIS master - # - case ${rpc_ypupdated_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.ypupdated'; rpc.ypupdated - ;; - esac - ;; - esac - - # Start ATM daemons - if [ -n "${atm_pass2_done}" ]; then - atm_pass3 + # XXX this must die + if [ -s /etc/netstart.local ]; then + sh /etc/netstart.local stop fi - echo '.' - network_pass2_done=YES -} - -network_pass3() { - echo -n 'Starting final network daemons:' - - case ${portmap_enable} in - [Yy][Ee][Ss]) - case ${nfs_server_enable} in - [Yy][Ee][Ss]) - # Handle absent nfs server support - nfsserver_in_kernel=0 - if sysctl vfs.nfsrv >/dev/null 2>&1; then - nfsserver_in_kernel=1 - else - kldload nfsserver && nfsserver_in_kernel=1 - fi - - if [ -r /etc/exports -a \ - ${nfsserver_in_kernel} -eq 1 ]; then - echo -n ' mountd' - - case ${weak_mountd_authentication} in - [Yy][Ee][Ss]) - mountd_flags="${mountd_flags} -n" - ;; - esac - - mountd ${mountd_flags} - - case ${nfs_reserved_port_only} in - [Yy][Ee][Ss]) - echo -n ' NFS on reserved port only=YES' - sysctl vfs.nfsrv.nfs_privport=1 > /dev/null - ;; - esac - - echo -n ' nfsd'; nfsd ${nfs_server_flags} - - case ${rpc_statd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.statd'; rpc.statd - ;; - esac - - case ${rpc_lockd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.lockd'; rpc.lockd - ;; - esac - else - echo -n ' Warning: nfs server failed' - fi - ;; - *) - case ${single_mountd_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/exports ]; then - echo -n ' mountd' - - case ${weak_mountd_authentication} in - [Yy][Ee][Ss]) - mountd_flags="-n" - ;; - esac - - mountd ${mountd_flags} - fi - ;; - esac - ;; - esac - - case ${nfs_client_enable} in - [Yy][Ee][Ss]) - nfsclient_in_kernel=0 - # Handle absent nfs client support - if sysctl vfs.nfs >/dev/null 2>&1; then - nfsclient_in_kernel=1 - else - kldload nfsclient && nfsclient_in_kernel=1 - fi - - if [ ${nfsclient_in_kernel} -eq 1 ] - then - if [ -n "${nfs_access_cache}" ]; then - echo -n " NFS access cache time=${nfs_access_cache}" - sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null - fi - if [ -n "${nfs_bufpackets}" ]; then - sysctl vfs.nfs.bufpackets=${nfs_bufpackets} > /dev/null - fi - case ${rpc_statd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.statd'; rpc.statd - ;; - esac - - case ${rpc_lockd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.lockd'; rpc.lockd - ;; - esac - - case ${amd_enable} in - [Yy][Ee][Ss]) - echo -n ' amd' - case ${amd_map_program} in - [Nn][Oo] | '') - ;; - *) - amd_flags="${amd_flags} `eval\ - ${amd_map_program}`" - ;; - esac - - case "${amd_flags}" in - '') - if [ -r /etc/amd.conf ]; then - amd & - else - echo '' - echo 'Warning: amd will not load without arguments' - fi - ;; - *) - amd -p ${amd_flags} \ - >/var/run/amd.pid \ - 2>/dev/null & - ;; - esac - ;; - esac - else - echo 'Warning: NFS client kernel module failed to load' - nfs_client_enable=NO - fi - ;; - esac + echo "Deleting aliases." + if [ -f /etc/ifaliases ]; then + while read addr int net; do + ifconfig $int inet delete $addr + done < /etc/ifaliases + fi - # If /var/db/mounttab exists, some nfs-server has not been - # successfully notified about a previous client shutdown. - # If there is no /var/db/mounttab, we do nothing. - if [ -f /var/db/mounttab ]; then - rpc.umntall -k + 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 - ;; - esac - - case ${rwhod_enable} in - [Yy][Ee][Ss]) - echo -n ' rwhod'; rwhod ${rwhod_flags} - ;; - esac - - # Kerberos servers run ONLY on the Kerberos server machine - case ${kerberos4_server_enable} in - [Yy][Ee][Ss]) - case ${kerberos_stash} in - [Yy][Ee][Ss]) - stash=-n - ;; - *) - stash= - ;; - esac - - echo -n ' kerberosIV' - ${kerberos4_server} ${stash} >> /var/log/kerberos.log & - - case ${kadmind4_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kadmindIV' - ( - sleep 20; - ${kadmind4_server} ${stash} >/dev/null 2>&1 & - ) & - ;; - esac - unset stash_flag - ;; - esac - - case ${kerberos5_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kerberos5' - ${kerberos5_server} & - - case ${kadmind5_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kadmind5' - ${kadmind5_server} & - ;; - esac - ;; - esac - - case ${pppoed_enable} in - [Yy][Ee][Ss]) - if [ -n "${pppoed_provider}" ]; then - pppoed_flags="${pppoed_flags} -p ${pppoed_provider}" + # 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 - echo -n ' pppoed'; - _opts=$-; set -f - /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface} - set +f; set -${_opts} - ;; - esac - - case ${sshd_enable} in - [Yy][Ee][Ss]) - if [ -x /usr/bin/ssh-keygen ]; then - if [ ! -f /etc/ssh/ssh_host_key ]; then - echo ' creating ssh1 RSA host key'; - /usr/bin/ssh-keygen -t rsa1 -N "" \ - -f /etc/ssh/ssh_host_key + for int in $tmp; do + eval args=\$ifconfig_$int + if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then + echo -n " $int" + ifconfig $int down fi - if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then - echo ' creating ssh2 RSA host key'; - /usr/bin/ssh-keygen -t rsa -N "" \ - -f /etc/ssh/ssh_host_rsa_key - fi - if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then - echo ' creating ssh2 DSA host key'; - /usr/bin/ssh-keygen -t dsa -N "" \ - -f /etc/ssh/ssh_host_dsa_key - fi - fi - ;; - esac - - echo '.' - network_pass3_done=YES -} - -network_pass4() { - echo -n 'Additional TCP options:' - case ${log_in_vain} in - [Nn][Oo] | '') - log_in_vain=0 - ;; - [Yy][Ee][Ss]) - log_in_vain=1 - ;; - [0-9]*) - ;; - *) - echo " invalid log_in_vain setting: ${log_in_vain}" - log_in_vain=0 - ;; - esac - - [ "${log_in_vain}" -ne 0 ] && ( - echo -n " log_in_vain=${log_in_vain}" - sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null - sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null - ) - echo '.' - network_pass4_done=YES -} - -network_gif_setup() { - case ${gif_interfaces} in - [Nn][Oo] | '') - ;; - *) - for i in ${gif_interfaces}; do - eval peers=\$gifconfig_$i - case ${peers} in - '') - continue - ;; - *) - ifconfig $i create >/dev/null 2>&1 - ifconfig $i tunnel ${peers} - ;; - esac done - ;; - esac -} + echo "." + fi -convert_host_conf() { - host_conf=$1; shift; - nsswitch_conf=$1; shift; - awk ' \ - /^[:blank:]*#/ { next } \ - /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next } \ - /(dns|bind)/ { nsswitch[c] = "dns"; c++; next } \ - /nis/ { nsswitch[c] = "nis"; c++; next } \ - { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" } \ - END { \ - printf "hosts: "; \ - for (i in nsswitch) printf "%s ", nsswitch[i]; \ - printf "\n"; \ - }' < $host_conf > $nsswitch_conf -} + # flush routes + # + route -n flush -generate_host_conf() { - nsswitch_conf=$1; shift; - host_conf=$1; shift; - - awk ' -BEGIN { - xlat["files"] = "hosts"; - xlat["dns"] = "bind"; - xlat["nis"] = "nis"; - cont = 0; -} -sub(/^[\t ]*hosts:/, "") || cont { - if (!cont) - srcs = "" - sub(/#.*/, "") - gsub(/[][]/, " & ") - cont = sub(/\\$/, "") - srcs = srcs " " $0 -} -END { - print "# Auto-generated from nsswitch.conf, do not edit" - ns = split(srcs, s) - for (n = 1; n <= ns; ++n) { - if (s[n] in xlat) - print xlat[s[n]] - } -} -' <$nsswitch_conf >$host_conf } + +load_rc_config $name +run_rc_command "$1" |