From: David Hankins Date: Fri, 18 May 2007 17:18:05 +0000 (+0000) Subject: - Duplicate dhclient-script updates for DHCPv6 to all provided scripts. X-Git-Tag: v4_0_0a1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f66f02cc9c7e713bb5e8b40352052cd007e54215;p=thirdparty%2Fdhcp.git - Duplicate dhclient-script updates for DHCPv6 to all provided scripts. [ISC-Bugs #16875] --- diff --git a/RELNOTES b/RELNOTES index 21399a409..69a524960 100644 --- a/RELNOTES +++ b/RELNOTES @@ -63,7 +63,9 @@ the README file. - Silenced several other compiler warnings. - Include the more standard sys/uio.h rather than rely upon other - header files to include it (fixes a BSDI compile failure). + header files to include it (fixes a BSD 4.2 compile failure). + +- Duplicate dhclient-script updates for DHCPv6 to all provided scripts. Changes since 3.1.0 (NEW FEATURES) diff --git a/client/scripts/bsdos b/client/scripts/bsdos index fb0d43f22..de3b18d78 100755 --- a/client/scripts/bsdos +++ b/client/scripts/bsdos @@ -16,6 +16,18 @@ make_resolv_conf() { done mv /etc/resolv.conf.dhclient /etc/resolv.conf + elif [ "x${new_dhcp6_name_servers}" != x ] ; then + cat /dev/null > /etc/resolv.conf.dhclient6 + chmod 644 /etc/resolv.conf.dhclient6 + + if [ "x${new_dhcp6_domain_search}" != x ] ; then + echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 + fi + for nameserver in ${new_dhcp6_name_servers} ; do + echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 + done + + mv /etc/resolv.conf.dhclient6 /etc/resolv.conf fi } @@ -68,6 +80,10 @@ if [ x$reason = xMEDIUM ]; then exit_with_hooks 0 fi +### +### DHCPv4 Handlers +### + if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 @@ -213,4 +229,64 @@ if [ x$reason = xTIMEOUT ]; then exit_with_hooks 1 fi +### +### DHCPv6 Handlers +### + +if [ ${reason} = PREINIT6 ] ; then + # Ensure interface is up. + ifconfig ${interface} up + + # XXX: Remove any stale addresses from aborted clients. + + exit_with_hooks 0 +fi + +if [ ${reason} = BOUND6 ] ; then + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen} + + # Check for nameserver options. + make_resolv_conf + + exit_with_hooks 0 +fi + +if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then + # Make sure nothing has moved around on us. + + # Nameservers/domains/etc. + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then + make_resolv_conf + fi + + exit_with_hooks 0 +fi + +if [ ${reason} = DEPREF6 ] ; then + if [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + # XXX: + # There doesn't appear to be a way to update an addr to indicate + # preference. + + exit_with_hooks 0 +fi + +if [ ${reason} = EXPIRE6 ] ; then + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen} + + exit_with_hooks 0 +fi + exit_with_hooks 0 diff --git a/client/scripts/freebsd b/client/scripts/freebsd index b40316eb1..b4567a50c 100755 --- a/client/scripts/freebsd +++ b/client/scripts/freebsd @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: freebsd,v 1.17 2006/07/22 02:24:16 dhankins Exp $ +# $Id: freebsd,v 1.18 2007/05/18 17:18:05 dhankins Exp $ # # $FreeBSD$ @@ -45,6 +45,33 @@ make_resolv_conf() { $LOGGER "Error while writing new /etc/resolv.conf." fi fi + elif [ "x${new_dhcp6_name_servers}" != x ] ; then + ( cat /dev/null > /etc/resolv.conf.dhclient6 ) + exit_status=$? + if [ $exit_status -ne 0 ] ; then + $LOGGER "Unable to create /etc/resolv.conf.dhclient6: Error $exit_status" + else + if [ "x${new_dhcp6_domain_search}" != x ] ; then + ( echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 ) + exit_status=$? + fi + for nameserver in ${new_dhcp6_name_servers} ; do + if [ $exit_status -ne 0 ] ; then + break + fi + ( echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 ) + exit_status = $? + done + + if [ $exit_status -ne 0 ] ; then + ( mv /etc/resolv.conf.dhclient6 /etc/resolv.conf ) + exit_status = $? + fi + + if [ $exit_status -ne 0 ] ; then + $LOGGER "Error while writing new /etc/resolv.conf." + fi + fi fi } @@ -97,6 +124,10 @@ if [ x$reason = xMEDIUM ]; then exit_with_hooks 0 fi +### +### DHCPv4 Handlers +### + if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 @@ -253,4 +284,64 @@ if [ x$reason = xTIMEOUT ]; then exit_with_hooks 1 fi +### +### DHCPv6 Handlers +### + +if [ ${reason} = PREINIT6 ] ; then + # Ensure interface is up. + ifconfig ${interface} up + + # XXX: Remove any stale addresses from aborted clients. + + exit_with_hooks 0 +fi + +if [ ${reason} = BOUND6 ] ; then + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 alias ${new_ip6_address}/${new_ip6_prefixlen} + + # Check for nameserver options. + make_resolv_conf + + exit_with_hooks 0 +fi + +if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then + # Make sure nothing has moved around on us. + + # Nameservers/domains/etc. + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then + make_resolv_conf + fi + + exit_with_hooks 0 +fi + +if [ ${reason} = DEPREF6 ] ; then + if [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + # XXX: + # There doesn't appear to be a way to update an addr to indicate + # preference. + + exit_with_hooks 0 +fi + +if [ ${reason} = EXPIRE6 ] ; then + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 -alias ${old_ip6_address}/${old_ip6_prefixlen} + + exit_with_hooks 0 +fi + exit_with_hooks 0 diff --git a/client/scripts/linux b/client/scripts/linux index 72e37ee15..ee3ef42d6 100755 --- a/client/scripts/linux +++ b/client/scripts/linux @@ -1,101 +1,4 @@ #!/bin/bash -# dhclient-script for Linux. Dan Halbert, March, 1997. -# Updated for Linux 2.[12] by Brian J. Murrell, January 1999. -# Updated for ipv6 by David W. Hankins, Janurary 2007. - -ip=/sbin/ip - -make_resolv_conf() { - if [ "x${new_dhcp6_name_servers}" != x ] ; then - cat /dev/null > /etc/resolv.conf.dhclient - chmod 644 /etc/resolv.conf.dhclient - - if [ "x${new_dhcp6_domain_search}" != x ] ; then - echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient - fi - for nameserver in ${new_dhcp6_name_servers} ; do - echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient - done - - mv /etc/resolv.conf.dhclient /etc/resolv.conf - fi -} - -# Check for valid constant input values. -if [ x${reason} = x ] || [ x${interface} = x ] ; then - exit 1; -fi - - -if [ ${reason} = PREINIT6 ] ; then - # Ensure interface is up. - ${ip} link set ${interface} up - - # Remove any stale addresses. - ${ip} -f inet6 addr flush dev ${interface} scope global permanent - - exit 0 -fi - - -if [ ${reason} = BOUND6 ] ; then - if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then - exit 2; - fi - - ${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ - dev ${interface} scope global - - # Check for nameserver options. - make_resolv_conf - - exit 0 -fi - - -if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then - # Make sure nothing has moved around on us. - - # Nameservers/domains/etc. - if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || - [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then - make_resolv_conf - fi - - exit 0 -fi - - -if [ ${reason} = DEPREF6 ] ; then - if [ x${new_ip6_prefixlen} = x ] ; then - exit 2; - fi - - # There doesn't appear to be a way to update an addr to indicate - # preference. -# ${ip} -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \ -# dev ${interface} scope global deprecated? - - exit 0 -fi - - -if [ ${reason} = EXPIRE6 ] ; then - if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then - exit 2; - fi - - ${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \ - dev ${interface} - - exit 0 -fi - - -# Old DHCPv4 script below, need to review and reintegrate. - -exit - # dhclient-script for Linux. Dan Halbert, March, 1997. # Updated for Linux 2.[12] by Brian J. Murrell, January 1999. # No guarantees about this. I'm a novice at the details of Linux @@ -119,6 +22,9 @@ exit # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious # of the $1 in its args. +# 'ip' just looks too weird. /sbin/ip looks less weird. +ip=/sbin/ip + make_resolv_conf() { if [ x"$new_domain_name_servers" != x ]; then cat /dev/null > /etc/resolv.conf.dhclient @@ -136,6 +42,18 @@ make_resolv_conf() { done mv /etc/resolv.conf.dhclient /etc/resolv.conf + elif [ "x${new_dhcp6_name_servers}" != x ] ; then + cat /dev/null > /etc/resolv.conf.dhclient6 + chmod 644 /etc/resolv.conf.dhclient6 + + if [ "x${new_dhcp6_domain_search}" != x ] ; then + echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 + fi + for nameserver in ${new_dhcp6_name_servers} ; do + echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 + done + + mv /etc/resolv.conf.dhclient6 /etc/resolv.conf fi } @@ -165,6 +83,10 @@ release=`expr $release : '\(.*\)\..*'` relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'` relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'` +### +### DHCPv4 Handlers +### + if [ x$new_broadcast_address != x ]; then new_broadcast_arg="broadcast $new_broadcast_address" fi @@ -281,7 +203,6 @@ if [ x$reason = xTIMEOUT ]; then ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg set $new_routers - ############## what is -w in ping? if ping -q -c 1 $1; then if [ x$new_ip_address != x$alias_ip_address ] && \ [ x$alias_ip_address != x ]; then @@ -302,4 +223,68 @@ if [ x$reason = xTIMEOUT ]; then exit_with_hooks 1 fi +### +### DHCPv6 Handlers +### + +if [ ${reason} = PREINIT6 ] ; then + # Ensure interface is up. + ${ip} link set ${interface} up + + # Remove any stale addresses from aborted clients. + ${ip} -f inet6 addr flush dev ${interface} scope global permanent + + exit_with_hooks 0 +fi + +if [ ${reason} = BOUND6 ] ; then + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ + dev ${interface} scope global + + # Check for nameserver options. + make_resolv_conf + + exit_with_hooks 0 +fi + +if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then + # Make sure nothing has moved around on us. + + # Nameservers/domains/etc. + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then + make_resolv_conf + fi + + exit_with_hooks 0 +fi + +if [ ${reason} = DEPREF6 ] ; then + if [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + # There doesn't appear to be a way to update an addr to indicate + # preference. +# ${ip} -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \ +# dev ${interface} scope global deprecated? + + exit_with_hooks 0 +fi + +if [ ${reason} = EXPIRE6 ] ; then + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \ + dev ${interface} + + exit_with_hooks 0 +fi + exit_with_hooks 0 diff --git a/client/scripts/netbsd b/client/scripts/netbsd index 3de6b555d..5629ee785 100755 --- a/client/scripts/netbsd +++ b/client/scripts/netbsd @@ -16,6 +16,18 @@ make_resolv_conf() { done mv /etc/resolv.conf.dhclient /etc/resolv.conf + elif [ "x${new_dhcp6_name_servers}" != x ] ; then + cat /dev/null > /etc/resolv.conf.dhclient6 + chmod 644 /etc/resolv.conf.dhclient6 + + if [ "x${new_dhcp6_domain_search}" != x ] ; then + echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 + fi + for nameserver in ${new_dhcp6_name_servers} ; do + echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 + done + + mv /etc/resolv.conf.dhclient6 /etc/resolv.conf fi } @@ -68,6 +80,10 @@ if [ x$reason = xMEDIUM ]; then exit_with_hooks 0 fi +### +### DHCPv4 Handlers +### + if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 @@ -213,4 +229,64 @@ if [ x$reason = xTIMEOUT ]; then exit_with_hooks 1 fi +### +### DHCPv6 Handlers +### + +if [ ${reason} = PREINIT6 ] ; then + # Ensure interface is up. + ifconfig ${interface} up + + # XXX: Remove any stale addresses from aborted clients. + + exit_with_hooks 0 +fi + +if [ ${reason} = BOUND6 ] ; then + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen} + + # Check for nameserver options. + make_resolv_conf + + exit_with_hooks 0 +fi + +if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then + # Make sure nothing has moved around on us. + + # Nameservers/domains/etc. + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then + make_resolv_conf + fi + + exit_with_hooks 0 +fi + +if [ ${reason} = DEPREF6 ] ; then + if [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + # XXX: + # There doesn't appear to be a way to update an addr to indicate + # preference. + + exit_with_hooks 0 +fi + +if [ ${reason} = EXPIRE6 ] ; then + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen} + + exit_with_hooks 0 +fi + exit_with_hooks 0 diff --git a/client/scripts/openbsd b/client/scripts/openbsd index 64fead2e2..a17a0a451 100644 --- a/client/scripts/openbsd +++ b/client/scripts/openbsd @@ -16,6 +16,18 @@ make_resolv_conf() { done mv /etc/ersolv.conf.dhclient /etc/resolv.conf + elif [ "x${new_dhcp6_name_servers}" != x ] ; then + cat /dev/null > /etc/resolv.conf.dhclient6 + chmod 644 /etc/resolv.conf.dhclient6 + + if [ "x${new_dhcp6_domain_search}" != x ] ; then + echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 + fi + for nameserver in ${new_dhcp6_name_servers} ; do + echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 + done + + mv /etc/resolv.conf.dhclient6 /etc/resolv.conf fi } @@ -68,6 +80,10 @@ if [ x$reason = xMEDIUM ]; then exit_with_hooks 0 fi +### +### DHCPv4 Handlers +### + if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 @@ -213,4 +229,64 @@ if [ x$reason = xTIMEOUT ]; then exit_with_hooks 1 fi +### +### DHCPv6 Handlers +### + +if [ ${reason} = PREINIT6 ] ; then + # Ensure interface is up. + ifconfig ${interface} up + + # XXX: Remove any stale addresses from aborted clients. + + exit_with_hooks 0 +fi + +if [ ${reason} = BOUND6 ] ; then + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen} + + # Check for nameserver options. + make_resolv_conf + + exit_with_hooks 0 +fi + +if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then + # Make sure nothing has moved around on us. + + # Nameservers/domains/etc. + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then + make_resolv_conf + fi + + exit_with_hooks 0 +fi + +if [ ${reason} = DEPREF6 ] ; then + if [ x${new_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + # XXX: + # There doesn't appear to be a way to update an addr to indicate + # preference. + + exit_with_hooks 0 +fi + +if [ ${reason} = EXPIRE6 ] ; then + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then + exit_with_hooks 2; + fi + + ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen} + + exit_with_hooks 0 +fi + exit_with_hooks 0