8273327
#!/bin/bash
fb0a2d0
#
fb0a2d0
# dhclient-script: Network interface configuration script run by
fb0a2d0
#                  dhclient based on DHCP client communication
fb0a2d0
#
fb0a2d0
# Copyright (C) 2008 Red Hat, Inc.
fb0a2d0
#
fb0a2d0
# This program is free software; you can redistribute it and/or modify
fb0a2d0
# it under the terms of the GNU General Public License as published by
fb0a2d0
# the Free Software Foundation; either version 2 of the License, or
fb0a2d0
# (at your option) any later version.
fb0a2d0
#
fb0a2d0
# This program is distributed in the hope that it will be useful,
fb0a2d0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
fb0a2d0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fb0a2d0
# GNU General Public License for more details.
fb0a2d0
#
fb0a2d0
# You should have received a copy of the GNU General Public License
fb0a2d0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
fb0a2d0
#
fb0a2d0
# Author(s): David Cantrell <dcantrell@redhat.com>
fb0a2d0
#
fb0a2d0
# ----------
fb0a2d0
# This script is a rewrite/reworking on dhclient-script originally
fb0a2d0
# included as part of dhcp-970306:
8273327
# dhclient-script for Linux. Dan Halbert, March, 1997.
8273327
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
8273327
# Modified by David Cantrell <dcantrell@redhat.com> for Fedora and RHEL
fb0a2d0
# ----------
fb0a2d0
#
8273327
fb0a2d0
PATH=/bin:/usr/bin:/sbin
fb0a2d0
SAVEDIR=/var/lib/dhclient
8273327
fb0a2d0
LOGFACILITY="local7"
fb0a2d0
LOGLEVEL="notice"
8273327
fb0a2d0
logmessage() {
fb0a2d0
    msg="${1}"
fb0a2d0
    logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
fb0a2d0
}
8273327
fb0a2d0
save_previous() {
fb0a2d0
    origfile="${1}"
fb0a2d0
    savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}"
8273327
fb0a2d0
    if [ ! -d ${SAVEDIR} ]; then
fb0a2d0
        mkdir -p ${SAVEDIR}
fb0a2d0
    fi
8273327
fb0a2d0
    if [ -e ${origfile} ]; then
fb0a2d0
        mv ${origfile} ${savefile}
8273327
    else
fb0a2d0
        echo > ${savefile}
8273327
    fi
7a4b490
fb0a2d0
    restorecon ${savefile} >/dev/null 2>&1
8273327
}
8273327
8273327
make_resolv_conf() {
fb0a2d0
    [ "${PEERDNS}" = "no" ] && return
8273327
fb0a2d0
    if [ "${reason}" = "RENEW" ] &&
fb0a2d0
       [ "${new_domain_name}" = "${old_domain_name}" ] &&
fb0a2d0
       [ "${new_domain_name_servers}" = "${old_domain_name_servers}" ]; then
8273327
        return
8273327
    fi
8273327
fb0a2d0
    if [ -n "${new_domain_name}" ] ||
fb0a2d0
       [ -n "${new_domain_name_servers}" ] ||
fb0a2d0
       [ -n "${new_domain_search}" ]; then
7a4b490
        save_previous /etc/resolv.conf
fb0a2d0
        rscf="$(mktemp /tmp/XXXXXX)"
fb0a2d0
        echo "; generated by /sbin/dhclient-script" > ${rscf}
8273327
fb0a2d0
        if [ -n "${SEARCH}" ]; then
fb0a2d0
            echo "search ${SEARCH}" >> $rscf
7a4b490
        else
fb0a2d0
            if [ -n "${new_domain_search}" ]; then
fb0a2d0
                echo "search ${new_domain_search//\\032/ }" >> ${rscf}
fb0a2d0
            elif [ -n "${new_domain_name}" ]; then
fb0a2d0
                echo "search ${new_domain_name//\\032/ }" >> ${rscf}
8273327
            fi
8273327
        fi
8273327
fb0a2d0
        if [ -n "${RES_OPTIONS}" ]; then
fb0a2d0
            echo "options ${RES_OPTIONS}" >> ${rscf}
5d1db19
        fi
5d1db19
fb0a2d0
        for nameserver in ${new_domain_name_servers} ; do
fb0a2d0
            echo "nameserver ${nameserver}" >> ${rscf}
8273327
        done
8273327
fb0a2d0
        change_resolv_conf ${rscf}
fb0a2d0
        rm -f ${rscf}
8273327
    fi
8273327
}
8273327
8273327
exit_with_hooks() {
fb0a2d0
    exit_status="${1}"
8273327
fb0a2d0
    if [ -x /etc/dhclient-exit-hooks ]; then
8273327
        . /etc/dhclient-exit-hooks
8273327
    fi
8273327
fb0a2d0
    exit ${exit_status}
8273327
}
8273327
fb0a2d0
quad2num() {
8273327
    if [ $# -eq 4 ]; then
fb0a2d0
        let n="${1} << 24 | ${2} << 16 | ${3} << 8 | ${4}"
fb0a2d0
        echo "${n}"
8273327
        return 0
fb0a2d0
    else
fb0a2d0
        echo "0"
fb0a2d0
        return 1
8273327
    fi
8273327
}
8273327
fb0a2d0
ip2num() {
fb0a2d0
    IFS="." quad2num ${1}
8273327
}
8273327
fb0a2d0
num2ip() {
fb0a2d0
    let n="${1}"
fb0a2d0
    let o1="(n >> 24) & 0xff"
fb0a2d0
    let o2="(n >> 16) & 0xff"
fb0a2d0
    let o3="(n >> 8) & 0xff"
fb0a2d0
    let o4="n & 0xff"
fb0a2d0
    echo "${o1}.${o2}.${o3}.${o4}"
8273327
}
8273327
fb0a2d0
mask() {
fb0a2d0
    ip="${1}"
fb0a2d0
    m="${2}"
fb0a2d0
    let ip="$(IFS="." ip2num ${ip})"
fb0a2d0
    let m="$(IFS="." ip2num ${m})"
fb0a2d0
    let n="ip & m"
fb0a2d0
    num2ip ${n}
8273327
}
8273327
fb0a2d0
class_bits() {
8273327
    let ip=$(IFS='.' ip2num $1)
8273327
    let bits=32
8273327
    let mask='255'
8273327
    for ((i=0; i <= 3; i++, 'mask<<=8')); do
8273327
        let v='ip&mask'
8273327
        if [ "$v" -eq 0 ] ; then
8273327
             let bits-=8
8273327
        else
8273327
             break
8273327
        fi
8273327
    done
8273327
    echo $bits
8273327
}
8273327
fb0a2d0
is_router_reachable() {
fb0a2d0
    # handle DHCP servers that give us a router not on our subnet
fb0a2d0
    router="${1}"
fb0a2d0
    routersubnet="$(mask ${router} ${new_subnet_mask})"
fb0a2d0
    mysubnet="$(mask ${new_ip_address} ${new_subnet_mask})"
8273327
    unreachable=0
fb0a2d0
fb0a2d0
    if [ ! "${routersubnet}" = "${mysubnet}" ]; then
8273327
        unreachable=1
fb0a2d0
        if arping -f -q -I ${interface} -w2 ${router}; then
fb0a2d0
            ip route add ${router}/32 dev ${interface}
fb0a2d0
            if [ $? -eq 0 ]; then
fb0a2d0
                unreachable=0
fb0a2d0
            else
fb0a2d0
                logmessage "failed to create host router for unreachable router ${router} not on subnet ${mysubnet}"
fb0a2d0
            fi
8273327
        else
fb0a2d0
            unreachable=1
fb0a2d0
            logmessage "DHCP router ${router} is unreachable on DHCP subnet ${mysubnet} router subnet ${routersubnet}"
8273327
        fi
8273327
    fi
fb0a2d0
fb0a2d0
    return ${unreachable}
8273327
}
8273327
fb0a2d0
add_default_gateway() {
fb0a2d0
    router="${1}"
fb0a2d0
    metric=""
fb0a2d0
3eef636
    if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
fb0a2d0
        metric="metric ${2}"
8273327
    fi
fb0a2d0
fb0a2d0
    if is_router_reachable ${router} ; then
fb0a2d0
        ip route replace default via ${router} dev ${interface} ${metric}
8273327
        if [ $? -ne 0 ]; then
fb0a2d0
            logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
8273327
            return 1
8273327
        else
8273327
            return 0
8273327
        fi
8273327
    fi
fb0a2d0
8273327
    return 1
8273327
}
8273327
fb0a2d0
dhconfig() {
fb0a2d0
    if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
fb0a2d0
       [ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
fb0a2d0
        # possible new alias, remove old alias first
fb0a2d0
        ip -family inet addr del ${old_ip_address} dev ${interface}:0
8273327
    fi
8273327
fb0a2d0
    if [ -n "${old_ip_address}" ] &&
fb0a2d0
       [ ! "${old_ip_address}" = "${new_ip_address}" ]; then
fb0a2d0
        # IP address changed.  Bringing down the interface will delete all
8273327
        # routes, and clear the ARP cache.
fb0a2d0
        ip -family inet addr flush dev ${interface}
fb0a2d0
        ip -family inet link set dev ${interface} down
8273327
    fi
8273327
3eef636
    if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
fb0a2d0
       [ ! "${old_ip_address}" = "${new_ip_address}" ] ||
fb0a2d0
       [ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] ||
fb0a2d0
       [ ! "${old_network_number}" = "${new_network_number}" ] ||
fb0a2d0
       [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] ||
fb0a2d0
       [ ! "${old_routers}" = "${new_routers}" ] ||
fb0a2d0
       [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
fb0a2d0
        ip -family inet addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
fb0a2d0
fb0a2d0
        if [ -n "${new_interface_mtu}" ]; then
fb0a2d0
            ip link set ${interface} mtu ${new_interface_mtu}
8273327
        fi
8273327
8273327
        if [ -x /etc/dhclient-${interface}-up-hooks ]; then
8273327
            . /etc/dhclient-${interface}-up-hooks
8273327
        elif [ -x /etc/dhclient-up-hooks ]; then
8273327
            . /etc/dhclient-up-hooks
8273327
        fi
8273327
fb0a2d0
        if [[ (( -z "${GATEWAYDEV}" ) ||
fb0a2d0
               ( "${GATEWAYDEV}" = "${interface}" )) &&
fb0a2d0
              (( -z "$GATEWAY" ) ||
fb0a2d0
               (( -n "$DHCLIENT_IGNORE_GATEWAY" ) &&
fb0a2d0
                ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* ))) ]]; then
24398ee
            metric="${METRIC:-}"
fb0a2d0
            let i="${METRIC:-0}"
8273327
            default_routers=()
8273327
fb0a2d0
            for router in ${new_routers} ; do
fb0a2d0
                added_router=-
8273327
fb0a2d0
                for r in ${default_routers[@]} ; do
fb0a2d0
                    if [ "${r}" = "${router}" ]; then
8273327
                        added_router=1
8273327
                    fi
8273327
                done
8273327
fb0a2d0
                if [ -z "${router}" ] ||
fb0a2d0
                   [ "${added_router}" = "1" ] ||
fb0a2d0
                   [ $(IFS=. ip2num ${router}) -le 0 ] ||
fb0a2d0
                   [[ ( "${router}" = "${new_broadcast_address}" ) &&
fb0a2d0
                      ( "${new_subnet_mask}" != "255.255.255.255" ) ]]; then
8273327
                    continue
8273327
                fi
8273327
fb0a2d0
                default_routers=(${default_routers[@]} ${router})
fb0a2d0
                add_default_gateway ${router} ${metric}
8273327
                let i=i+1
fb0a2d0
                metric=${i}
8273327
            done
fb0a2d0
        elif [[ (( -z "${GATEWAYDEV}" ) ||
fb0a2d0
                 ( "${GATEWAYDEV}" = "${interface}" )) &&
fb0a2d0
                ( -n "${GATEWAY}" ) ]]; then
fb0a2d0
            routersubnet=$(mask ${GATEWAY} ${new_subnet_mask})
fb0a2d0
            mysubnet=$(mask ${new_ip_address} ${new_subnet_mask})
fb0a2d0
fb0a2d0
            if [ "${routersubnet}" = "${mysubnet}" ]; then
fb0a2d0
                ip route replace default via ${GATEWAY} dev ${interface}
8273327
            fi
8273327
        fi
8273327
8273327
        # static routes
fb0a2d0
        if [ -n "${new_static_routes}" ]; then
fb0a2d0
            IFS=', |' static_routes=(${new_static_routes})
8273327
            route_targets=()
8273327
8273327
            for((i=0; i<${#static_routes[@]}; i+=2)); do
8273327
                target=${static_routes[$i]}
8273327
                gateway=${static_routes[$i+1]}
8273327
                metric=''
8273327
8273327
                for t in ${route_targets[@]}; do
fb0a2d0
                    if [ ${t} = ${target} ]; then
fb0a2d0
                        if [ -z "${metric}" ]; then
8273327
                            metric=1
8273327
                        else
8273327
                            ((metric=metric+1))
8273327
                        fi
8273327
                    fi
8273327
                done
8273327
fb0a2d0
                if [ -n "${metric}" ]; then
fb0a2d0
                    metric="metric ${metric}"
8273327
                fi
8273327
fb0a2d0
                if is_router_reachable ${gateway}; then
fb0a2d0
                    ip route replace ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric}
8273327
8273327
                    if [ $? -ne 0 ]; then
fb0a2d0
                        logmessage "failed to create static route: ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric}"
8273327
                    else
fb0a2d0
                        route_targets=(${route_targets[@]} ${target})
8273327
                    fi
8273327
                fi
8273327
            done
8273327
        fi
8273327
    fi
8273327
fb0a2d0
    if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
fb0a2d0
       [ -n "${alias_ip_address}" ]; then
fb0a2d0
        ip -family inet addr flush dev ${interface}:0
fb0a2d0
        ip -family inet addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
fb0a2d0
        ip route replace ${alias_ip_address}/32 dev ${interface}:0
8273327
    fi
8273327
8273327
    make_resolv_conf
8273327
fb0a2d0
    if [ -n "${new_host_name}" ] && need_hostname; then
fb0a2d0
        hostname ${new_host_name}
8273327
    fi
8273327
fb0a2d0
    if [ ! "${PEERNIS}" = "no" ]; then
fb0a2d0
        if [ -n "${new_nis_domain}" ]; then
fb0a2d0
            domainname "${new_nis_domain}"
fb0a2d0
            save_previous /etc/yp.conf
fb0a2d0
            let contents=0
fb0a2d0
            echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
fb0a2d0
fb0a2d0
            if [ -n "${new_nis_servers}" ]; then
fb0a2d0
                for i in ${new_nis_servers} ; do
fb0a2d0
                    echo "domain ${new_nis_domain} server ${i}" >> /etc/yp.conf
fb0a2d0
                    let contents=contents+1
fb0a2d0
                done
fb0a2d0
            else
fb0a2d0
                echo "domain ${new_nis_domain} broadcast" >> /etc/yp.conf
8273327
                let contents=contents+1
fb0a2d0
            fi
8273327
fb0a2d0
            if [ ${contents} -gt 0 ]; then
fb0a2d0
                if [ -x /etc/rc.d/init.d/ypbind ] &&
fb0a2d0
                   [ -r /var/run/ypbind.pid ]; then
fb0a2d0
                    service ypbind restart >/dev/null 2>&1
fb0a2d0
                fi
4f14cb7
            fi
fb0a2d0
        elif [ -n "${new_nis_servers}" ]; then
fb0a2d0
            save_previous /etc/yp.conf
fb0a2d0
            echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
fb0a2d0
            let contents=0
fb0a2d0
fb0a2d0
            for i in ${new_nis_servers} ; do
fb0a2d0
                echo "ypserver ${i}" >> /etc/yp.conf
fb0a2d0
                let contents=contents+1
fb0a2d0
            done
8273327
fb0a2d0
            if [ $contents -gt 0 ]; then
fb0a2d0
                if [ -x /etc/rc.d/init.d/ypbind ] &&
fb0a2d0
                   [ -r /var/run/ypbind.pid ]; then
e9c8f22
                    service ypbind restart >/dev/null 2>&1
fb0a2d0
                fi
4f14cb7
            fi
8273327
        fi
8273327
    fi
8273327
fb0a2d0
    if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
fb0a2d0
       [[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
fb0a2d0
        if [ -n "${new_time_offset}" ]; then
8273327
            # DHCP option "time-offset" is requested by default and should be
8273327
            # handled.  The geographical zone abbreviation cannot be determined
8273327
            # from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
8273327
            # used - note: this disables DST.
8273327
            ((z=new_time_offset/3600))
8273327
            ((hoursWest=$(printf '%+d' $z)))
8273327
8273327
            if (( $hoursWest < 0 )); then
8273327
                # tzdata treats negative 'hours west' as positive 'gmtoff'!
8273327
                ((hoursWest*=-1))
8273327
            fi
8273327
fb0a2d0
            tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' ${hoursWest})
fb0a2d0
            if [ -e ${tzfile} ]; then
fb0a2d0
                save_previous /etc/localtime
fb0a2d0
                cp -fp ${tzfile} /etc/localtime
fb0a2d0
                touch /etc/localtime
8273327
            fi
8273327
        fi
8273327
    fi
8273327
fb0a2d0
    if [ ! "${PEERNTP}" = "no" ] &&
fb0a2d0
       [ -n "${new_ntp_servers}" ] && [ -e /etc/ntp.conf ]; then
8273327
        save_previous /etc/ntp.conf
fb0a2d0
        egrep -v '^server .*  # added by /sbin/dhclient-script$'< ${SAVEDIR}/ntp.conf.predhclient.${interface} > /etc/ntp.conf
fb0a2d0
        restorecon /etc/ntp.conf >/dev/null 2>&1
8273327
fb0a2d0
        for s in ${new_ntp_servers} ; do
fb0a2d0
            echo "server ${s}  # added by /sbin/dhclient-script" >> /etc/ntp.conf
8273327
        done
8273327
fb0a2d0
        diff -q /etc/ntp.conf ${SAVEDIR}/ntp.conf.predhclient.${interface} >/dev/null 2>&1
fb0a2d0
        if [ $? -eq 1 ]; then
fb0a2d0
            service ntpd condrestart >/dev/null 2>&1
8273327
        fi
8273327
    fi
8273327
}
8273327
8273327
fb0a2d0
#
fb0a2d0
# ### MAIN
fb0a2d0
#
8273327
fb0a2d0
if [ -x /etc/dhclient-enter-hooks ]; then
fb0a2d0
    exit_status=0
fb0a2d0
fb0a2d0
    # dhclient-enter-hooks can abort dhclient-script by setting
fb0a2d0
    # the exit_status variable to a non-zero value
fb0a2d0
    . /etc/dhclient-enter-hooks
fb0a2d0
    if [ ${exit_status} -ne 0 ]; then
fb0a2d0
        exit ${exit_status}
fb0a2d0
    fi
e618bc9
fi
fb0a2d0
fb0a2d0
if [ ! -r /etc/sysconfig/network-scripts/network-functions ]; then
fb0a2d0
    echo "Missing /etc/sysconfig/network-scripts/network-functions, exiting." >&2
fb0a2d0
    exit 1
8273327
fi
8273327
fb0a2d0
if [ ! -r /etc/rc.d/init.d/functions ]; then
fb0a2d0
    echo "Missing /etc/rc.d/init.d/functions, exiting." >&2
fb0a2d0
    exit 1
8273327
fi
8273327
fb0a2d0
. /etc/sysconfig/network-scripts/network-functions
fb0a2d0
. /etc/rc.d/init.d/functions
fb0a2d0
fb0a2d0
if [ -f /etc/sysconfig/network ]; then
fb0a2d0
    . /etc/sysconfig/network
8273327
fi
8273327
fb0a2d0
if [ -f /etc/sysconfig/networking/network ]; then
fb0a2d0
    . /etc/sysconfig/networking/network
8273327
fi
8273327
fb0a2d0
CONFIG="${interface}"
fb0a2d0
need_config ${CONFIG}
8273327
fb0a2d0
if [ -f "${CONFIG}" ]; then
fb0a2d0
    source_config
fb0a2d0
fi
8273327
fb0a2d0
if [ -n "${new_subnet_mask}" ]; then
fb0a2d0
    new_prefix="$(ipcalc -p ${new_ip_address} ${new_subnet_mask} | cut -d '=' -f 2)"
8273327
fi
8273327
fb0a2d0
if [ -n "${old_subnet_mask}" ]; then
fb0a2d0
    old_prefix="$(ipcalc -p ${old_ip_address} ${new_subnet_mask} | cut -d '=' -f 2)"
8273327
fi
8273327
fb0a2d0
if [ -n "${alias_subnet_mask}" ]; then
fb0a2d0
    alias_prefix="$(ipcalc -p ${alias_ip_address} ${alias_subnet_mask} | cut -d '=' -f 2)"
8273327
fi
8273327
fb0a2d0
case "${reason}" in
fb0a2d0
    MEDIUM)
fb0a2d0
        # Linux doesn't handle mediums (media)
fb0a2d0
        exit_with_hooks 0
fb0a2d0
        ;;
fb0a2d0
fb0a2d0
    PREINIT)
fb0a2d0
        if [ -n "${alias_ip_address}" ]; then
fb0a2d0
            # Bring down alias interface, its routes will disappear too.
fb0a2d0
            ip -family inet link set ${interface}:0 down
881f7fa
        fi
8273327
fb0a2d0
        if [ "${keep_old_ip}" = "yes" ]; then
fb0a2d0
            ip -family inet link set ${interface} up
fb0a2d0
        else
fb0a2d0
            ip -family inet addr flush dev ${interface}
fb0a2d0
            ip -family inet link set ${interface} up
8273327
        fi
8273327
fb0a2d0
        if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then
fb0a2d0
            sleep ${DHCLIENT_DELAY}
881f7fa
        fi
8273327
fb0a2d0
        exit_with_hooks 0
fb0a2d0
        ;;
8273327
fb0a2d0
    ARPCHECK|ARPSEND)
fb0a2d0
        if [ -z "${new_ip_address}" ] || [ -z "${interface}" ] ||
fb0a2d0
           arping -q -f -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
fb0a2d0
            exit_with_hooks 0
fb0a2d0
        else
fb0a2d0
            exit_with_hooks 1
8273327
        fi
fb0a2d0
        ;;
8273327
fb0a2d0
    BOUND|RENEW|REBIND|REBOOT)
fb0a2d0
        dhconfig
fb0a2d0
        exit_with_hooks 0
fb0a2d0
        ;;
fb0a2d0
fb0a2d0
    EXPIRE|FAIL|RELEASE|STOP)
fb0a2d0
        # only restore config files if there are no other dhclient processes
fb0a2d0
        # running (#306381)
fb0a2d0
        any_other_clients="$(ps -eo pid,ppid,comm | grep dhclient | grep -v ${PPID})"
fb0a2d0
        if [ -n "${any_other_clients}" ]; then
fb0a2d0
            if [ -f ${SAVEDIR}/resolv.conf.predhclient.${interface} ]; then
fb0a2d0
                change_resolv_conf ${SAVEDIR}/resolv.conf.predhclient.${interface}
fb0a2d0
                rm -f ${SAVEDIR}/resolv.conf.predhclient.${interface}
fb0a2d0
            fi
8273327
fb0a2d0
            if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
fb0a2d0
               [[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
fb0a2d0
                if [ -e ${SAVEDIR}/localtime.predhclient.${interface} ]; then
fb0a2d0
                    rm -f /etc/localtime
fb0a2d0
                    mv ${SAVEDIR}/localtime.predhclient.${interface} /etc/localtime
fb0a2d0
                    touch /etc/localtime
fb0a2d0
                fi
fb0a2d0
            fi
8273327
fb0a2d0
            if [ -f ${SAVEDIR}/ntp.conf.predhclient.${interface} ]; then
fb0a2d0
                rm -f /etc/ntp.conf
fb0a2d0
                mv -f ${SAVEDIR}/ntp.conf.predhclient.${interface} /etc/ntp.conf
fb0a2d0
                service ntpd condrestart >/dev/null 2>&1
fb0a2d0
            fi
8273327
fb0a2d0
            if [ -f ${SAVEDIR}/yp.conf.predhclient.${interface} ]; then
fb0a2d0
                rm -f /etc/yp.conf
fb0a2d0
                mv -f ${SAVEDIR}/yp.conf.predhclient.${interface} /etc/yp.conf
fb0a2d0
                if [ -x /etc/rc.d/init.d/ypbind ] && [ -r /var/run/ypbind.pid ]; then
fb0a2d0
                    service ypbind restart >/dev/null 2>&1
fb0a2d0
                fi
fb0a2d0
            fi
fb0a2d0
        fi
8273327
fb0a2d0
        if [ -x /etc/dhclient-${interface}-down-hooks ]; then
fb0a2d0
            . /etc/dhclient-${interface}-down-hooks
fb0a2d0
        elif [ -x /etc/dhclient-down-hooks ]; then
fb0a2d0
            . /etc/dhclient-down-hooks
fb0a2d0
        fi
8273327
fb0a2d0
        if [ -n "${alias_ip_address}" ]; then
fb0a2d0
            # Turn off alias interface
fb0a2d0
            ip -family inet link set ${interface}:0 down
fb0a2d0
        fi
8273327
fb0a2d0
        if [ -n "${old_ip_address}" ]; then
fb0a2d0
            # Shut down interface, which will delete routes and clear arp cache.
fb0a2d0
            ip -family inet addr flush dev ${interface}
fb0a2d0
            ip -family inet link set ${interface} down
fb0a2d0
        fi
fb0a2d0
fb0a2d0
        if [ -n "${alias_ip_address}" ]; then
fb0a2d0
            ip -family inet addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
fb0a2d0
            ip -family inet route replace ${alias_ip_address}/32 ${interface}:0
fb0a2d0
        fi
8273327
8273327
        exit_with_hooks 0
fb0a2d0
        ;;
8273327
fb0a2d0
    TIMEOUT)
fb0a2d0
        if [ -n "${new_routers}" ]; then
fb0a2d0
            if [ -n "${alias_ip_address}" ]; then
fb0a2d0
                ip -family inet addr flush dev ${interface}:0
fb0a2d0
            fi
fb0a2d0
fb0a2d0
            ip -family inet addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
fb0a2d0
            set ${new_routers}
fb0a2d0
fb0a2d0
            if ping -q -c 1 -w 10 -I ${interface} ${1}; then
fb0a2d0
                dhconfig
fb0a2d0
                exit_with_hooks 0
fb0a2d0
            fi
fb0a2d0
fb0a2d0
            ip -family inet addr flush dev ${interface}
fb0a2d0
            ip -family inet link set ${interface} down
fb0a2d0
            exit_with_hooks 1
fb0a2d0
        else
fb0a2d0
            exit_with_hooks 1
fb0a2d0
        fi
fb0a2d0
        ;;
fb0a2d0
fb0a2d0
    *)
fb0a2d0
        logmessage "unhandled state: ${reason}"
fb0a2d0
        exit_with_hooks 1
fb0a2d0
        ;;
fb0a2d0
esac
8273327
8273327
exit_with_hooks 0