From b6b28d718d2ba98a421876c3984666b6092502bf8a2cd94b62dbf2b8ceba8a3a Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Fri, 7 May 2010 14:12:44 +0000 Subject: [PATCH] - Updated to ISC DHCP 4.1.1, the current 4.x series production release, providing DHCPv6 client/server/relay implementation. The programs act in DHCPv6 mode, when the -6 start option is set. We install separate init scripts with a 6 at the end to handle them, that is /etc/init.d/dhcpd6 and dhrelay6. Further, there is also a link to the binaries with a 6 at the end, e.g. dhclient6, making it visible, that the installed version supports DHCPv6. - Moved additional documentation to a separate dhcp-doc package. - Changed to provide config files and scripts as source files instead of patches to the ISC scripts. - Adopted spec file and config/scripts, merged in all patches. - Implemented RFC 3442 classless static routes support in the dhclient-script (bnc#555870). OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=15 --- SuSEfirewall2.dhcp-server | 4 +- contrib.tar.gz | 3 + dhclient-script | 637 ++++++++++++++++++ dhclient.conf | 57 ++ dhclient6.conf | 9 + dhcp-3.1-ESV.tar.bz2 | 3 - dhcp-3.1.1-dhclient-conf.dif | 81 --- dhcp-3.1.1-dhclient-use-script-cmdline.dif | 17 - dhcp-3.1.1-man-includes.dif | 26 - dhcp-3.1.1-omapi-test.c.dif | 10 - dhcp-3.1.1-paranoia.dif | 170 ----- dhcp-3.1.1-paths.dif | 148 ---- dhcp-3.1.1-pie.dif | 45 -- dhcp-3.1.3-dhclient-conf.bnc516459.dif | 13 - dhcp-3.1.3-dhclient-script.bnc555095.dif | 73 -- dhcp-3.1.3-dhclient-script.bnc585380.dif | 156 ----- dhcp-3.1.3-dhclient-script.dif | 383 ----------- dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 | 3 - dhcp-4.1.1-default-paths.diff | 32 + ...if => dhcp-4.1.1-dhclient-exec-filedes.dif | 8 +- dhcp-4.1.1-dhclient-exec-filedes.diff | 17 + dhcp-4.1.1-dhclient-no-libcrypto.diff | 16 + ...dhcp-4.1.1-dhclient-send-hostname-rml.diff | 70 +- dhcp-4.1.1-in6_pktinfo-prototype.diff | 21 + dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 | 3 + dhcp-4.1.1-man-includes.diff | 26 + dhcp-4.1.1-paranoia.diff | 63 ++ ...1.1-tmpfile.dif => dhcp-4.1.1-tmpfile.diff | 8 +- dhcp-4.1.1.tar.bz2 | 3 + dhcp.changes | 17 + dhcp.spec | 609 +++++++++-------- dhcpd.conf | 138 ++++ dhcpd6.conf | 107 +++ dhcpd6.xml | 88 +++ if-up.d.dhcpd-restart-hook | 55 +- rc.dhcpd | 164 +++-- rc.dhcpd6 | 413 ++++++++++++ rc.dhcrelay | 20 +- rc.dhcrelay6 | 220 ++++++ sysconfig.dhcpd | 112 ++- sysconfig.dhcrelay | 39 +- sysconfig.syslog-dhcpd | 20 +- 42 files changed, 2535 insertions(+), 1572 deletions(-) create mode 100644 contrib.tar.gz create mode 100644 dhclient-script create mode 100644 dhclient.conf create mode 100644 dhclient6.conf delete mode 100644 dhcp-3.1-ESV.tar.bz2 delete mode 100644 dhcp-3.1.1-dhclient-conf.dif delete mode 100644 dhcp-3.1.1-dhclient-use-script-cmdline.dif delete mode 100644 dhcp-3.1.1-man-includes.dif delete mode 100644 dhcp-3.1.1-omapi-test.c.dif delete mode 100644 dhcp-3.1.1-paranoia.dif delete mode 100644 dhcp-3.1.1-paths.dif delete mode 100644 dhcp-3.1.1-pie.dif delete mode 100644 dhcp-3.1.3-dhclient-conf.bnc516459.dif delete mode 100644 dhcp-3.1.3-dhclient-script.bnc555095.dif delete mode 100644 dhcp-3.1.3-dhclient-script.bnc585380.dif delete mode 100644 dhcp-3.1.3-dhclient-script.dif delete mode 100644 dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 create mode 100644 dhcp-4.1.1-default-paths.diff rename dhcp-3.1.1-dhclient-exec-filedes.dif => dhcp-4.1.1-dhclient-exec-filedes.dif (63%) create mode 100644 dhcp-4.1.1-dhclient-exec-filedes.diff create mode 100644 dhcp-4.1.1-dhclient-no-libcrypto.diff rename dhcp-3.1.1-dhclient-send-hostname-rml.dif => dhcp-4.1.1-dhclient-send-hostname-rml.diff (51%) create mode 100644 dhcp-4.1.1-in6_pktinfo-prototype.diff create mode 100644 dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 create mode 100644 dhcp-4.1.1-man-includes.diff create mode 100644 dhcp-4.1.1-paranoia.diff rename dhcp-3.1.1-tmpfile.dif => dhcp-4.1.1-tmpfile.diff (86%) create mode 100644 dhcp-4.1.1.tar.bz2 create mode 100644 dhcpd.conf create mode 100644 dhcpd6.conf create mode 100644 dhcpd6.xml create mode 100644 rc.dhcpd6 create mode 100644 rc.dhcrelay6 diff --git a/SuSEfirewall2.dhcp-server b/SuSEfirewall2.dhcp-server index e4aff2d..640417d 100644 --- a/SuSEfirewall2.dhcp-server +++ b/SuSEfirewall2.dhcp-server @@ -1,5 +1,5 @@ -## Name: DHCP Server -## Description: Opens ports for ISC DHCP Server. +## Name: DHCPv4 Server +## Description: Opens ports for ISC DHCPv4 4.x Server. # # For a more detailed description of the individual variables see # the comments for FW_SERVICES_*_EXT in /etc/sysconfig/SuSEfirewall2 diff --git a/contrib.tar.gz b/contrib.tar.gz new file mode 100644 index 0000000..515b10f --- /dev/null +++ b/contrib.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:699a861ef8be1a62fe1efa802ae71d9045b55bfc61b4cd76c34f94e47be4952e +size 8333 diff --git a/dhclient-script b/dhclient-script new file mode 100644 index 0000000..0088202 --- /dev/null +++ b/dhclient-script @@ -0,0 +1,637 @@ +#!/bin/bash +# +# /sbin/dhclient-script for openSUSE / SUSE Linux Enterprise Server +# based on the scripts shipped with the ISC DHCP (4.1.1) client. +# +# Note: +# It is used by sysconfig alias netcontrol alias ifup-dhcp, +# but not by the NetworkManager that is using an own script. +# +# Copyright (C) 2010 SUSE LINUX Products GmbH / Novell Inc. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Marius Tomaschewski +# + +## +## check mandatory parameters or ignore & exit +## +test "x$reason" = x -o "x$interface" = x && exit 1 + +# +# source sysconfig functions +# +SYSCONFIG_CFG_DIR="/etc/sysconfig/network" +. "$SYSCONFIG_CFG_DIR/scripts/functions" +SYSCONFIG_RUN_DIR=${SYSCONFIG_RUN_DIR:-/dev/.sysconfig/network} + +# +# Debugging: +# logs entire run of dhclient-script to /var/log/${dhclient}-script.*.log, +# when DHCLIENT_DEBUG/DHCLIENT6_DEBUG are "yes" in sysconfig/network/dhcp +# +eval `grep '^DHCLIENT6\?_DEBUG=' "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` +case $reason in + *6) DEBUG=$DHCLIENT6_DEBUG ; dhclient=dhclient6 ; ipver=6 ;; + *) DEBUG=$DHCLIENT_DEBUG ; dhclient=dhclient ; ipver=4 ;; +esac +if [ "$DEBUG" = yes ]; then + set -a # allexport + ( + echo '****************' + echo "$0 $*" + date + echo '----------------' + env + echo '----------------' + ) >> /var/log/${dhclient}-script.$interface.log + exec 2>> /var/log/${dhclient}-script.$interface.log + set +a + set -x +fi + +is_ifup_controlled() +{ + test -f "$SYSCONFIG_RUN_DIR/if-${interface}" +} +# netconfig makes all "additional" modifications as DNS or NTP +netconfig_modify() { + if test -x /sbin/netconfig -a -n "$interface" ; then + { + echo "INTERFACE='$interface'" + for v in ${!new_*}; do + case $ipver in + 6) + case $v in + (new_ip6_address) k='IPADDR' ;; + (new_ip6_prefixlen) k='PREFIXLEN' ;; + (new_dhcp6_client_id) k='DHCP6CID' ;; + (new_dhcp6_server_id) k='DHCP6SID' ;; + (new_dhcp6_domain_search) k='DNSSEARCH' ;; + (new_dhcp6_name_servers) k='DNSSERVERS' ;; + (*) k="dhclient6_${v#new_}" ;; + esac + ;; + 4) + case $v in + (new_ip_address) k='IPADDR' ;; + (new_subnet_mask) k='NETMASK' ;; + (new_network_number) k='NETWORK' ;; + (new_broadcast_address) k='BROADCAST' ;; + (new_interface_mtu) k='MTU' ;; + (new_rfc3442_classless_static_routes) + k='ROUTES' ;; + # (new_static_routes) k='ROUTES' ;; + (new_routers) k='GATEWAYS' ;; + (new_host_name) k='HOSTNAME' ;; + (new_domain_search) k='DNSSEARCH' ;; + (new_domain_name) k='DNSDOMAIN' ;; + (new_domain_name_servers) k='DNSSERVERS' ;; + (new_ntp_servers) k='NTPSERVERS' ;; + (new_nis_domain) k='NISDOMAIN' ;; + (new_nis_servers) k='NISSERVERS' ;; + (new_root_path) k='ROOTPATH' ;; + (new_dhcp_server_identifier)k='DHCPSID' ;; + (new_lpr_servers) k='LPRSERVER' ;; + (new_log_servers) k='LOGSERVER' ;; + (new_netbios_dd_server) k='NETBIOSDDSERVER' ;; + (new_netbios_name_servers) k='NETBIOSNAMESERVER' ;; + (new_netbios_node_type) k='NETBIOSNODETYPE' ;; + (new_netbios_scope) k='NETBIOSSCOPE' ;; + (*) k="dhclient_${v#new_}" ;; + esac + esac + [ "k${k}" != k ] && echo "${k}='${!v}'" + done + } | /sbin/netconfig modify -s "dhclient$ipver" -i "$interface" + fi +} +netconfig_remove() { + if test -x /sbin/netconfig -a -n "$interface" ; then + /sbin/netconfig remove -s "dhclient$ipver" -i "$interface" &1` && return 0 + case $err in + RTNETLINK*answers:*File*exists) ;; + RTNETLINK*answers:*No*such*process) + # + # The gateway seems to be not reachable via local network + # route (implicitly created by ifconfig based on the IP + # and netmask provided by dhcp). + # Check this, set an explicit host route to the gateway + # over the current interface and try again (bnc#266215). + # + retry=0 + for router in ${gate[@]} ; do + matches=$(/sbin/ip -f inet -o route list match $router | \ + grep -v ^default | grep -c -v "^$" 2>/dev/null) + if [ -n "$matches" -a $(($matches)) -eq 0 ] ; then + LC_ALL=C /sbin/ip route add $router/32 dev $interface || retry=1 + fi + done + if [ $retry -eq 0 ] ; then + LC_ALL=C /sbin/ip route replace ${args[*]} && return 0 + fi + ;; + esac + return 1 +} +get_ipv4_default_gw() +{ + if [ "x$new_rfc3442_classless_static_routes" != x ] ; then + local r route=() gw=() + for r in $new_rfc3442_classless_static_routes ; do + route=(${r//,/ }) + case ${route[0]}/${route[1]} in + 0.0.0.0/0.0.0.0) + [ "x${route[2]}" = "x0.0.0.0" ] || \ + gw+=(${route[2]}) + ;; + esac + done + echo "${gw[*]}" + elif [ "$new_routers" != x ] ; then + echo "$new_routers" + fi +} +set_ipv4_routes() +{ + if [ "x$new_rfc3442_classless_static_routes" != x ] ; then + local r route=() + # TODO: multiple gw's to one dest as in $new_routers? + for r in $new_rfc3442_classless_static_routes ; do + route=(${r//,/ }) + case ${route[0]}/${route[1]} in + 0.0.0.0/0.0.0.0) + [ "x$DHCLIENT_SET_DEFAULT_ROUTE" = xyes ] || continue ;; + esac + set_ipv4_route ${route[*]} + done + elif [ "$new_routers" != x ] ; then + if [ "x$DHCLIENT_SET_DEFAULT_ROUTE" = xyes ] ; then + set_ipv4_route default "" $new_routers + fi + fi +} +set_ipv6_routes() +{ + : TODO +} +set_hostname() +{ + if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then + current_hostname=`hostname` + if [ "x${current_hostname%%.*}" = "x" ] || \ + [ "x${current_hostname%%.*}" = "x(none)" ] || \ + [ "x${current_hostname%%.*}" = "xlocalhost" ] || \ + [ "x${current_hostname%%.*}" != "x${new_host_name%%.*}" ]; then + + if [ "x${new_host_name%%.*}" != "x" ]; then + hostname "${new_host_name%%.*}" + else + if [ -x /usr/bin/host ] ; then + if out=`host -W 2 "$new_ip_address" 2>/dev/null` ; then + _hostname="`echo "$out" | sed 's:^.* ::; s:\..*::'`" + if [ "x${_hostname}" != "x" -a \ + "x${_hostname}" != "x${current_hostname%%.*}" ]; then + hostname "${_hostname}" + fi + fi + fi + fi + fi + fi + if is_ifup_controlled ; then + # check regardless the DHCLIENT_SET_HOSTNAME setting + # and whether we've set it above or not, because when + # it changed, we've to handle it anyway... + local OLD_HOSTNAME=`read_cached_config_data hostname $interface` + local CUR_HOSTNAME=`hostname 2>/dev/null` + if test "x$OLD_HOSTNAME" != "x$CUR_HOSTNAME" ; then + write_cached_config_data hostname "$CUR_HOSTNAME" $interface + commit_cached_config_data $interface + + # reload syslog so it knows the new hostname + /etc/init.d/syslog reload + fi + fi +} + +# Must be used on exit. Invokes the local dhcp client exit hooks, if any. +exit_with_hooks() { + exit_status=$1 + if [ -f /etc/${dhclient}-exit-hooks ]; then + . /etc/${dhclient}-exit-hooks + fi + # probably should do something with exit status of the local script + exit $exit_status +} + +# Invoke the local dhcp client enter hooks, if they exist. +if [ -f /etc/${dhclient}-enter-hooks ]; then + exit_status=0 + . /etc/${dhclient}-enter-hooks + # allow the local script to abort processing of this state + # local script must set exit_status variable to nonzero. + if [ $exit_status -ne 0 ]; then + exit $exit_status + fi +fi + +case $dhclient in +dhclient) + if is_ifup_controlled ; then + # STARTMODE + eval `grep --no-filename \ + '^[[:space:]]*STARTMODE=' \ + "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` + tmp_startmode=`read_cached_config_data startmode $INTERFACE` + [ -n "$tmp_startmode" ] && STARTMODE="$tmp_startmode" + + # DHCLIENT_SET_HOSTNAME and DHCLIENT_SET_DEFAULT_ROUTE + if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; + then + eval `grep --no-filename \ + '^[[:space:]]*DHCLIENT_SET_\(HOSTNAME\|DEFAULT_ROUTE\)=' \ + "$SYSCONFIG_CFG_DIR/dhcp" + "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` + else + eval `grep --no-filename \ + '^[[:space:]]*DHCLIENT_SET_\(HOSTNAME\|DEFAULT_ROUTE\)=' \ + "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` + fi + else + STARTMODE=manual + eval `grep --no-filename \ + '^[[:space:]]*DHCLIENT_SET_\(HOSTNAME\|DEFAULT_ROUTE\)=' \ + "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` + fi + if [ "x$new_rfc3442_classless_static_routes_raw" != x ] ; then + new_rfc3442_classless_static_routes=$( + parse_ipv4_classless_routes $new_rfc3442_classless_static_routes_raw + ) + else + unset new_rfc3442_classless_static_routes + fi + if [ x$new_broadcast_address != x ] ; then + new_broadcast_arg="brd $new_broadcast_address" + elif [ "x$new_subnet_mask" != "x255.255.255.255" ] ; then + new_broadcast_arg="brd +" + fi + if [ x$new_interface_mtu != x -a \ + $(( $new_interface_mtu )) -lt 576 ] ; + then + # 68 is the minimal legal value, but 576 the real life minimum + unset new_interface_mtu + fi + if [ x$IF_METRIC != x ]; then + metric_arg="metric $IF_METRIC" + fi +;; +dhclient6) + if is_ifup_controlled ; then + # STARTMODE + eval `grep --no-filename \ + '^[[:space:]]*STARTMODE=' \ + "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` + tmp_startmode=`read_cached_config_data startmode $INTERFACE` + [ -n "$tmp_startmode" ] && STARTMODE="$tmp_startmode" + else + STARTMODE=manual + fi +;; +esac + +case $reason in +###################################################################### +## DHCPv4 # +###################################################################### + +MEDIUM) + #################################################################### + exit_with_hooks 0 +;; + +PREINIT) + #################################################################### + if [ "x$alias_ip_address" != x ]; then + /sbin/ip addr del $alias_ip_address/$alias_subnet_mask dev $interface + fi + if [ "x$STARTMODE" != "xnfsroot" ] ; then + /sbin/ip -4 addr flush dev $interface + fi + /sbin/ip link set $interface up + + # We need to give the kernel some time to get the interface up. + sleep 1 + + exit_with_hooks 0 +;; + +ARPCHECK|ARPSEND) + #################################################################### + exit_with_hooks 0 +;; + +BOUND|RENEW|REBIND|REBOOT) + #################################################################### + + if [ x$old_ip_address != x -a x$alias_ip_address != x ] && \ + [ x$alias_ip_address != x$old_ip_address ] ; + then + # Possible new alias. Remove old alias. + /sbin/ip addr del $alias_ip_address/$alias_subnet_mask dev $interface + fi + if [ x$old_ip_address != x -a x$old_ip_address != x$new_ip_address ]; then + # IP address changed. Flush to clear routes and ARP cache. + if [ "x$STARTMODE" != "xnfsroot" ] ; then + /sbin/ip -4 addr flush dev $interface + fi + fi + + if [ x$new_interface_mtu != x ] ; then + /sbin/ip link set $interface mtu $new_interface_mtu + fi + if [ x$new_ip_address != x -a x$old_ip_address != x$new_ip_address ] || \ + [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then + + /sbin/ip addr add $new_ip_address/$new_subnet_mask \ + ${new_broadcast_arg} \ + dev $interface + + set_ipv4_routes + fi + if [ x$new_ip_address != x$alias_ip_address -a x$alias_ip_address != x ]; + then + /sbin/ip addr add $alias_ip_address/$alias_subnet_mask \ + dev $interface + fi + + netconfig_modify + + if [ x$old_ip_address != x -a x$old_ip_address != x$new_ip_address ]; then + if is_ifup_controlled ; then + ifdown $interface -o dhcp + + write_cached_config_data dhcp4_state "new" $interface + commit_cached_config_data $interface + fi + else + if is_ifup_controlled ; then + write_cached_config_data dhcp4_state "up" $interface + commit_cached_config_data $interface + fi + fi + + set_hostname + + if is_ifup_controlled ; then + # execute ifservice and if-up.d scripts + ifup $interface -o dhcp + + write_cached_config_data dhcp4_state "complete" $interface + commit_cached_config_data $interface + fi + + exit_with_hooks 0 +;; + +EXPIRE|FAIL|RELEASE|STOP) + #################################################################### + if [ x$old_ip_address != x ]; then + if [ "x$STARTMODE" != "xnfsroot" ] ; then + /sbin/ip -4 addr flush dev $interface + fi + fi + if [ x$alias_ip_address != x ]; then + /sbin/ip addr add $alias_ip_address/$alias_subnet_mask \ + dev $interface + fi + + if is_ifup_controlled ; then + write_cached_config_data dhcp4_state "down" $interface + commit_cached_config_data $interface + fi + netconfig_remove + + exit_with_hooks 0 +;; + +TIMEOUT) + #################################################################### + if [ x$alias_ip_address != x ]; then + /sbin/ip addr del $alias_ip_address/$alias_subnet_mask \ + dev $interface + fi + + if [ x$new_ip_address != x -a x$old_ip_address != x$new_ip_address ]; + then + /sbin/ip addr add $new_ip_address/$new_subnet_mask \ + ${new_broadcast_arg} \ + dev $interface + + set -- $(get_ipv4_default_gw) + if [ -n "$1" ] && /sbin/arping -q -c 1 -w 5 -I $interface $1 ; + then + if [ x$new_ip_address != x$alias_ip_address ] && \ + [ x$alias_ip_address != x ]; then + /sbin/ip addr add $alias_ip_address/$alias_subnet_arg + fi + + set_ipv4_routes + + netconfig_modify + + set_hostname + if is_ifup_controlled ; then + # execute ifservice and if-up.d scripts + ifup $interface -o dhcp + + write_cached_config_data dhcp4_state "complete" $interface + commit_cached_config_data $interface + fi + + exit_with_hooks 0 + else + if [ x$old_ip_address != x ]; then + if [ "x$STARTMODE" != "xnfsroot" ] ; then + /sbin/ip -4 addr flush dev $interface + fi + fi + + if is_ifup_controlled ; then + write_cached_config_data dhcp4_state "down" $interface + commit_cached_config_data $interface + fi + netconfig_remove + + exit_with_hooks 1 + fi + fi +;; + + +###################################################################### +## DHCPv6 # +###################################################################### + +PREINIT6) + #################################################################### + if [ "x$STARTMODE" != "xnfsroot" ] ; then + /sbin/ip -6 addr flush dev $interface scope global permanent + fi + /sbin/ip link set $interface up + + # We need to give the kernel some time to get the interface up. + sleep 1 + + exit_with_hooks 0 +;; + +BOUND6|RENEW6|REBIND6|REBOOT6) + #################################################################### + + if [ x$old_ip6_address != x -a x$old_ip6_address != x$new_ip6_address ]; + then + + /sbin/ip addr del "$old_ip6_address/$old_ip6_prefixlen" dev $interface + + if is_ifup_controlled ; then + write_cached_config_data dhcp6_state "new" $interface + commit_cached_config_data $interface + fi + else + if is_ifup_controlled ; then + write_cached_config_data dhcp6_state "up" $interface + commit_cached_config_data $interface + fi + fi + + if [ "x$new_ip6_address" != x -a "x$new_ip6_prefixlen" != x ] ; then + /sbin/ip addr add "$new_ip6_address/$new_ip6_prefixlen" \ + dev $interface scope global + + set_ipv6_routes + fi + + netconfig_modify + if [ x$old_ip6_address != x -a x$old_ip6_address != x$new_ip_address ]; + then + if is_ifup_controlled ; then + /sbin/ifdown $interface -o dhcp + fi + fi + + #set_hostname + if is_ifup_controlled ; then + # execute ifservice and if-up.d scripts + /sbin/ifup $interface -o dhcp + + write_cached_config_data dhcp6_state "complete" $interface + commit_cached_config_data $interface + fi + + exit_with_hooks 0 +;; + +DEPREF6) + #################################################################### + if [ x$new_ip6_address = x -o x$new_ip6_prefixlen = x ] ; then + exit_with_hooks 2 + fi + + /sbin/ip addr change "$new_ip6_address/$new_ip6_prefixlen" \ + dev $interface scope global preferred_lft 0 + + exit_with_hooks 0 +;; + +EXPIRE6|RELEASE6|STOP6) + #################################################################### + if [ x$old_ip6_address != x -a x$old_ip6_prefixlen != x ] ; then + /sbin/ip addr del "$old_ip6_address/$old_ip6_prefixlen" \ + dev $interface + fi + + if is_ifup_controlled ; then + write_cached_config_data dhcp6_state "down" $interface + commit_cached_config_data $interface + fi + netconfig_remove + + exit_with_hooks 0 +;; +esac + +exit_with_hooks 0 diff --git a/dhclient.conf b/dhclient.conf new file mode 100644 index 0000000..9269202 --- /dev/null +++ b/dhclient.conf @@ -0,0 +1,57 @@ +# +# /etc/dhclient.conf -- dhclient configuration file +# See "man dhclient.conf" for further details +# + +###################################################### +# Sometimes, a special configuration is required for +# e.g. Cable Modem providers (@Home -- TCI). +# For example, it may be required to send out a special +# dhcp-client-identifier or to override some settings. +# +# Uncomment and fill in the appropriate settings: +# +#send dhcp-client-identifier "c32423-a" +# or as hex octets +#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; +# +# Note, that hostname is usually send using -H option. +#send host-name "andare.fugue.com"; +# +#supersede domain-name "fugue.com home.vix.com"; +#prepend domain-name-servers 127.0.0.1; +# +##################################################### + +# uncomment to request a specific lease time, otherwise +# the dhcp server will provide its default lease time: +#send dhcp-lease-time 3600; + +# +# define classless static route option +# +option rfc3442-classless-static-routes_raw code 121 = array of unsigned integer 8; + +# Request several well known/usefull dhcp options. +request subnet-mask, broadcast-address, routers, + rfc3442-classless-static-routes, + interface-mtu, host-name, domain-name, + domain-name-servers, nis-domain, nis-servers, + nds-context, nds-servers, nds-tree-name, + netbios-name-servers, netbios-dd-server, + netbios-node-type, netbios-scope, ntp-servers; + +# We request above options, require only the IP configuration: +require subnet-mask; +# All another options (DNS, NTP, NIS, ...) are applied using +# netconfig(8) modules. + +# To enforce the availability of the dns server list, set to: +#require subnet-mask, domain-name-servers; + +timeout 60; +retry 60; +reboot 10; +select-timeout 5; +initial-interval 2; + diff --git a/dhclient6.conf b/dhclient6.conf new file mode 100644 index 0000000..8ca65ab --- /dev/null +++ b/dhclient6.conf @@ -0,0 +1,9 @@ +# Client configuration file example for DHCPv6 + +# The client side command to enable rapid-commit (2 packet exchange) +##send dhcp6.rapid-commit; + +# name-servers and domain-search are requested by default. +# here is the way to request sip-servers-addresses too +also request dhcp6.sip-servers-addresses; + diff --git a/dhcp-3.1-ESV.tar.bz2 b/dhcp-3.1-ESV.tar.bz2 deleted file mode 100644 index b43d62e..0000000 --- a/dhcp-3.1-ESV.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:75faa831bcd8594c621ab48aacf0ae55f676facf205d7e0059f2a0216ac0030a -size 626100 diff --git a/dhcp-3.1.1-dhclient-conf.dif b/dhcp-3.1.1-dhclient-conf.dif deleted file mode 100644 index 6a758c1..0000000 --- a/dhcp-3.1.1-dhclient-conf.dif +++ /dev/null @@ -1,81 +0,0 @@ ---- client/dhclient.conf -+++ client/dhclient.conf 2008/11/11 09:12:22 -@@ -1,36 +1,48 @@ --send host-name "andare.fugue.com"; --send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; -+# -+# /etc/dhclient.conf -- dhclient configuration file -+# see "man dhclient.conf" for further details -+# -+ -+###################################################### -+# Sometimes, a special configuration is required for -+# e.g. Cable Modem providers (@Home -- TCI). -+# For example, it may be required to send out a special -+# dhcp-client-identifier or to override some settings. -+# -+# Uncomment and fill in the appropriate settings: -+# -+#send dhcp-client-identifier "c32423-a" -+# or as hex octets -+#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; -+# -+#send host-name "andare.fugue.com"; -+# -+#supersede domain-name "fugue.com home.vix.com"; -+#prepend domain-name-servers 127.0.0.1; -+# -+##################################################### -+ - send dhcp-lease-time 3600; --supersede domain-name "fugue.com home.vix.com"; --prepend domain-name-servers 127.0.0.1; --request subnet-mask, broadcast-address, time-offset, routers, -- domain-name, domain-name-servers, host-name; --require subnet-mask, domain-name-servers; -+ -+# Request several well known/usefull dhcp options. -+request subnet-mask, broadcast-address, routers, -+ interface-mtu, host-name, domain-name, -+ domain-name-servers, nis-domain, nis-servers, -+ nds-context, nds-servers, nds-tree-name, -+ netbios-name-servers, netbios-dd-server, -+ netbios-node-type, netbios-scope, ntp-servers; -+ -+# We request above options, require only the IP configuration: -+require subnet-mask; -+# All another options (DNS, NTP, NIS, ...) are applied using -+# netconfig(8) modules. -+ -+# To enforce the availability of the dns server list, set to: -+#require subnet-mask, domain-name-servers; -+ - timeout 60; - retry 60; - reboot 10; - select-timeout 5; - initial-interval 2; --script "/etc/dhclient-script"; --media "-link0 -link1 -link2", "link0 link1"; --reject 192.33.137.209; -- --alias { -- interface "ep0"; -- fixed-address 192.5.5.213; -- option subnet-mask 255.255.255.255; --} -- --lease { -- interface "ep0"; -- fixed-address 192.33.137.200; -- medium "link0 link1"; -- option host-name "andare.swiftmedia.com"; -- option subnet-mask 255.255.255.0; -- option broadcast-address 192.33.137.255; -- option routers 192.33.137.250; -- option domain-name-servers 127.0.0.1; -- renew 2 2000/1/12 00:00:01; -- rebind 2 2000/1/12 00:00:01; -- expire 2 2000/1/12 00:00:01; --} -+ diff --git a/dhcp-3.1.1-dhclient-use-script-cmdline.dif b/dhcp-3.1.1-dhclient-use-script-cmdline.dif deleted file mode 100644 index 3af4c88..0000000 --- a/dhcp-3.1.1-dhclient-use-script-cmdline.dif +++ /dev/null @@ -1,17 +0,0 @@ ---- client/dhclient.c -+++ client/dhclient.c 2008/09/08 15:31:00 -@@ -355,6 +355,14 @@ int main (argc, argv, envp) - /* Parse the dhclient.conf file. */ - read_client_conf (); - -+ /* -+ ** Override the script name definition in the config file -+ ** with the one provided as command line argument...: -+ */ -+ if(no_dhclient_script) { -+ top_level_config.script_name = path_dhclient_script; -+ } -+ - /* If the user specified a hostname, send it here and now */ - if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) { - struct parse *cfile = NULL; diff --git a/dhcp-3.1.1-man-includes.dif b/dhcp-3.1.1-man-includes.dif deleted file mode 100644 index 0729ac2..0000000 --- a/dhcp-3.1.1-man-includes.dif +++ /dev/null @@ -1,26 +0,0 @@ ---- dhcpctl/dhcpctl.3 -+++ dhcpctl/dhcpctl.3 2008/09/08 10:02:38 -@@ -425,8 +425,8 @@ that most error checking has been ommitt - #include - #include - --#include --#include -+#include -+#include - - int main (int argc, char **argv) { - dhcpctl_data_string ipaddrstring = NULL; ---- omapip/omapi.3 -+++ omapip/omapi.3 2008/09/08 10:02:38 -@@ -87,8 +87,8 @@ the lease ends. - #include - #include - -- #include -- #include -+ #include -+ #include - - int main (int argc, char **argv) { - dhcpctl_data_string ipaddrstring = NULL; diff --git a/dhcp-3.1.1-omapi-test.c.dif b/dhcp-3.1.1-omapi-test.c.dif deleted file mode 100644 index e0be4ee..0000000 --- a/dhcp-3.1.1-omapi-test.c.dif +++ /dev/null @@ -1,10 +0,0 @@ ---- omapip/test.c -+++ omapip/test.c 2008/09/05 08:24:16 -@@ -40,6 +40,7 @@ - #include - #include - #include -+#include - - int main (int argc, char **argv) - { diff --git a/dhcp-3.1.1-paranoia.dif b/dhcp-3.1.1-paranoia.dif deleted file mode 100644 index 340cba8..0000000 --- a/dhcp-3.1.1-paranoia.dif +++ /dev/null @@ -1,170 +0,0 @@ ---- server/dhcpd.c -+++ server/dhcpd.c 2008/09/05 08:22:38 -@@ -47,6 +47,15 @@ static char url [] = "For info, please v - #include "version.h" - #include - -+#ifdef PARANOIA -+# include -+# include -+/* get around the ISC's declaration of group */ -+#define group real_group -+# include -+#undef group -+#endif -+ - static void usage PROTO ((void)); - - struct iaddr server_identifier; -@@ -225,6 +234,15 @@ int main (argc, argv, envp) - char *traceinfile = (char *)0; - char *traceoutfile = (char *)0; - #endif -+#ifdef PARANOIA -+ char *set_user = NULL; -+ char *set_group = NULL; -+ char *set_chroot = NULL; -+ -+ uid_t set_uid = 0; -+ gid_t set_gid = 0; -+#endif -+ - - /* Make sure that file descriptors 0 (stdin), 1, (stdout), and - 2 (stderr) are open. To do this, we assume that when we -@@ -286,6 +304,20 @@ int main (argc, argv, envp) - daemon = 0; - #endif - log_perror = -1; -+#ifdef PARANOIA -+ } else if (!strcmp (argv [i], "-user")) { -+ if (++i == argc) -+ usage (); -+ set_user = argv [i]; -+ } else if (!strcmp (argv [i], "-group")) { -+ if (++i == argc) -+ usage (); -+ set_group = argv [i]; -+ } else if (!strcmp (argv [i], "-chroot")) { -+ if (++i == argc) -+ usage (); -+ set_chroot = argv [i]; -+#endif - } else if (!strcmp (argv [i], "-s")) { - if (++i == argc) - usage (); -@@ -347,7 +379,7 @@ int main (argc, argv, envp) - log_fatal ("Insufficient memory to %s %s: %s", - "record interface", argv [i], - isc_result_totext (result)); -- strcpy (tmp -> name, argv [i]); -+ strncpy (tmp -> name, argv [i], sizeof(tmp->name)-1); - if (interfaces) { - interface_reference (&tmp -> next, - interfaces, MDL); -@@ -412,6 +444,66 @@ int main (argc, argv, envp) - } - } - -+#ifdef PARANOIA -+ /* get user and group info if those options were given */ -+ if (set_user) { -+ struct passwd *tmp_pwd; -+ -+ /* -+ ** I query for the real UID and not for the effective UID -+ ** just to force the user to run this server as root and -+ ** not setting it suid. It should be a paranoia patch and -+ ** not a teletubbie patch. *eg* -+ ** Note: That the user is still able to set it suid! *zitter* -+ ** thomas@suse.de -+ */ -+ if (getuid()) -+ error ("you must be root to set user"); -+ -+ if (!(tmp_pwd = getpwnam(set_user))) -+ error ("no such user: %s", set_user); -+ -+ set_uid = tmp_pwd->pw_uid; -+ -+ /* use the user's group as the default gid */ -+ if (!set_group) -+ set_gid = tmp_pwd->pw_gid; -+ -+ } -+ -+ if (set_group) { -+/* get around the ISC's declaration of group */ -+#define group real_group -+ struct group *tmp_grp; -+ -+ /* -+ ** getuid() instead of geteuid(), see above -+ */ -+ if (getuid()) -+ error ("you must be root to set group"); -+ -+ if (!(tmp_grp = getgrnam(set_group))) -+ error ("no such group: %s", set_group); -+ -+ set_gid = tmp_grp->gr_gid; -+#undef group -+ } -+ -+ if (set_chroot) { -+ if (getuid()) /* see above */ -+ error ("you must be root to use chroot"); -+ -+ if (chroot(set_chroot) != 0) { -+ error ("chroot(\"%s\"): %s", set_chroot, -+ strerror(errno)); -+ } -+ if (chdir ("/") != 0) { -+ /* probably permission denied */ -+ error ("chdir(\"/\"): %s", strerror(errno)); -+ } -+ } -+#endif /* PARANOIA */ -+ - remote_port = htons (ntohs (local_port) + 1); - - if (server) { -@@ -601,6 +693,27 @@ int main (argc, argv, envp) - omapi_set_int_value ((omapi_object_t *)dhcp_control_object, - (omapi_object_t *)0, "state", server_running); - -+#ifdef PARANOIA -+ /* change uid to the specified one */ -+ -+ /* -+ ** common failure: forget to drop supplementary GID'S ;-> -+ ** thomas@suse.de -+ */ -+ -+ if (set_gid) { -+ if(setgroups(0, NULL) < 0) -+ error("couldn't drop supplementary groups!"); -+ if (setgid (set_gid) != 0) -+ error ("couldn't set gid to %d", set_gid); -+ } -+ -+ if (set_uid) { -+ if (setuid (set_uid) != 0) -+ error ("couldn't set uid to %d", set_uid); -+ } -+#endif -+ - /* Receive packets and dispatch them... */ - dispatch (); - -@@ -879,6 +992,10 @@ static void usage () - - log_fatal ("Usage: dhcpd [-p ] [-d] [-f]%s%s%s%s", - "\n [-cf config-file] [-lf lease-file]", -+#ifdef PARANOIA -+ "\n [-user ] [-group ]", -+ "\n [-chroot ]", -+#endif - #if defined (TRACING) - "\n [-tf trace-output-file]", - "\n [-play trace-input-file]", diff --git a/dhcp-3.1.1-paths.dif b/dhcp-3.1.1-paths.dif deleted file mode 100644 index c673f93..0000000 --- a/dhcp-3.1.1-paths.dif +++ /dev/null @@ -1,148 +0,0 @@ ---- includes/cf/linux.h -+++ includes/cf/linux.h 2008/09/08 09:56:54 -@@ -75,7 +75,7 @@ extern int h_errno; - - #include /* gettimeofday()*/ - --/* Databases go in /var/state/dhcp. It would also be valid to put them -+/* Databases go in /var/lib/dhcp. It would also be valid to put them - in /var/state/misc - indeed, given that there's only one lease file, it - would probably be better. However, I have some ideas for optimizing - the lease database that may result in a _lot_ of smaller files being -@@ -83,11 +83,11 @@ extern int h_errno; - directory. */ - - #ifndef _PATH_DHCPD_DB --#define _PATH_DHCPD_DB "/var/state/dhcp/dhcpd.leases" -+#define _PATH_DHCPD_DB "/var/lib/dhcp/db/dhcpd.leases" - #endif - - #ifndef _PATH_DHCLIENT_DB --#define _PATH_DHCLIENT_DB "/var/state/dhcp/dhclient.leases" -+#define _PATH_DHCLIENT_DB "/var/lib/dhcp/dhclient.leases" - #endif - - /* Varargs stuff... */ ---- includes/dhcpd.h -+++ includes/dhcpd.h 2008/09/08 09:56:54 -@@ -1062,7 +1062,7 @@ typedef unsigned char option_mask [16]; - #endif - - #ifndef _PATH_DHCPD_DB --#define _PATH_DHCPD_DB "/etc/dhcpd.leases" -+#define _PATH_DHCPD_DB "/var/lib/dhcp/db/dhcpd.leases" - #endif - - #ifndef _PATH_DHCPD_PID -@@ -1083,7 +1083,7 @@ typedef unsigned char option_mask [16]; - #endif - - #ifndef _PATH_DHCLIENT_DB --#define _PATH_DHCLIENT_DB "/etc/dhclient.leases" -+#define _PATH_DHCLIENT_DB "/var/run/dhclient.leases" - #endif - - #ifndef _PATH_RESOLV_CONF ---- Makefile.conf -+++ Makefile.conf 2008/09/08 09:56:58 -@@ -42,8 +42,10 @@ CATMANPAGES = - ETC = /etc - VARRUN = /var/run - VARDB = /var/db --LIBDIR=/usr/local/lib --INCDIR=/usr/local/include -+ifeq (${LIBDIR},) -+LIBDIR=/usr/lib -+endif -+INCDIR=/usr/include - LIBS = - COPTS = $(BINDDEF) $(CC_OPTIONS) - DEBUG = -g -@@ -277,17 +279,17 @@ MINORVERSION=MinorVersion - #COPTS = -DLINUX_MAJOR=$(MAJORVERSION) -DLINUX_MINOR=$(MINORVERSION) \ - # $(BINDDEF) $(CC_OPTIONS) - #CF = cf/linux.h --#ADMMANDIR = /usr/man/man8 -+#ADMMANDIR = /usr/share/man/man8 - #ADMMANEXT = .8 --#FFMANDIR = /usr/man/man5 -+#FFMANDIR = /usr/share/man/man5 - #FFMANEXT = .5 --#LIBMANDIR = /usr/man/man3 -+#LIBMANDIR = /usr/share/man/man3 - #LIBMANEXT = .3 --#USRMANDIR = /usr/man/man1 -+#USRMANDIR = /usr/share/man/man1 - #USRMANEXT = .1 - #MANCAT = man - #VARRUN = /var/run --#VARDB = /var/state/dhcp -+#VARDB = /var/lib/dhcp - #SCRIPT=linux - ##--linux-2.0-- - -@@ -296,17 +298,17 @@ MINORVERSION=MinorVersion - #COPTS = -DLINUX_MAJOR=$(MAJORVERSION) -DLINUX_MINOR=$(MINORVERSION) \ - # $(BINDDEF) $(CC_OPTIONS) - #CF = cf/linux.h --#ADMMANDIR = /usr/man/man8 -+#ADMMANDIR = /usr/share/man/man8 - #ADMMANEXT = .8 --#FFMANDIR = /usr/man/man5 -+#FFMANDIR = /usr/share/man/man5 - #FFMANEXT = .5 --#LIBMANDIR = /usr/man/man3 -+#LIBMANDIR = /usr/share/man/man3 - #LIBMANEXT = .3 --#USRMANDIR = /usr/man/man1 -+#USRMANDIR = /usr/share/man/man1 - #USRMANEXT = .1 - #MANCAT = man - #VARRUN = /var/run --#VARDB = /var/state/dhcp -+#VARDB = /var/lib/dhcp - #SCRIPT=linux - ##--linux-2.1-- - -@@ -315,20 +317,36 @@ MINORVERSION=MinorVersion - #COPTS = -DLINUX_MAJOR=$(MAJORVERSION) -DLINUX_MINOR=$(MINORVERSION) \ - # $(BINDDEF) $(CC_OPTIONS) - #CF = cf/linux.h --#ADMMANDIR = /usr/man/man8 -+#ADMMANDIR = /usr/share/man/man8 - #ADMMANEXT = .8 --#FFMANDIR = /usr/man/man5 -+#FFMANDIR = /usr/share/man/man5 - #FFMANEXT = .5 --#LIBMANDIR = /usr/man/man3 -+#LIBMANDIR = /usr/share/man/man3 - #LIBMANEXT = .3 --#USRMANDIR = /usr/man/man1 -+#USRMANDIR = /usr/share/man/man1 - #USRMANEXT = .1 - #MANCAT = man - #VARRUN = /var/run --#VARDB = /var/state/dhcp -+#VARDB = /var/lib/dhcp - #SCRIPT=linux - ##--linux-2.2-- - -+## Linux 2.4 -+##--linux-2.4-- -+#COPTS = -DLINUX_MAJOR=$(MAJORVERSION) -DLINUX_MINOR=$(MINORVERSION) $(BINDDEF) -+#CF = cf/linux.h -+#ADMMANDIR = /usr/share/man/man8 -+#ADMMANEXT = .8 -+#FFMANDIR = /usr/share/man/man5 -+#FFMANEXT = .5 -+#LIBMANDIR = /usr/share/man/man3 -+#LIBMANEXT = .3 -+#MANCAT = man -+#VARRUN = /var/run -+#VARDB = /var/lib/dhcp -+#SCRIPT=linux -+##--linux-2.4-- -+ - ## SCO UnixWare 7 - ##--uw7-- - #CF = cf/uw7.h diff --git a/dhcp-3.1.1-pie.dif b/dhcp-3.1.1-pie.dif deleted file mode 100644 index d8b2781..0000000 --- a/dhcp-3.1.1-pie.dif +++ /dev/null @@ -1,45 +0,0 @@ ---- client/Makefile.dist -+++ client/Makefile.dist -@@ -128,6 +128,6 @@ - - - dhclient: $(OBJS) $(DHCPLIB) -- $(CC) $(LFLAGS) -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS) -+ $(CC) $(LFLAGS) -pie -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS) - - # Dependencies (semi-automatically-generated) ---- dhcpctl/Makefile.dist -+++ dhcpctl/Makefile.dist -@@ -37,10 +37,10 @@ - all: libdhcpctl.a omshell cltest $(CATMANPAGES) - - omshell: omshell.o $(DHCPCTLLIBS) -- $(CC) $(DEBUG) $(LFLAGS) -o omshell omshell.o $(DHCPCTLLIBS) $(LIBS) -+ $(CC) $(DEBUG) $(LFLAGS) -pie -o omshell omshell.o $(DHCPCTLLIBS) $(LIBS) - - cltest: cltest.o $(DHCPCTLLIBS) -- $(CC) $(DEBUG) $(LFLAGS) -o cltest cltest.o $(DHCPCTLLIBS) $(LIBS) -+ $(CC) $(DEBUG) $(LFLAGS) -pie -o cltest cltest.o $(DHCPCTLLIBS) $(LIBS) - - libdhcpctl.a: $(OBJ) - rm -f libdhcpctl.a ---- relay/Makefile.dist -+++ relay/Makefile.dist -@@ -83,6 +83,6 @@ - -e "s#RUNDIR#$(VARRUN)#" < dhcrelay.8 >dhcrelay.man8 - - dhcrelay: dhcrelay.o $(DHCPLIB) -- $(CC) $(LFLAGS) -o $(PROG) dhcrelay.o $(DHCPLIB) $(LIBS) -+ $(CC) $(LFLAGS) -pie -o $(PROG) dhcrelay.o $(DHCPLIB) $(LIBS) - - # Dependencies (semi-automatically-generated) ---- server/Makefile.dist -+++ server/Makefile.dist -@@ -103,6 +103,6 @@ - -e "s#RUNDIR#$(VARRUN)#g" < dhcpd.leases.5 >dhcpd.leases.man5 - - dhcpd: $(OBJS) $(COBJ) $(DHCPLIB) -- $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) -+ $(CC) $(LFLAGS) -pie -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) - - # Dependencies (semi-automatically-generated) diff --git a/dhcp-3.1.3-dhclient-conf.bnc516459.dif b/dhcp-3.1.3-dhclient-conf.bnc516459.dif deleted file mode 100644 index e3e16d6..0000000 --- a/dhcp-3.1.3-dhclient-conf.bnc516459.dif +++ /dev/null @@ -1,13 +0,0 @@ ---- client/dhclient.conf -+++ client/dhclient.conf 2009/12/14 21:31:00 -@@ -22,7 +22,9 @@ - # - ##################################################### - --send dhcp-lease-time 3600; -+# uncomment to request a specific lease time, otherwise -+# the dhcp server will provide its default lease time: -+#send dhcp-lease-time 3600; - - # Request several well known/usefull dhcp options. - request subnet-mask, broadcast-address, routers, diff --git a/dhcp-3.1.3-dhclient-script.bnc555095.dif b/dhcp-3.1.3-dhclient-script.bnc555095.dif deleted file mode 100644 index 532fba8..0000000 --- a/dhcp-3.1.3-dhclient-script.bnc555095.dif +++ /dev/null @@ -1,73 +0,0 @@ ---- client/scripts/linux -+++ client/scripts/linux 2009/12/14 22:29:11 -@@ -28,7 +28,11 @@ - # logs entire run of dhclient-script to /var/log/dhclient-script, - # if DHCLIENT_DEBUG is set in sysconfig/network/dhcp - # --eval `grep "^DHCLIENT_DEBUG=" /etc/sysconfig/network/dhcp 2>/dev/null` -+SYSCONFIG_CFG_DIR="/etc/sysconfig/network" -+SYSCONFIG_RUN_DIR=`. "$SYSCONFIG_CFG_DIR/scripts/functions" \ -+ 2>/dev/null && echo "$RUN_FILES_BASE"` -+SYSCONFIG_RUN_DIR=${SYSCONFIG_RUN_DIR:-/dev/.sysconfig/network} -+eval `grep "^DHCLIENT_DEBUG=" "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` - if [ "$DHCLIENT_DEBUG" = yes ]; then - set -a # allexport - ( -@@ -90,21 +94,21 @@ netconfig_remove() { - } - set_default_gw_route() - { -- if test -f /etc/sysconfig/network/ifcfg-${interface} -o \ -- -f /dev/shm/sysconfig/if-${interface} ; -+ if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ -+ -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; - then -- if grep -qs '^primary=yes' /dev/shm/sysconfig/if-${interface} 2>/dev/null ; -+ if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; - then - eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -- /etc/sysconfig/network/dhcp -- /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/dhcp" -+ "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` - else - eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -- /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` - fi - else - eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -- /etc/sysconfig/network/dhcp 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` - fi - if [ "$DHCLIENT_SET_DEFAULT_ROUTE" = yes ] ; then - for router in $new_routers; do -@@ -130,21 +134,21 @@ set_default_gw_route() - } - set_hostname() - { -- if test -f /etc/sysconfig/network/ifcfg-${interface} -o \ -- -f /dev/shm/sysconfig/if-${interface} ; -+ if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ -+ -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; - then -- if grep -qs '^primary=yes' /dev/shm/sysconfig/if-${interface} 2>/dev/null ; -+ if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; - then - eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -- /etc/sysconfig/network/dhcp -- /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/dhcp" -+ "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` - else - eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -- /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" 2>/dev/null` - fi - else - eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -- /etc/sysconfig/network/dhcp 2>/dev/null` -+ "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` - fi - if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then - current_hostname=`hostname` diff --git a/dhcp-3.1.3-dhclient-script.bnc585380.dif b/dhcp-3.1.3-dhclient-script.bnc585380.dif deleted file mode 100644 index 4c837f0..0000000 --- a/dhcp-3.1.3-dhclient-script.bnc585380.dif +++ /dev/null @@ -1,156 +0,0 @@ ---- client/scripts/linux -+++ client/scripts/linux 2010/03/04 13:30:09 -@@ -29,8 +29,7 @@ - # if DHCLIENT_DEBUG is set in sysconfig/network/dhcp - # - SYSCONFIG_CFG_DIR="/etc/sysconfig/network" --SYSCONFIG_RUN_DIR=`. "$SYSCONFIG_CFG_DIR/scripts/functions" \ -- 2>/dev/null && echo "$RUN_FILES_BASE"` -+. "$SYSCONFIG_CFG_DIR/scripts/functions" - SYSCONFIG_RUN_DIR=${SYSCONFIG_RUN_DIR:-/dev/.sysconfig/network} - eval `grep "^DHCLIENT_DEBUG=" "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` - if [ "$DHCLIENT_DEBUG" = yes ]; then -@@ -40,7 +39,7 @@ if [ "$DHCLIENT_DEBUG" = yes ]; then - echo "$0 $*" - date - echo '----------------' -- set -+ env - echo '----------------' - ) >> /var/log/dhclient-script.log - exec 2>> /var/log/dhclient-script.log -@@ -48,6 +47,10 @@ if [ "$DHCLIENT_DEBUG" = yes ]; then - set -x - fi - -+is_ifup_controlled() -+{ -+ test -f "$SYSCONFIG_RUN_DIR/if-${interface}" -+} - # netconfig makes all "additional" modifications as DNS or NTP - use_netconfig() { - test -x /sbin/netconfig -@@ -94,9 +97,7 @@ netconfig_remove() { - } - set_default_gw_route() - { -- if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ -- -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; -- then -+ if is_ifup_controlled ; then - if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; - then - eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -@@ -134,9 +135,7 @@ set_default_gw_route() - } - set_hostname() - { -- if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ -- -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; -- then -+ if is_ifup_controlled ; then - if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; - then - eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -@@ -157,13 +156,14 @@ set_hostname() - [ "x${current_hostname%%.*}" = "xlocalhost" ] || \ - [ "x${current_hostname%%.*}" != "x${new_host_name%%.*}" ]; then - -- if [ "x${new_host_name%%.*}" != x ]; then -+ if [ "x${new_host_name%%.*}" != "x" ]; then - hostname "${new_host_name%%.*}" - else - if [ -x /usr/bin/host ] ; then - if out=`host -W 2 "$new_ip_address" 2>/dev/null` ; then - _hostname="`echo "$out" | sed 's:^.* ::; s:\..*::'`" -- if [ "x${_hostname}" != x ]; then -+ if [ "x${_hostname}" != "x" -a \ -+ "x${_hostname}" != "x${current_hostname%%.*}" ]; then - hostname "${_hostname}" - fi - fi -@@ -171,6 +171,20 @@ set_hostname() - fi - fi - fi -+ if is_ifup_controlled ; then -+ # check regardless the DHCLIENT_SET_HOSTNAME setting -+ # and whether we've set it above or not, because when -+ # it changed, we've to handle it anyway... -+ local OLD_HOSTNAME=`read_cached_config_data hostname $interface` -+ local CUR_HOSTNAME=`hostname 2>/dev/null` -+ if test "x$OLD_HOSTNAME" != "x$CUR_HOSTNAME" ; then -+ write_cached_config_data hostname "$CUR_HOSTNAME" $interface -+ commit_cached_config_data $interface -+ -+ # reload syslog so it knows the new hostname -+ /etc/init.d/syslog reload -+ fi -+ fi - } - - resolv_conf_dhclient="/var/lib/dhcp/resolv.conf.dhclient.$interface" -@@ -300,7 +314,15 @@ if [ x$reason = xBOUND ] || [ x$reason = - # and clear the ARP cache. - ifconfig $interface inet 0 - -+ if is_ifup_controlled ; then -+ write_cached_config_data dhcp4_state "new" $interface -+ commit_cached_config_data $interface -+ fi -+ elif is_ifup_controlled ; then -+ write_cached_config_data dhcp4_state "up" $interface -+ commit_cached_config_data $interface - fi -+ - if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ - [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then - -@@ -328,7 +350,20 @@ if [ x$reason = xBOUND ] || [ x$reason = - make_resolv_conf - fi - -+ if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then -+ if is_ifup_controlled ; then -+ ifdown $interface -o dhcp -+ fi -+ fi -+ - set_hostname -+ if is_ifup_controlled ; then -+ # execute ifservice and if-up.d scripts -+ ifup $interface -o dhcp -+ -+ write_cached_config_data dhcp4_state "complete" $interface -+ commit_cached_config_data $interface -+ fi - - exit_with_hooks 0 - fi -@@ -376,12 +411,26 @@ if [ x$reason = xTIMEOUT ]; then - make_resolv_conf - fi - -+ set_hostname -+ if is_ifup_controlled ; then -+ # execute ifservice and if-up.d scripts -+ ifup $interface -o dhcp -+ -+ write_cached_config_data dhcp4_state "complete" $interface -+ commit_cached_config_data $interface -+ fi -+ - exit_with_hooks 0 - fi - ifconfig $interface inet 0 - exit_with_hooks 1 - fi - -+if is_ifup_controlled ; then -+ write_cached_config_data dhcp4_state "down" $interface -+ commit_cached_config_data $interface -+fi -+ - if use_netconfig ; then - netconfig_remove - else diff --git a/dhcp-3.1.3-dhclient-script.dif b/dhcp-3.1.3-dhclient-script.dif deleted file mode 100644 index 4605d07..0000000 --- a/dhcp-3.1.3-dhclient-script.dif +++ /dev/null @@ -1,383 +0,0 @@ ---- client/dhclient-script.8 -+++ client/dhclient-script.8 2009/10/16 08:10:52 -@@ -45,9 +45,10 @@ any, and also called once if no valid le - This script is not meant to be customized by the end user. If local - customizations are needed, they should be possible using the enter and - exit hooks provided (see HOOKS for details). These hooks will allow the --user to override the default behaviour of the client in creating a -+user to override the default behaviour of the client in applying of -+additional settings like DNS (e.g. creating a - .B /etc/resolv.conf --file. -+file), NTP or YP to the system. - .PP - No standard client script exists for some operating systems, even though - the actual client may work, so a pioneering user may well need to create -@@ -59,12 +60,43 @@ customizing - .B ETCDIR/dhclient.conf - or using the enter and exit hooks, please submit a bug report. - .SH HOOKS --When it starts, the client script first defines a shell function, --.B make_resolv_conf , --which is later used to create the -+When it starts, the client script first defines several shell functions: -+.BR use_netconfig , -+.BR netconfig_modify , -+.BR netconfig_remove , -+.BR make_resolv_conf , -+and -+.BR restore_resolv_conf . -+These functions are later used to apply DNS, NTP, YP, and other additional -+settings to the system. -+ -+The -+.B use_netconfig -+returns true (0), when the /sbin/netconfig script is installed and enables -+the use of the -+.B netconfig_modify -+and -+.B netconfig_remove -+functions. -+.br -+Otherwise, the -+.BR make_resolv_conf -+and -+.BR restore_resolv_conf -+functions are used. These functions are modified to create -+/var/lib/dhcp/resolv.conf.dhclient.$interface files only -+instead of the - .B /etc/resolv.conf --file. To override the default behaviour, redefine this function in --the enter hook script. -+file. -+To override the default behaviour, redefine these function in the enter -+hook script. Before you start doing this, consider to implement own -+netconfig modules. -+ -+.IR Note : -+Note, that since openSUSE 11.1, the modify_resolvconf script / mechanizm -+is obsoleted by netconfig and not shipped or supported any more. -+See the netconfig(8) manual page for more informations. -+ - .PP - On after defining the make_resolv_conf function, the client script checks - for the presence of an executable -@@ -221,7 +253,7 @@ valid, this shouldn't cause any real pro - confusing. - .SH SEE ALSO - dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and --dhclient.leases(5). -+dhclient.leases(5) and netconfig(8). - .SH AUTHOR - .B dhclient-script(8) - has been written for Internet Systems Consortium ---- client/scripts/linux -+++ client/scripts/linux 2009/10/16 08:16:11 -@@ -22,25 +22,183 @@ - # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious - # of the $1 in its args. - -+ -+# Debugging: -+# -+# logs entire run of dhclient-script to /var/log/dhclient-script, -+# if DHCLIENT_DEBUG is set in sysconfig/network/dhcp -+# -+eval `grep "^DHCLIENT_DEBUG=" /etc/sysconfig/network/dhcp 2>/dev/null` -+if [ "$DHCLIENT_DEBUG" = yes ]; then -+ set -a # allexport -+ ( -+ echo '****************' -+ echo "$0 $*" -+ date -+ echo '----------------' -+ set -+ echo '----------------' -+ ) >> /var/log/dhclient-script.log -+ exec 2>> /var/log/dhclient-script.log -+ set +a -+ set -x -+fi -+ -+# netconfig makes all "additional" modifications as DNS or NTP -+use_netconfig() { -+ test -x /sbin/netconfig -+} -+netconfig_modify() { -+ if test -x /sbin/netconfig -a -n "$interface" ; then -+ { -+ echo "INTERFACE='$interface'" -+ for v in ${!new_*}; do -+ case $v in -+ (new_ip_address) k='IPADDR' ;; -+ (new_subnet_mask) k='NETMASK' ;; -+ (new_network_number) k='NETWORK' ;; -+ (new_broadcast_address) k='BROADCAST' ;; -+ (new_interface_mtu) k='MTU' ;; -+ # (new_static_routes) k='ROUTES' ;; -+ (new_routers) k='GATEWAYS' ;; -+ (new_host_name) k='HOSTNAME' ;; -+ (new_domain_search) k='DNSSEARCH' ;; -+ (new_domain_name) k='DNSDOMAIN' ;; -+ (new_domain_name_servers) k='DNSSERVERS' ;; -+ (new_ntp_servers) k='NTPSERVERS' ;; -+ (new_nis_domain) k='NISDOMAIN' ;; -+ (new_nis_servers) k='NISSERVERS' ;; -+ (new_root_path) k='ROOTPATH' ;; -+ (new_dhcp_server_identifier)k='DHCPSID' ;; -+ (new_lpr_servers) k='LPRSERVER' ;; -+ (new_log_servers) k='LOGSERVER' ;; -+ (new_netbios_dd_server) k='NETBIOSDDSERVER' ;; -+ (new_netbios_name_servers) k='NETBIOSNAMESERVER' ;; -+ (new_netbios_node_type) k='NETBIOSNODETYPE' ;; -+ (new_netbios_scope) k='NETBIOSSCOPE' ;; -+ (*) k="dhclient_${v#new_}" ;; -+ esac -+ [ "k${k}" != k ] && echo "${k}='${!v}'" -+ done -+ } | /sbin/netconfig modify -s "dhclient3" -i "$interface" -+ fi -+} -+netconfig_remove() { -+ if test -x /sbin/netconfig -a -n "$interface" ; then -+ /sbin/netconfig remove -s "dhclient3" -i "$interface" /dev/null ; -+ then -+ eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -+ /etc/sysconfig/network/dhcp -+ /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ else -+ eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -+ /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ fi -+ else -+ eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ -+ /etc/sysconfig/network/dhcp 2>/dev/null` -+ fi -+ if [ "$DHCLIENT_SET_DEFAULT_ROUTE" = yes ] ; then -+ for router in $new_routers; do -+ err=`route add default gw $router $metric_arg dev $interface 2>&1` && break || \ -+ case "$err" in -+ SIOCADDRT:*) -+ # The gateway seems to be not reachable via local network -+ # route (implicitely created by ifconfig based on the IP -+ # an netmask provided by dhcp). -+ # Check this, set an explicit host route to the gateway -+ # over the current interface and try again (bnc#266215). -+ matches=$(test -x /sbin/ip && \ -+ /sbin/ip -f inet -o route list match $router | \ -+ grep -v ^default | grep -c -v "^$" 2>/dev/null) -+ if test -n "$matches" -a $(($matches)) -eq 0 ; then -+ route add -host $router dev $interface && \ -+ route add default gw $router $metric_arg dev $interface && break -+ fi -+ ;; -+ esac -+ done -+ fi -+} -+set_hostname() -+{ -+ if test -f /etc/sysconfig/network/ifcfg-${interface} -o \ -+ -f /dev/shm/sysconfig/if-${interface} ; -+ then -+ if grep -qs '^primary=yes' /dev/shm/sysconfig/if-${interface} 2>/dev/null ; -+ then -+ eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -+ /etc/sysconfig/network/dhcp -+ /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ else -+ eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -+ /etc/sysconfig/network/ifcfg-${interface} 2>/dev/null` -+ fi -+ else -+ eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ -+ /etc/sysconfig/network/dhcp 2>/dev/null` -+ fi -+ if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then -+ current_hostname=`hostname` -+ if [ "x${current_hostname%%.*}" = "x" ] || \ -+ [ "x${current_hostname%%.*}" = "x(none)" ] || \ -+ [ "x${current_hostname%%.*}" = "xlocalhost" ] || \ -+ [ "x${current_hostname%%.*}" != "x${new_host_name%%.*}" ]; then -+ -+ if [ "x${new_host_name%%.*}" != x ]; then -+ hostname "${new_host_name%%.*}" -+ else -+ if [ -x /usr/bin/host ] ; then -+ if out=`host -W 2 "$new_ip_address" 2>/dev/null` ; then -+ _hostname="`echo "$out" | sed 's:^.* ::; s:\..*::'`" -+ if [ "x${_hostname}" != x ]; then -+ hostname "${_hostname}" -+ fi -+ fi -+ fi -+ fi -+ fi -+ fi -+} -+ -+resolv_conf_dhclient="/var/lib/dhcp/resolv.conf.dhclient.$interface" - make_resolv_conf() { -+ ### -+ ### note: this function is never used by default -+ ### and it has been modified to create the -+ ### /var/lib/dhcp/resolv.conf.dhclient.$interface -+ ### file instead /etc/resolv.conf. -+ ### - if [ x"$new_domain_name_servers" != x ]; then -- cat /dev/null > /etc/resolv.conf.dhclient -- chmod 644 /etc/resolv.conf.dhclient -+ cat /dev/null > "$resolv_conf_dhclient" -+ chmod 644 "$resolv_conf_dhclient" - if [ x"$new_domain_search" != x ]; then -- echo search $new_domain_search >> /etc/resolv.conf.dhclient -+ echo search $new_domain_search >> "$resolv_conf_dhclient" - elif [ x"$new_domain_name" != x ]; then - # Note that the DHCP 'Domain Name Option' is really just a domain - # name, and that this practice of using the domain name option as - # a search path is both nonstandard and deprecated. -- echo search $new_domain_name >> /etc/resolv.conf.dhclient -+ echo search $new_domain_name >> "$resolv_conf_dhclient" - fi - for nameserver in $new_domain_name_servers; do -- echo nameserver $nameserver >>/etc/resolv.conf.dhclient -+ echo nameserver $nameserver >> "$resolv_conf_dhclient" - done - -- mv /etc/resolv.conf.dhclient /etc/resolv.conf -+ ### mv /etc/resolv.conf.dhclient /etc/resolv.conf - fi - } -+restore_resolv_conf() -+{ -+ rm -f "$resolv_conf_dhclient" -+} - - # Must be used on exit. Invokes the local dhcp client exit hooks, if any. - exit_with_hooks() { -@@ -84,7 +242,12 @@ if [ x$alias_subnet_mask != x ]; then - alias_subnet_arg="netmask $alias_subnet_mask" - fi - if [ x$new_interface_mtu != x ]; then -- mtu_arg="mtu $new_interface_mtu" -+ if [ $(( $new_interface_mtu )) -lt 576 ] ; then -+ # 68 is the minimal legal value, but 576 the real life minimum -+ unset new_interface_mtu -+ else -+ mtu_arg="mtu $new_interface_mtu" -+ fi - fi - if [ x$IF_METRIC != x ]; then - metric_arg="metric $IF_METRIC" -@@ -122,15 +285,6 @@ fi - - if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ - [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then -- current_hostname=`hostname` -- if [ x$current_hostname = x ] || \ -- [ x$current_hostname = "x(none)" ] || \ -- [ x$current_hostname = xlocalhost ] || \ -- [ x$current_hostname = x$old_host_name ]; then -- if [ x$new_host_name != x$old_host_name ]; then -- hostname "$new_host_name" -- fi -- fi - - if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ - [ x$alias_ip_address != x$old_ip_address ]; then -@@ -140,7 +294,7 @@ if [ x$reason = xBOUND ] || [ x$reason = - if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then - # IP address changed. Bringing down the interface will delete all routes, - # and clear the ARP cache. -- ifconfig $interface inet 0 down -+ ifconfig $interface inet 0 - - fi - if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ -@@ -153,17 +307,25 @@ if [ x$reason = xBOUND ] || [ x$reason = - ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then - route add -net $new_network_number $new_subnet_arg dev $interface - fi -- for router in $new_routers; do -- route add default gw $router $metric_arg dev $interface -- done -+ -+ set_default_gw_route - fi -+ - if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; - then - ifconfig $interface:0- inet 0 - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg - route add -host $alias_ip_address $interface:0 - fi -- make_resolv_conf -+ -+ if use_netconfig ; then -+ netconfig_modify -+ else -+ make_resolv_conf -+ fi -+ -+ set_hostname -+ - exit_with_hooks 0 - fi - -@@ -175,7 +337,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason - fi - if [ x$old_ip_address != x ]; then - # Shut down interface, which will delete routes and clear arp cache. -- ifconfig $interface inet 0 down -+ ifconfig $interface inet 0 - fi - if [ x$alias_ip_address != x ]; then - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg -@@ -190,7 +352,7 @@ if [ x$reason = xTIMEOUT ]; then - fi - ifconfig $interface inet $new_ip_address $new_subnet_arg \ - $new_broadcast_arg $mtu_arg -- set $new_routers -+ set -- $new_routers - if ping -q -c 1 $1; then - if [ x$new_ip_address != x$alias_ip_address ] && \ - [ x$alias_ip_address != x ]; then -@@ -201,14 +363,25 @@ if [ x$reason = xTIMEOUT ]; then - ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then - route add -net $new_network_number - fi -- for router in $new_routers; do -- route add default gw $router $metric_arg dev $interface -- done -- make_resolv_conf -+ -+ set_default_gw_route -+ -+ if use_netconfig ; then -+ netconfig_modify -+ else -+ make_resolv_conf -+ fi -+ - exit_with_hooks 0 - fi -- ifconfig $interface inet 0 down -+ ifconfig $interface inet 0 - exit_with_hooks 1 - fi - -+if use_netconfig ; then -+ netconfig_remove -+else -+ restore_resolv_conf -+fi -+ - exit_with_hooks 0 diff --git a/dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 b/dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 deleted file mode 100644 index efa83f1..0000000 --- a/dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9d652eebb6a2d447fbc85635bb6c64211434c2dd9ec4862017d69871e5dc20f0 -size 44910 diff --git a/dhcp-4.1.1-default-paths.diff b/dhcp-4.1.1-default-paths.diff new file mode 100644 index 0000000..16247ea --- /dev/null +++ b/dhcp-4.1.1-default-paths.diff @@ -0,0 +1,32 @@ +diff --git a/includes/dhcpd.h b/includes/dhcpd.h +index 90f8a73..6fa5b9e 100644 +--- a/includes/dhcpd.h ++++ b/includes/dhcpd.h +@@ -1285,11 +1285,11 @@ typedef unsigned char option_mask [16]; + #endif /* DEBUG */ + + #ifndef _PATH_DHCPD_DB +-#define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases" ++#define _PATH_DHCPD_DB LOCALSTATEDIR"/lib/dhcp/db/dhcpd.leases" + #endif + + #ifndef _PATH_DHCPD6_DB +-#define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases" ++#define _PATH_DHCPD6_DB LOCALSTATEDIR"/lib/dhcp6/db/dhcpd6.leases" + #endif + + #ifndef _PATH_DHCPD_PID +@@ -1319,11 +1319,11 @@ typedef unsigned char option_mask [16]; + #endif + + #ifndef _PATH_DHCLIENT_DB +-#define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases" ++#define _PATH_DHCLIENT_DB LOCALSTATEDIR"/lib/dhcp/dhclient.leases" + #endif + + #ifndef _PATH_DHCLIENT6_DB +-#define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases" ++#define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/lib/dhcp6/dhclient6.leases" + #endif + + #ifndef _PATH_RESOLV_CONF diff --git a/dhcp-3.1.1-dhclient-exec-filedes.dif b/dhcp-4.1.1-dhclient-exec-filedes.dif similarity index 63% rename from dhcp-3.1.1-dhclient-exec-filedes.dif rename to dhcp-4.1.1-dhclient-exec-filedes.dif index aa24919..ef6fe7c 100644 --- a/dhcp-3.1.1-dhclient-exec-filedes.dif +++ b/dhcp-4.1.1-dhclient-exec-filedes.dif @@ -1,6 +1,8 @@ ---- client/dhclient.c -+++ client/dhclient.c 2008/09/08 09:27:16 -@@ -2659,6 +2659,12 @@ int script_go (client) +diff --git a/client/dhclient.c b/client/dhclient.c +index 69dcc91..15c31a5 100644 +--- a/client/dhclient.c ++++ b/client/dhclient.c +@@ -3173,6 +3173,12 @@ int script_go (client) */ if (leaseFile != NULL) fclose(leaseFile); diff --git a/dhcp-4.1.1-dhclient-exec-filedes.diff b/dhcp-4.1.1-dhclient-exec-filedes.diff new file mode 100644 index 0000000..ef6fe7c --- /dev/null +++ b/dhcp-4.1.1-dhclient-exec-filedes.diff @@ -0,0 +1,17 @@ +diff --git a/client/dhclient.c b/client/dhclient.c +index 69dcc91..15c31a5 100644 +--- a/client/dhclient.c ++++ b/client/dhclient.c +@@ -3173,6 +3173,12 @@ int script_go (client) + */ + if (leaseFile != NULL) + fclose(leaseFile); ++ if ((i = open("/dev/null", O_RDWR)) != -1) { ++ dup2(i, STDIN_FILENO); ++ dup2(i, STDOUT_FILENO); ++ if (i > STDERR_FILENO) ++ close(i); ++ } + execve (scriptName, argv, envp); + log_error ("execve (%s, ...): %m", scriptName); + exit (0); diff --git a/dhcp-4.1.1-dhclient-no-libcrypto.diff b/dhcp-4.1.1-dhclient-no-libcrypto.diff new file mode 100644 index 0000000..bfd5c15 --- /dev/null +++ b/dhcp-4.1.1-dhclient-no-libcrypto.diff @@ -0,0 +1,16 @@ +--- dhcp-4.1.1/configure.ac ++++ dhcp-4.1.1/configure.ac 2010/05/03 12:25:59 +@@ -420,8 +420,13 @@ AC_TRY_LINK( + AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h) + + # find an MD5 library ++saved_LIBS="$LIBS" ++LIBS="" + AC_SEARCH_LIBS(MD5_Init, [crypto]) + AC_SEARCH_LIBS(MD5Init, [crypto]) ++CRYPTO_LIBS="$LIBS" ++LIBS="$saved_LIBS" ++AC_SUBST(CRYPTO_LIBS) + + # Solaris needs some libraries for functions + AC_SEARCH_LIBS(socket, [socket]) diff --git a/dhcp-3.1.1-dhclient-send-hostname-rml.dif b/dhcp-4.1.1-dhclient-send-hostname-rml.diff similarity index 51% rename from dhcp-3.1.1-dhclient-send-hostname-rml.dif rename to dhcp-4.1.1-dhclient-send-hostname-rml.diff index bae7f56..5d90ef0 100644 --- a/dhcp-3.1.1-dhclient-send-hostname-rml.dif +++ b/dhcp-4.1.1-dhclient-send-hostname-rml.diff @@ -1,6 +1,8 @@ ---- client/dhclient.8 -+++ client/dhclient.8 2008/09/08 15:19:13 -@@ -36,6 +36,9 @@ +diff --git a/client/dhclient.8 b/client/dhclient.8 +index b805528..d31fa8d 100644 +--- a/client/dhclient.8 ++++ b/client/dhclient.8 +@@ -60,6 +60,9 @@ dhclient - Dynamic Host Configuration Protocol Client .I port ] [ @@ -10,47 +12,50 @@ .B -d ] [ -@@ -172,6 +175,11 @@ +@@ -227,6 +230,11 @@ If a different port is specified for the client to listen on and transmit on, the client will also use a different destination port - one less than the specified port. .PP +The +.B -H +flag may be used to specify a client hostname that should be sent to -+the DHCP server. ++the DHCP server. Note, that this option is a SUSE/Novell extension. +.PP The DHCP client normally transmits any protocol messages it sends before acquiring an IP address to, 255.255.255.255, the IP limited broadcast address. For debugging purposes, it may be useful to have ---- client/dhclient.c -+++ client/dhclient.c 2008/09/08 15:17:50 -@@ -100,6 +100,7 @@ int main (argc, argv, envp) +diff --git a/client/dhclient.c b/client/dhclient.c +index 15c31a5..65e9c23 100644 +--- a/client/dhclient.c ++++ b/client/dhclient.c +@@ -108,6 +108,7 @@ main(int argc, char **argv) { int no_dhclient_db = 0; int no_dhclient_pid = 0; int no_dhclient_script = 0; + char *dhclient_hostname = NULL; - char *s; - - /* Make sure that file descriptors 0 (stdin), 1, (stdout), and -@@ -189,6 +190,15 @@ int main (argc, argv, envp) + #ifdef DHCPv6 + int local_family_set = 0; + #endif /* DHCPv6 */ +@@ -212,6 +213,16 @@ main(int argc, char **argv) { if (++i == argc) - usage (); - relay = argv [i]; -+ } else if (!strcmp (argv [i], "-H")) { + usage(); + mockup_relay = argv[i]; ++ } else if (!strcmp (argv[i], "-H")) { + if (++i == argc || !argv[i] || *(argv[i]) == '\0') + usage (); + if (strlen (argv[i]) > HOST_NAME_MAX) { + log_error("-H option host-name string \"%s\" is too long:" -+ "maximum length is %d characters", argv[i], HOST_NAME_MAX); ++ "maximum length is %d characters", ++ argv[i], HOST_NAME_MAX); + exit(1); + } + dhclient_hostname = argv [i]; - } else if (!strcmp (argv [i], "-nw")) { + } else if (!strcmp(argv[i], "-nw")) { nowait = 1; - } else if (!strcmp (argv [i], "-n")) { -@@ -345,6 +355,32 @@ int main (argc, argv, envp) + } else if (!strcmp(argv[i], "-n")) { +@@ -445,6 +456,32 @@ main(int argc, char **argv) { /* Parse the dhclient.conf file. */ - read_client_conf (); + read_client_conf(); + /* If the user specified a hostname, send it here and now */ + if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) { @@ -79,17 +84,20 @@ + } + /* Parse the lease database. */ - read_client_leases (); + read_client_leases(); -@@ -483,9 +519,9 @@ static void usage () - log_info (arr); - log_info (url); +@@ -653,12 +690,12 @@ static void usage() -- log_error ("Usage: dhclient [-1dqrx] [-nw] [-p ] %s", -+ log_error ("Usage: dhclient [-1dqrx] [-nw] [-H ] [-p ] %s", - "[-s server]"); -- log_error (" [-cf config-file] [-lf lease-file]%s", -+ log_error (" [-cf config-file] [-lf lease-file] %s", - "[-pf pid-file] [-e VAR=val]"); - log_fatal (" [-sf script-file] [interface]"); + log_error("Usage: dhclient %s %s", + #ifdef DHCPv6 +- "[-4|-6] [-SNTP1dvrx] [-nw] [-p ]", ++ "[-4|-6] [-SNTP1dvrx] [-nw] [-H ] [-p ]", + #else /* DHCPv6 */ + "[-1dvrx] [-nw] [-p ]", + #endif /* DHCPv6 */ + "[-s server]"); +- log_error(" [-cf config-file] [-lf lease-file]%s", ++ log_error(" [-cf config-file] [-lf lease-file] %s", + "[-pf pid-file] [-e VAR=val]"); + log_fatal(" [-sf script-file] [interface]"); } diff --git a/dhcp-4.1.1-in6_pktinfo-prototype.diff b/dhcp-4.1.1-in6_pktinfo-prototype.diff new file mode 100644 index 0000000..951134f --- /dev/null +++ b/dhcp-4.1.1-in6_pktinfo-prototype.diff @@ -0,0 +1,21 @@ +diff --git a/common/socket.c b/common/socket.c +index 036f7ae..6f56740 100644 +--- a/common/socket.c ++++ b/common/socket.c +@@ -40,11 +40,16 @@ + * I have implemented it under Linux; other systems should be doable also. + */ + ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif + #include "dhcpd.h" + #include + #include + #include + #include ++#include /* for struct in6_pktinfo, with glibc >= 2.10.1 ++ _GNU_SOURCE required to enable it */ + + #ifdef USE_SOCKET_FALLBACK + # if !defined (USE_SOCKET_SEND) diff --git a/dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 b/dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 new file mode 100644 index 0000000..fd34c11 --- /dev/null +++ b/dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:176dec01acb2704866f516ed21b6210c9d16bd4667db9b265c57bb2b07735510 +size 46012 diff --git a/dhcp-4.1.1-man-includes.diff b/dhcp-4.1.1-man-includes.diff new file mode 100644 index 0000000..c065a19 --- /dev/null +++ b/dhcp-4.1.1-man-includes.diff @@ -0,0 +1,26 @@ +diff --git a/dhcpctl/dhcpctl.3 b/dhcpctl/dhcpctl.3 +index 2e1cb8a..ee44755 100644 +--- a/dhcpctl/dhcpctl.3 ++++ b/dhcpctl/dhcpctl.3 +@@ -425,7 +425,7 @@ that most error checking has been ommitted for brevity. + #include + #include + +-#include ++#include + #include + + int main (int argc, char **argv) { +diff --git a/omapip/omapi.3 b/omapip/omapi.3 +index 4673549..8e2503f 100644 +--- a/omapip/omapi.3 ++++ b/omapip/omapi.3 +@@ -87,7 +87,7 @@ the lease ends. + #include + #include + +- #include ++ #include + #include + + int main (int argc, char **argv) { diff --git a/dhcp-4.1.1-paranoia.diff b/dhcp-4.1.1-paranoia.diff new file mode 100644 index 0000000..ff00292 --- /dev/null +++ b/dhcp-4.1.1-paranoia.diff @@ -0,0 +1,63 @@ +diff --git a/server/dhcpd.c b/server/dhcpd.c +index f0cacb6..6e30d33 100644 +--- a/server/dhcpd.c ++++ b/server/dhcpd.c +@@ -210,7 +210,11 @@ static void omapi_listener_start (void *foo) + #if defined (PARANOIA) + /* to be used in one of two possible scenarios */ + static void setup_chroot (char *chroot_dir) { +- if (geteuid()) ++ /* ++ ** getuid() instead of geteuid(), see ++ ** comment by thomas@suse.de bellow ++ */ ++ if (getuid()) + log_fatal ("you must be root to use chroot"); + + if (chroot(chroot_dir)) { +@@ -402,7 +406,7 @@ main(int argc, char **argv) { + log_fatal ("Insufficient memory to %s %s: %s", + "record interface", argv [i], + isc_result_totext (result)); +- strcpy (tmp -> name, argv [i]); ++ strncpy (tmp -> name, argv [i], sizeof(tmp->name)-1); + if (interfaces) { + interface_reference (&tmp -> next, + interfaces, MDL); +@@ -487,7 +491,15 @@ main(int argc, char **argv) { + if (set_user) { + struct passwd *tmp_pwd; + +- if (geteuid()) ++ /* ++ ** I query for the real UID and not for the effective UID ++ ** just to force the user to run this server as root and ++ ** not setting it suid. It should be a paranoia patch and ++ ** not a teletubbie patch. *eg* ++ ** Note: That the user is still able to set it suid! *zitter* ++ ** thomas@suse.de ++ */ ++ if (getuid()) + log_fatal ("you must be root to set user"); + + if (!(tmp_pwd = getpwnam(set_user))) +@@ -505,7 +517,10 @@ main(int argc, char **argv) { + #define group real_group + struct group *tmp_grp; + +- if (geteuid()) ++ /* ++ ** getuid() instead of geteuid(), see above ++ */ ++ if (getuid()) + log_fatal ("you must be root to set group"); + + if (!(tmp_grp = getgrnam(set_group))) +@@ -751,6 +766,7 @@ main(int argc, char **argv) { + /* change uid to the specified one */ + + if (set_gid) { ++ /* setgroups is done, OK */ + if (setgroups (0, (void *)0)) + log_fatal ("setgroups: %m"); + if (setgid (set_gid)) diff --git a/dhcp-3.1.1-tmpfile.dif b/dhcp-4.1.1-tmpfile.diff similarity index 86% rename from dhcp-3.1.1-tmpfile.dif rename to dhcp-4.1.1-tmpfile.diff index 6e9688f..219ded1 100644 --- a/dhcp-3.1.1-tmpfile.dif +++ b/dhcp-4.1.1-tmpfile.diff @@ -1,6 +1,8 @@ ---- server/db.c -+++ server/db.c 2006/11/07 10:19:41 -@@ -782,21 +782,16 @@ +diff --git a/server/db.c b/server/db.c +index a4e1558..1d5f5b0 100644 +--- a/server/db.c ++++ b/server/db.c +@@ -1059,21 +1059,16 @@ int new_lease_file () db_validity = lease_file_is_corrupt; diff --git a/dhcp-4.1.1.tar.bz2 b/dhcp-4.1.1.tar.bz2 new file mode 100644 index 0000000..bccf9df --- /dev/null +++ b/dhcp-4.1.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56937cd8e59da6ea0560e82d6b3dd637a96cc3052e0f8e163727c46a22fb87c4 +size 875897 diff --git a/dhcp.changes b/dhcp.changes index e44be0b..dd3512e 100644 --- a/dhcp.changes +++ b/dhcp.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Fri May 7 14:10:21 UTC 2010 - mt@suse.de + +- Updated to ISC DHCP 4.1.1, the current 4.x series production + release, providing DHCPv6 client/server/relay implementation. + The programs act in DHCPv6 mode, when the -6 start option is set. + We install separate init scripts with a 6 at the end to handle + them, that is /etc/init.d/dhcpd6 and dhrelay6. Further, there is + also a link to the binaries with a 6 at the end, e.g. dhclient6, + making it visible, that the installed version supports DHCPv6. +- Moved additional documentation to a separate dhcp-doc package. +- Changed to provide config files and scripts as source files + instead of patches to the ISC scripts. +- Adopted spec file and config/scripts, merged in all patches. +- Implemented RFC 3442 classless static routes support in the + dhclient-script (bnc#555870). + ------------------------------------------------------------------- Thu Apr 29 11:18:20 UTC 2010 - mt@suse.de diff --git a/dhcp.spec b/dhcp.spec index b53c4fe..075fb52 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -1,5 +1,5 @@ # -# spec file for package dhcp (Version 3.1.3.ESV) +# spec file for package dhcp (Version 4.1.1) # # Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -18,74 +18,69 @@ # norootforbuild +%define isc_version 4.1.1 +%define susefw2dir %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services +%define omc_prefix /usr/share/omc +%define omc_svcdir %{omc_prefix}/svcinfo.d +%define with_ldap 0 Name: dhcp -%define isc_version 3.1-ESV -%define susefw2dir %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services -%define omc_prefix /usr/share/omc -%define omc_svcdir %{omc_prefix}/svcinfo.d -%define with_casa 0%{?sles_version} >= 10 || 0%{?suse_version} >= 1110 -%if 0%{?with_casa:%with_casa} +%if 0%{?with_ldap:1} BuildRequires: CASA-devel +BuildRequires: openldap2-devel %endif -BuildRequires: dos2unix openldap2-devel +BuildRequires: dos2unix License: BSD3c(or similar) Group: Productivity/Networking/Boot/Servers AutoReqProv: on -Version: 3.1.3.ESV -Release: 1 +Version: 4.1.1 +Release: 0 Summary: Common Files Used by ISC DHCP Software -Url: http://www.isc.org/isc/dhcp.html +Url: http://www.isc.org/software/dhcp Source0: dhcp-%{isc_version}.tar.bz2 #Source0: http://ftp.isc.org/isc/dhcp/dhcp-%{isc_version}.tar.gz #Source1: http://ftp.isc.org/isc/dhcp/dhcp-%{isc_version}.tar.gz.asc -Source2: rc.dhcpd -Source3: rc.dhcrelay -Source11: sysconfig.dhcpd -Source12: sysconfig.syslog-dhcpd -Source14: sysconfig.dhcrelay -Source15: dhcp.README -Source16: dhcp.LIESMICH -Source17: examples.tar.gz -Source18: dhcp.README.upgrade -Source19: dhcpsync -Source20: dhcpsync.8 -Source21: DDNS-howto.txt -Source30: http://www.andrew.cmu.edu/~kevinm/dhcp/leasestate -Source31: http://www.andrew.cmu.edu/~kevinm/dhcp/listlease -Source32: http://www.andrew.cmu.edu/~kevinm/dhcp/clearip -Source33: http://www.andrew.cmu.edu/~kevinm/dhcp/reset-ip -Source40: http://www3.baylor.edu/~Jeff_Wilson/GiveAway/leases.awk -Source41: http://www.suse.de/~poeml/dnscompr.py -Source42: dhcpd.xml -Source43: SuSEfirewall2.dhcp-server -Source44: if-up.d.dhcpd-restart-hook -Patch0: dhcp-3.1.1-paths.dif -## chroot patch by Ari Edelkind (see readme) -## and patch supplied by -Patch1: dhcp-3.1.1-paranoia.dif -Patch2: dhcp-3.1.1-omapi-test.c.dif -Patch3: dhcp-3.1.1-man-includes.dif -Patch4: dhcp-3.1.1-tmpfile.dif -## LDAP support for DHCP server +# +Source10: rc.dhcpd +Source11: rc.dhcpd6 +Source12: rc.dhcrelay +Source14: sysconfig.dhcpd +Source15: sysconfig.syslog-dhcpd +Source16: sysconfig.dhcrelay +Source19: if-up.d.dhcpd-restart-hook +# +Source20: dhclient.conf +Source21: dhclient6.conf +Source22: dhcpd.conf +Source23: dhcpd6.conf +Source24: dhclient-script +# +Source30: dhcpd.xml +Source31: dhcpd6.xml +Source32: SuSEfirewall2.dhcp-server +# +Source40: dhcp.LIESMICH +Source41: dhcp.README +Source42: dhcp.README.upgrade +Source43: DDNS-howto.txt +Source44: contrib.tar.gz +Source45: examples.tar.gz +# +Patch10: dhcp-4.1.1-default-paths.diff +# paranoia patch is included now, but not the +# additional patch by thomas@suse.de not ... +Patch11: dhcp-4.1.1-paranoia.diff +Patch12: dhcp-4.1.1-man-includes.diff +Patch13: dhcp-4.1.1-tmpfile.diff +Patch14: dhcp-4.1.1-in6_pktinfo-prototype.diff +Patch20: dhcp-4.1.1-dhclient-exec-filedes.diff +Patch21: dhcp-4.1.1-dhclient-send-hostname-rml.diff ## patch lives here: http://www.suse.de/~mt/git/dhcp-ldap.git/ -%define DHCPD_LDAP 1 -%if %DHCPD_LDAP -Patch10: dhcp-3.1.3-ldap-patch-mt-01.diff.bz2 +%if 0%{?with_ldap:1} +Patch30: dhcp-4.1.1-ldap-patch-mt-01.diff.bz2 +%else +Patch30: dhcp-4.1.1-dhclient-no-libcrypto.diff %endif -%if %{?suse_version:%suse_version}%{?!suse_version:99999} > 930 -Patch30: dhcp-3.1.1-pie.dif -%endif -Patch40: dhcp-3.1.1-dhclient-exec-filedes.dif -Patch41: dhcp-3.1.1-dhclient-send-hostname-rml.dif -Patch42: dhcp-3.1.1-dhclient-use-script-cmdline.dif -Patch50: dhcp-3.1.1-dhclient-conf.dif -Patch51: dhcp-3.1.3-dhclient-conf.bnc516459.dif -Patch60: dhcp-3.1.3-dhclient-script.dif -Patch61: dhcp-3.1.3-dhclient-script.bnc555095.dif -Patch62: dhcp-3.1.3-dhclient-script.bnc585380.dif ## -Obsoletes: dhcp-base -Provides: dhcp-base:/usr/bin/omshell PreReq: /bin/touch /sbin/chkconfig sysconfig BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -93,31 +88,27 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build License: BSD3c(or similar) Summary: ISC DHCP Server Group: Productivity/Networking/Boot/Servers -Requires: net-tools dhcp +Requires: net-tools dhcp = %{version} PreReq: %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp /usr/sbin/useradd -Provides: dhcp_server dhcp:/usr/sbin/dhcpd +Provides: dhcp_server dhcp_server6 AutoReqProv: on %package client License: BSD3c(or similar) Summary: ISC DHCP Client Group: Productivity/Networking/Boot/Clients -Requires: net-tools dhcp /usr/bin/host -PreReq: %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp -Provides: dhcp_client -Provides: dhclient = %{version} -Obsoletes: dhclient < %{version} +Requires: net-tools dhcp = %{version} /bin/arping /usr/bin/host +PreReq: %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp /bin/grep +Provides: dhcp_client dhcp_client6 AutoReqProv: on %package relay License: BSD3c(or similar) -Summary: DHCP Relay Agent +Summary: ISC DHCP Relay Agent Group: Productivity/Networking/Boot/Servers -Requires: net-tools dhcp +Requires: net-tools dhcp = %{version} PreReq: %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp -Provides: dhcp_relay -Provides: dhcrelay = %{version} -Obsoletes: dhcrelay < %{version} +Provides: dhcp_relay dhcp_relay6 AutoReqProv: on %package devel @@ -125,37 +116,36 @@ License: BSD3c(or similar) Summary: Header Files and Libraries for dhcpctl API Group: Development/Libraries/C and C++ Requires: dhcp = %{version} -%if %ul_version >= 1 -%define VENDOR UnitedLinux -%else -%define VENDOR SuSE -%endif + +%package doc +License: BSD3c(or similar) +Summary: Documentation +Group: Productivity/Networking/Boot/Servers + %description -This package contains common files used by both the ISC DHCP server -("dhcp-server" package) and client ("dhcp-client"). - - +This package contains common programs used by both the ISC DHCP +server ("dhcp-server" package) and client ("dhcp-client") as the +omshell and common manual pages. Authors: -------- Ted Lemon + %description server This package contains the ISC DHCP server. Please read the documentation in /usr/share/doc/packages/dhcp-server regarding configuration of the DHCP server. - - Authors: -------- Ted Lemon - This package also contains software written by Kevin C. Miller and Jeff Wilson . + %description client This is an alternative DHCP client, the ISC DHCP client for Linux. Like "dhcpcd" (the client that is installed by default), it can be used to @@ -167,8 +157,6 @@ It is configurable via the configuration file /etc/dhclient.conf and you can define your own 'hooks' to be used by the /sbin/dhclient-script (which is called by the daemon). - - Authors: -------- Ted Lemon @@ -180,310 +168,317 @@ because requests can be broadcast, and they will normally not be routed. +Authors: +-------- + Ted Lemon -%description devel -This package contains all of the libraries and headers for developing -with the Internet Software Consortium (ISC) dhcpctl API. - - +%description doc +This package contains additional documentation files provided with +the software. The manual pages are in the corresponding packages. Authors: -------- Ted Lemon + +%description devel +This package contains all of the libraries and headers for developing +with the Internet Software Consortium (ISC) dhcpctl API. + +Authors: +-------- + Ted Lemon + + %prep %setup -q -n %{name}-%{isc_version} ## -%patch0 -p0 -%patch1 -p0 -%patch2 -p0 -%patch3 -p0 -%patch4 -p0 -%if %DHCPD_LDAP %patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch20 -p1 +%patch21 -p1 +%if 0%{?with_ldap:%with_ldap} +%patch30 -p1 +%else +%patch30 -p1 %endif -%if %{?suse_version:%suse_version}%{?!suse_version:99999} > 930 -%patch30 -p0 -%endif -%patch40 -p0 -%patch41 -p0 -%patch42 -p0 -%patch50 -p0 -%patch51 -p0 -%patch60 -p0 -%patch61 -p0 -%patch62 -p0 ## find . -type f -name \*.cat\* -exec rm -f {} \; -cp -p %{S:2} %{S:3} %{S:11} %{S:12} %{S:14} %{S:32} %{S:33} . -for i in README LIESMICH; do -sed 's/SuSE/%VENDOR/' $RPM_SOURCE_DIR/dhcp.$i > $i.%VENDOR -done -cp -p $RPM_SOURCE_DIR/dhcp.README.upgrade README.upgrade -cp -p $RPM_SOURCE_DIR/DDNS-howto.txt . -echo "exec /usr/bin/genDDNSkey \"$@\"" > genDDNSKey.sh -tar xzf $RPM_SOURCE_DIR/examples.tar.gz dos2unix contrib/ms2isc/* %build -export CFLAGS -CFLAGS="$RPM_OPT_FLAGS -W -Wall -fno-strict-aliasing -Wno-unused -DLDAP_DEPRECATED -DUSE_SSL -DPARANOIA -DHAVE_INET_PTON -DHAVE_INET_NTOP" -%if 0%{?with_casa:%with_casa} - CFLAGS="$CFLAGS -DLDAP_CASA_AUTH" -%endif -# seems obsolete (redefined reports) => double check -#%ifarch ia64 sparc64 alpha s390x ppc64 x86_64 -# CFLAGS="$CFLAGS -DPTRSIZE_64BIT" -#%endif +CFLAGS="$RPM_OPT_FLAGS -W -Wall -fno-strict-aliasing -Wno-unused" %ifarch ppc ppc64 s390x # bugs 134590, 171532 CFLAGS="$CFLAGS -fsigned-char" %endif -%if %{?suse_version:%suse_version}%{?!suse_version:99999} > 930 %ifarch ia64 %sparc alpha s390x ppc64 x86_64 CFLAGS="$CFLAGS -fPIE" %else CFLAGS="$CFLAGS -fpie" %endif +LDFLAGS="-pie" +FFLAGS="$CFLAGS" +CXXFLAGS="$CFLAGS" +export RPM_OPT_FLAGS LDFLAGS +export CFLAGS FFLAGS CXXFLAGS +# +%{?suse_update_config:%{suse_update_config -f}} +libtoolize --force +autoreconf +# +%configure \ + --enable-dhcpv6 \ + --enable-failover \ + --enable-paranoia \ + --enable-early-chroot \ +%if 0%{?with_ldap:%with_ldap} + --enable-ldap-conf \ + --enable-ldap-casa \ %endif -export DEBUG_FLAGS=$CFLAGS -./configure -# first, build binaries which use bsd sockets instead of lpf -cp includes/site.h includes/site.h.save.lpf -echo "#define USE_SOCKETS" >> includes/site.h -make %{?_smp_mflags} DEBUG="$DEBUG_FLAGS -W" all -cp -p work.linux-2.2/server/dhcpd work.linux-2.2/server/dhcpd.bsd -make clean -# then, build the normal binaries using lpf -mv includes/site.h.save.lpf includes/site.h -make %{?_smp_mflags} DEBUG="$DEBUG_FLAGS -W" all + --with-cli-pid-file=%{_localstatedir}/run/dhclient.pid \ + --with-cli-lease-file=%{_localstatedir}/lib/dhcp/dhclient.leases \ + --with-cli6-pid-file=%{_localstatedir}/run/dhclient6.pid \ + --with-cli6-lease-file=%{_localstatedir}/lib/dhcp6/dhclient.leases \ + --with-srv-pid-file=%{_localstatedir}/run/dhcpd.pid \ + --with-srv-lease-file=%{_localstatedir}/lib/dhcp/db/dhcpd.leases \ + --with-srv6-pid-file=%{_localstatedir}/run/dhcpd6.pid \ + --with-srv6-lease-file=%{_localstatedir}/lib/dhcp6/db/dhcpd6.leases +# +make %{?_smp_mflags} + +%check # with a minimal config, see if it runs echo "ddns-update-style interim;" > testconf -work.linux-2.2/server/dhcpd -t -cf testconf || exit 1 +./server/dhcpd -4 -t -cf testconf || exit 1 +./server/dhcpd -6 -t -cf testconf || exit 1 +# check syntax in our scripts +bash -n $RPM_SOURCE_DIR/rc.dhcpd +bash -n $RPM_SOURCE_DIR/rc.dhcpd6 +bash -n $RPM_SOURCE_DIR/rc.dhcrelay +bash -n $RPM_SOURCE_DIR/rc.dhcrelay6 +bash -n $RPM_SOURCE_DIR/dhclient-script %install -MANDIR=%{_mandir} DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} make install -install -m 744 work.linux-2.2/omapip/svtest $RPM_BUILD_ROOT/usr/sbin/svtest -install -m 644 work.linux-2.2/dst/libdst.a $RPM_BUILD_ROOT/%{_libdir} -# install the saved bsd flavor binary -install -m 755 work.linux-2.2/server/dhcpd.bsd $RPM_BUILD_ROOT/usr/sbin/dhcpd.bsd -mkdir -p $RPM_BUILD_ROOT/etc/init.d -mkdir -p $RPM_BUILD_ROOT/%{susefw2dir} -mkdir -p $RPM_BUILD_ROOT/%{omc_svcdir} -mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates -mkdir -p $RPM_BUILD_ROOT/var/run -# set up chroot jail -mkdir -p $RPM_BUILD_ROOT/var/lib/dhcp/etc -mkdir -p $RPM_BUILD_ROOT/var/lib/dhcp/dev -mkdir -p $RPM_BUILD_ROOT/var/lib/dhcp/%_lib -mkdir -p $RPM_BUILD_ROOT/var/lib/dhcp/var/run -mkdir -p $RPM_BUILD_ROOT/var/lib/dhcp/db -%if %DHCPD_LDAP -mkdir -p $RPM_BUILD_ROOT/etc/openldap/schema -install -m 644 contrib/dhcp.schema $RPM_BUILD_ROOT/etc/openldap/schema/ -%endif -install -m 744 rc.dhcpd $RPM_BUILD_ROOT/etc/init.d/dhcpd -install -m 744 rc.dhcrelay $RPM_BUILD_ROOT/etc/init.d/dhcrelay -ln -sf ../../etc/init.d/dhcpd $RPM_BUILD_ROOT/usr/sbin/rcdhcpd -ln -sf ../../etc/init.d/dhcrelay $RPM_BUILD_ROOT/usr/sbin/rcdhcrelay -install -m 755 $RPM_SOURCE_DIR/dhcpsync $RPM_BUILD_ROOT/usr/sbin/ -install -m 644 $RPM_SOURCE_DIR/dhcpsync.8 $RPM_BUILD_ROOT/%{_mandir}/man8/ -install -m 755 $RPM_SOURCE_DIR/leasestate $RPM_BUILD_ROOT/usr/sbin/ -install -m 755 $RPM_SOURCE_DIR/listlease $RPM_BUILD_ROOT/usr/sbin/ -install -m 755 $RPM_SOURCE_DIR/leases.awk $RPM_BUILD_ROOT/usr/sbin/ -cp -p $RPM_SOURCE_DIR/dnscompr.py . -install -m 644 sysconfig.dhcpd $RPM_BUILD_ROOT/var/adm/fillup-templates/ -install -m 644 sysconfig.syslog-dhcpd $RPM_BUILD_ROOT/var/adm/fillup-templates/ -install -m 644 sysconfig.dhcrelay $RPM_BUILD_ROOT/var/adm/fillup-templates/ -rm -f $RPM_BUILD_ROOT/var/lib/dhcp/dhcpd.leases -install -m 644 client/dhclient.conf $RPM_BUILD_ROOT/etc/dhclient.conf -sed '/^max-lease-time/ a \ -\ -# if you do not use dynamical DNS updates:\ -#\ -# this statement is needed by dhcpd-3 needs at least this statement.\ -# you have to delete it for dhcpd-2, because it does not know it.\ -#\ -# if you want to use dynamical DNS updates, you should first read\ -# read /usr/share/doc/packages/dhcp-server/DDNS-howto.txt\ -ddns-update-style none; ddns-updates off;\ -' server/dhcpd.conf > dhcpd.conf -install -m644 contrib/3.0b1-lease-convert 3.0b1-lease-convert -find $RPM_BUILD_ROOT/%{_mandir} -type f | xargs chmod 644 -install -m 644 $RPM_SOURCE_DIR/dhcpd.xml $RPM_BUILD_ROOT/%{omc_svcdir}/ -install -m 644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp-server \ - $RPM_BUILD_ROOT/%{susefw2dir}/dhcp-server -install -m 755 -d $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d -install -m 755 -d $RPM_BUILD_ROOT/etc/sysconfig/network/scripts -install -m 755 $RPM_SOURCE_DIR/if-up.d.dhcpd-restart-hook \ +export RPM_BUILD_ROOT +make install DESTDIR="$RPM_BUILD_ROOT" +# +# directories +install -d -m0755 $RPM_BUILD_ROOT/sbin +install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/init.d +install -d -m0755 $RPM_BUILD_ROOT/%{susefw2dir} +install -d -m0755 $RPM_BUILD_ROOT/%{omc_svcdir} +install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/openldap/schema +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/run +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates +# chroot jail +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/etc +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/dev +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/%_lib +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/var/run +install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/db +# move the dhclient binary to /sbin +mv -f $RPM_BUILD_ROOT/usr/sbin/dhclient $RPM_BUILD_ROOT/sbin/ +# provide a ...6 link, so we know it supports DHCPv6 +ln -sf dhcpd $RPM_BUILD_ROOT%{_sbindir}/dhcpd6 +ln -sf dhcrelay $RPM_BUILD_ROOT%{_sbindir}/dhcrelay6 +ln -sf dhclient $RPM_BUILD_ROOT/sbin/dhclient6 +# install our adopted config examples and dhclient-script: +install -m0644 $RPM_SOURCE_DIR/dhcpd.conf $RPM_BUILD_ROOT%{_sysconfdir}/ +install -m0644 $RPM_SOURCE_DIR/dhcpd6.conf $RPM_BUILD_ROOT%{_sysconfdir}/ +install -m0644 $RPM_SOURCE_DIR/dhclient.conf $RPM_BUILD_ROOT%{_sysconfdir}/ +install -m0644 $RPM_SOURCE_DIR/dhclient6.conf $RPM_BUILD_ROOT%{_sysconfdir}/ +install -m0750 $RPM_SOURCE_DIR/dhclient-script $RPM_BUILD_ROOT/sbin/ +# init scripts +install -m0755 $RPM_SOURCE_DIR/rc.dhcpd \ + $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd +ln -sf %{_sysconfdir}/init.d/dhcpd \ + $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd +install -m0755 $RPM_SOURCE_DIR/rc.dhcpd6 \ + $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd6 +ln -sf %{_sysconfdir}/init.d/dhcpd6 \ + $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd6 +install -m0755 $RPM_SOURCE_DIR/rc.dhcrelay \ + $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay +ln -sf %{_sysconfdir}/init.d/dhcrelay \ + $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay +install -m0755 $RPM_SOURCE_DIR/rc.dhcrelay6 \ + $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay6 +ln -sf %{_sysconfdir}/init.d/dhcrelay6 \ + $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay6 +# sysconfig files +install -m0644 $RPM_SOURCE_DIR/sysconfig.dhcpd \ + $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/ +install -m0644 $RPM_SOURCE_DIR/sysconfig.syslog-dhcpd \ + $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/ +install -m0644 $RPM_SOURCE_DIR/sysconfig.dhcrelay \ + $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/ +# another config files and scripts +install -m0644 contrib/dhcp.schema \ + $RPM_BUILD_ROOT%{_sysconfdir}/openldap/schema +install -m0644 $RPM_SOURCE_DIR/dhcpd.xml \ + $RPM_SOURCE_DIR/dhcpd6.xml \ + $RPM_BUILD_ROOT/%{omc_svcdir}/ +install -m0644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp-server \ + $RPM_BUILD_ROOT/%{susefw2dir}/dhcp-server +install -d -m0755 $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d +install -d -m0755 $RPM_BUILD_ROOT/etc/sysconfig/network/scripts +install -m0755 $RPM_SOURCE_DIR/if-up.d.dhcpd-restart-hook \ $RPM_BUILD_ROOT/etc/sysconfig/network/scripts/dhcpd-restart-hook ln -sf ../scripts/dhcpd-restart-hook \ $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d/60-dhcpd-restart-hook - -%pre -# In the past, the name of the source package was "dhcp" but the subpackage -# with the common files was named "dhcp-base" -- thus, no subpackage had the -# same name as the parent package. This lead to trouble on various ends, like -# the putonftp mechanism, so "dhcp-base" was renamed to "dhcp". -# -# During a YaST system update, the first package to be updated is "dhcp", which -# should --and does-- obsolete the dhcp-base package. -# However, if RPMv4 is used, there is a peculiarity: RPMv4 automatically -# invents an 'obsolete' when it sees a 'provides'. -# Since the old dhcp-server package (SLES8) did provide -# Provides: dhcp_server dhcp:/usr/sbin/dhcpd dhcp -# RPMv4 removes the dhcp-server package. -# -# This in itself is not a problem because the package is re-installed later -# (RPMv4 is not that intelligent). However, if the service is destined to be -# started at boot time, the runlevel links will be gone, so the service will -# not be started after the update. To restore the links, there is no better way -# than remember that the service was running before updating the "dhcp" package, -# and restore the links at "dhcp-server" installation time. -if [ ${1:-0} -gt 1 ]; then # update - if sbin/chkconfig -c dhcpd; then - touch var/adm/dhcpd_needs_insserv - fi -fi +# fix manual page permissions +find $RPM_BUILD_ROOT/%{_mandir} -type f | xargs chmod 644 +# copy some documentation and examples from src dir +install -m0644 $RPM_SOURCE_DIR/dhcp.LIESMICH LIESMICH.SuSE +install -m0644 $RPM_SOURCE_DIR/dhcp.README README.SuSE +install -m0644 $RPM_SOURCE_DIR/dhcp.README.upgrade README.upgrade +install -m0644 $RPM_SOURCE_DIR/DDNS-howto.txt . +tar xzf $RPM_SOURCE_DIR/contrib.tar.gz +mv doc/examples . +tar xzf $RPM_SOURCE_DIR/examples.tar.gz +rm -f doc/{References.xml,Makefile*} +rm -f contrib/dhcp.spec +%if ! 0%{?with_ldap:%with_ldap} +rm -f doc/draft-ietf-dhc-ldap-schema-01.txt +rm -f contrib/dhcp.schema README.ldap +rm -f contrib/dhcpd-conf-to-ldap.pl +%endif %pre server /usr/sbin/useradd -r -g nogroup -s /bin/false -c "DHCP server daemon" -d /var/lib/dhcp dhcpd 2> /dev/null ||: -if [ ! -x usr/sbin/dhcpd.lpf -a \ - ! -d usr/share/doc/packages/dhcp-server/ms2isc ]; then - # usr/sbin/dhcpd.lpf was added _after_ release of 9.1; - # usr/share/doc/packages/dhcp-server/ms2isc was added with 9.0; - # thus, if both are not present we are updating from pre 9.0 AND - # we are NOT updating a 9.1 released package (that has not been updated before). - # 9.0 already had a binary compiled with BSD sockets. - touch etc/dhcpd_updating_from_lpf_style -fi %post server -%{fillup_and_insserv -n dhcpd dhcpd} -%{fillup_only -ans syslog dhcpd} -if grep -q '^DHCPD_RUN_AS="nobody"' etc/sysconfig/dhcpd; then - tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX) - sed 's|^DHCPD_RUN_AS="nobody"|DHCPD_RUN_AS="dhcpd"|' etc/sysconfig/dhcpd \ - > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd - rm -f $tmpfile -fi +%{fillup_and_insserv -n dhcpd dhcpd dhcpd6} +%{fillup_only -ans syslog dhcpd} # update? if [ ${FIRST_ARG:-0} -gt 1 ]; then - if [ -e etc/dhcpd_updating_from_lpf_style -a -x usr/sbin/dhcpd.lpf ]; then - if /etc/init.d/dhcpd status &>/dev/null; then - was_running=true - /etc/init.d/dhcpd stop - else - was_running=false - fi - tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX) - sed 's|^DHCPD_BINARY=""|DHCPD_BINARY="/usr/sbin/dhcpd.lpf"|' etc/sysconfig/dhcpd \ - > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd - rm -f $tmpfile - if $was_running; then - /etc/init.d/dhcpd start - fi - fi - # see comment above - if [ -f var/adm/dhcpd_needs_insserv ]; then - sbin/insserv dhcpd - rm var/adm/dhcpd_needs_insserv - fi + if grep -q '^DHCPD_RUN_AS=.*nobody' etc/sysconfig/dhcpd; then + tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX) + sed 's|^DHCPD_RUN_AS=.*|DHCPD_RUN_AS="dhcpd"|' etc/sysconfig/dhcpd \ + > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd + rm -f $tmpfile + fi + if grep -q '^DHCPD_BINARY=.*dhcpd\..*' etc/sysconfig/dhcpd; then + tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX) + sed 's|^DHCPD_BINARY=.*|DHCPD_BINARY=""|' etc/sysconfig/dhcpd \ + > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd + rm -f $tmpfile + fi fi -rm -f etc/dhcpd_updating_from_lpf_style -test -s etc/dhcpd.conf || { cp -p usr/share/doc/packages/dhcp-server/dhcpd.conf etc/; } exit 0 -%postun server -%restart_on_update dhcpd -%insserv_cleanup - %preun server %stop_on_removal dhcpd +%stop_on_removal dhcpd6 + +%postun server +%restart_on_update dhcpd +%restart_on_update dhcpd6 +%insserv_cleanup %post relay -%{fillup_and_insserv -n dhcrelay dhcrelay} - -%postun relay -%restart_on_update dhcrelay -%insserv_cleanup +%{fillup_and_insserv -n dhcrelay dhcrelay dhcrelay6} %preun relay %stop_on_removal dhcrelay +%stop_on_removal dhcrelay6 + +%postun relay +%restart_on_update dhcrelay +%restart_on_update dhcrelay6 +%insserv_cleanup %post client -touch var/lib/dhcp/dhclient.leases +test -e %{_localstatedir}/lib/dhcp/dhclient.leases || \ + touch %{_localstatedir}/lib/dhcp/dhclient.leases +test -e %{_localstatedir}/lib/dhcp6/dhclient6.leases || \ + touch %{_localstatedir}/lib/dhcp6/dhclient6.leases %clean if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi %files %defattr(-,root,root) -%doc LICENSE README RELNOTES doc -/usr/bin/omshell -%dir /var/lib/dhcp +%config %{susefw2dir}/dhcp-server +%{_bindir}/omshell %doc %{_mandir}/man1/omshell.1.gz %doc %{_mandir}/man5/dhcp-eval.5.gz -%config %{susefw2dir}/dhcp-server +%doc %{_mandir}/man5/dhcp-options.5.gz + +%files doc +%defattr(-,root,root) +%doc LICENSE README RELNOTES +%doc LIESMICH.* README.* +%doc DDNS-howto.txt doc/* +%doc contrib examples %files server %defattr(-,root,root) -%doc clearip reset-ip -%doc dnscompr.py -/usr/sbin/dhcpd -/usr/sbin/dhcpd.bsd -/usr/sbin/rcdhcpd -/usr/sbin/svtest -%config /usr/sbin/dhcpsync -%config /usr/sbin/leasestate -%config /usr/sbin/listlease -%config /usr/sbin/leases.awk -%config /etc/init.d/dhcpd -%dir /var/lib/dhcp/var -%dir /var/lib/dhcp/var/run -%attr(755,dhcpd,root) %dir /var/lib/dhcp/db -%dir /var/lib/dhcp/etc -%dir /var/lib/dhcp/dev -%doc %{_mandir}/man5/dhcpd.conf.5.gz -%doc %{_mandir}/man5/dhcp-options.5.gz -%doc %{_mandir}/man5/dhcpd.leases.5.gz +%{_sbindir}/dhcpd +%{_sbindir}/dhcpd6 +%{_sbindir}/rcdhcpd +%{_sbindir}/rcdhcpd6 +%config %{_sysconfdir}/init.d/dhcpd +%config %{_sysconfdir}/init.d/dhcpd6 +%config(noreplace) %{_sysconfdir}/dhcpd.conf +%config(noreplace) %{_sysconfdir}/dhcpd6.conf +%dir %{_localstatedir}/lib/dhcp +%dir %{_localstatedir}/lib/dhcp/etc +%dir %{_localstatedir}/lib/dhcp/dev +%dir %{_localstatedir}/lib/dhcp/%_lib +%dir %{_localstatedir}/lib/dhcp/var +%dir %{_localstatedir}/lib/dhcp/var/run +%attr(755,dhcpd,root) %dir %{_localstatedir}/lib/dhcp/db +%dir %{_localstatedir}/lib/dhcp6 +%dir %{_localstatedir}/lib/dhcp6/etc +%dir %{_localstatedir}/lib/dhcp6/dev +%dir %{_localstatedir}/lib/dhcp6/%_lib +%dir %{_localstatedir}/lib/dhcp6/var +%dir %{_localstatedir}/lib/dhcp6/var/run +%attr(755,dhcpd,root) %dir %{_localstatedir}/lib/dhcp6/db %doc %{_mandir}/man8/dhcpd.8.gz -%doc %{_mandir}/man8/dhcpsync.8.gz -%doc dhcpd.conf LIESMICH.%VENDOR README.%VENDOR README.upgrade 3.0b1-lease-convert DDNS-howto.txt genDDNSKey.sh -%doc examples -%doc contrib/ms2isc -%if %DHCPD_LDAP -%doc contrib/dhcp.schema -%doc contrib/dhcpd-conf-to-ldap.pl -%doc README.ldap doc/draft-ietf-dhc-ldap-schema-01.txt -%dir /etc/openldap -%dir /etc/openldap/schema -%attr(0644, root, root) %config /etc/openldap/schema/dhcp.schema +%doc %{_mandir}/man5/dhcpd.conf.5.gz +%doc %{_mandir}/man5/dhcpd.leases.5.gz +%if 0%{?with_ldap:1} +%dir %{_sysconfdir}/openldap +%dir %{_sysconfdir}/openldap/schema +%attr(0644, root, root) %config %{_sysconfdir}/openldap/schema/dhcp.schema %endif -/var/adm/fillup-templates/sysconfig.dhcpd -/var/adm/fillup-templates/sysconfig.syslog-dhcpd -%dir /var/lib/dhcp/%_lib %{omc_svcdir}/dhcpd.xml -/etc/sysconfig/network/scripts/dhcpd-restart-hook -/etc/sysconfig/network/if-up.d/60-dhcpd-restart-hook +%{omc_svcdir}/dhcpd6.xml +%{_sysconfdir}/sysconfig/network/scripts/dhcpd-restart-hook +%{_sysconfdir}/sysconfig/network/if-up.d/60-dhcpd-restart-hook +%{_localstatedir}/adm/fillup-templates/sysconfig.dhcpd +%{_localstatedir}/adm/fillup-templates/sysconfig.syslog-dhcpd %files client %defattr(-,root,root) /sbin/dhclient +/sbin/dhclient6 /sbin/dhclient-script -%config(noreplace) /etc/dhclient.conf +%config(noreplace) %{_sysconfdir}/dhclient.conf +%config(noreplace) %{_sysconfdir}/dhclient6.conf %doc %{_mandir}/man5/dhclient.conf.5.gz %doc %{_mandir}/man5/dhclient.leases.5.gz %doc %{_mandir}/man8/dhclient.8.gz %doc %{_mandir}/man8/dhclient-script.8.gz +%dir %{_localstatedir}/lib/dhcp +%dir %{_localstatedir}/lib/dhcp6 %files relay %defattr(-,root,root) -/usr/sbin/dhcrelay -/usr/sbin/rcdhcrelay -%config /etc/init.d/dhcrelay +%{_sbindir}/dhcrelay +%{_sbindir}/dhcrelay6 +%{_sbindir}/rcdhcrelay +%{_sbindir}/rcdhcrelay6 +%config %{_sysconfdir}/init.d/dhcrelay +%config %{_sysconfdir}/init.d/dhcrelay6 %doc %{_mandir}/man8/dhcrelay.8.gz -/var/adm/fillup-templates/sysconfig.dhcrelay +%{_localstatedir}/adm/fillup-templates/sysconfig.dhcrelay %files devel %defattr(-,root,root) diff --git a/dhcpd.conf b/dhcpd.conf new file mode 100644 index 0000000..ae75fe2 --- /dev/null +++ b/dhcpd.conf @@ -0,0 +1,138 @@ +# dhcpd.conf +# +# Sample configuration file for ISC dhcpd +# + +# option definitions common to all supported networks... +option domain-name "example.org"; +option domain-name-servers ns1.example.org, ns2.example.org; + +default-lease-time 600; +max-lease-time 7200; + +# if you do not use dynamical DNS updates: +# +# if you want to use dynamical DNS updates, you should first read +# read /usr/share/doc/packages/dhcp-server/DDNS-howto.txt +# +ddns-updates off; + +# Use this to enble / disable dynamic dns updates globally. +ddns-update-style none; + +# If this DHCP server is the official DHCP server for the local +# network, the authoritative directive should be uncommented. +#authoritative; + +# Use this to send dhcp log messages to a different log file (you also +# have to hack syslog.conf to complete the redirection). +log-facility local7; + +# +# Define RFC 3442 classless static route option (121); +# the following _example_ routes: +# 192.168.2.254/32 via 0.0.0.0 (device route) +# 192.168.2.253/32 via 192.168.1.2 (255.255.255.255) +# 192.2.0.128/25 via 192.168.1.2 (255.255.255.128) +# 192.168.2.0/24 via 192.168.1.2 (255.255.255.0) +# 172.16.0.0/12 via 192.168.1.2 (255.240.0.0) +# 10.0.0.0/8 via 192.168.1.2 (255.0.0.0) +# default via 192.168.1.1 +# have to be written as: +# option rfc3442-classless-static-routes +# 32, 192, 168, 2, 254, 0, 0, 0, 0, +# 32, 192, 168, 2, 253, 192, 168, 1, 2, +# 25, 192, 2, 0, 128, 192, 168, 1, 2, +# 24, 192, 168, 3, 192, 168, 1, 2, +# 12, 172, 16, 192, 168, 1, 2, +# 8, 10, 192, 168, 1, 2, +# 0, 192, 168, 1, 1; +# +# Note: you have to specify the default gateway here +# as well, because when classless routes are in use, +# the 'routers' option is ignored by the dhcp client. +# +option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; + + +# No service will be given on this subnet, but declaring it helps the +# DHCP server to understand the network topology. + +subnet 10.152.187.0 netmask 255.255.255.0 { +} + +# This is a very basic subnet declaration. + +subnet 10.254.239.0 netmask 255.255.255.224 { + range 10.254.239.10 10.254.239.20; + option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; +} + +# This declaration allows BOOTP clients to get dynamic addresses, +# which we don't really recommend. + +subnet 10.254.239.32 netmask 255.255.255.224 { + range dynamic-bootp 10.254.239.40 10.254.239.60; + option broadcast-address 10.254.239.31; + option routers rtr-239-32-1.example.org; +} + +# A slightly different configuration for an internal subnet. +subnet 10.5.5.0 netmask 255.255.255.224 { + range 10.5.5.26 10.5.5.30; + option domain-name-servers ns1.internal.example.org; + option domain-name "internal.example.org"; + option routers 10.5.5.1; + option broadcast-address 10.5.5.31; + default-lease-time 600; + max-lease-time 7200; +} + +# Hosts which require special configuration options can be listed in +# host statements. If no address is specified, the address will be +# allocated dynamically (if possible), but the host-specific information +# will still come from the host declaration. + +host passacaglia { + hardware ethernet 0:0:c0:5d:bd:95; + filename "vmunix.passacaglia"; + server-name "toccata.fugue.com"; +} + +# Fixed IP addresses can also be specified for hosts. These addresses +# should not also be listed as being available for dynamic assignment. +# Hosts for which fixed IP addresses have been specified can boot using +# BOOTP or DHCP. Hosts for which no fixed address is specified can only +# be booted with DHCP, unless there is an address range on the subnet +# to which a BOOTP client is connected which has the dynamic-bootp flag +# set. +host fantasia { + hardware ethernet 08:00:07:26:c0:a5; + fixed-address fantasia.fugue.com; +} + +# You can declare a class of clients and then do address allocation +# based on that. The example below shows a case where all clients +# in a certain class get addresses on the 10.17.224/24 subnet, and all +# other clients get addresses on the 10.0.29/24 subnet. + +class "foo" { + match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; +} + +shared-network 224-29 { + subnet 10.17.224.0 netmask 255.255.255.0 { + option routers rtr-224.example.org; + } + subnet 10.0.29.0 netmask 255.255.255.0 { + option routers rtr-29.example.org; + } + pool { + allow members of "foo"; + range 10.17.224.10 10.17.224.250; + } + pool { + deny members of "foo"; + range 10.0.29.10 10.0.29.230; + } +} diff --git a/dhcpd6.conf b/dhcpd6.conf new file mode 100644 index 0000000..704bcda --- /dev/null +++ b/dhcpd6.conf @@ -0,0 +1,107 @@ +# Server configuration file example for DHCPv6 +# From the file used for TAHI tests. + +# +# For more iformations about IPv6 addresses, see also: +# http://tools.ietf.org/html/rfc4193 +# http://tools.ietf.org/html/rfc4291 +# http://www.iana.org/assignments/ipv6-address-space/ +# +# The addresses in the examples bellow are from the: +# FC00::/7 Unique Local Unicast [RFC4193] +# address space. +# +# Please allocate own prefix (6to4, tunnel broker) ! +# + +# IPv6 address valid lifetime +# (at the end the address is no longer usable by the client) +# (set to 30 days, the usual IPv6 default) +default-lease-time 2592000; + +# IPv6 address preferred lifetime +# (at the end the address is deprecated, i.e., the client should use +# other addresses for new connections) +# (set to 7 days, the usual IPv6 default) +preferred-lifetime 604800; + +# T1, the delay before Renew +# (default is 1/2 preferred lifetime) +# (set to 1 hour) +option dhcp-renewal-time 3600; + +# T2, the delay before Rebind (if Renews failed) +# (default is 3/4 preferred lifetime) +# (set to 2 hours) +option dhcp-rebinding-time 7200; + +# Enable RFC 5007 support (same than for DHCPv4) +allow leasequery; + +# Global definitions for name server address(es) and domain search list +option dhcp6.name-servers fc00:501:ffff:100:200:ff:fe00:3f3e; +option dhcp6.domain-search "test.example.com","example.com"; + +# Set preference to 255 (maximum) in order to avoid waiting for +# additional servers when there is only one +##option dhcp6.preference 255; + +# Server side command to enable rapid-commit (2 packet exchange) +##option dhcp6.rapid-commit; + +# The delay before information-request refresh +# (minimum is 10 minutes, maximum one day, default is to not refresh) +# (set to 6 hours) +option dhcp6.info-refresh-time 21600; + +# Static definition (must be global) +host myclient { + # The entry is looked up by this + host-identifier option + dhcp6.client-id 00:01:00:01:00:04:93:e0:00:00:00:00:a2:a2; + + # A fixed address + fixed-address6 fc00:501:ffff:100::1234; + + # A fixed prefix + fixed-prefix6 fc00:501:ffff:101::/64; + + # Override of the global definitions, + # works only when a resource (address or prefix) is assigned + option dhcp6.name-servers fc00:501:ffff:100:200:ff:fe00:4f4e; + + # For debug (to see when the entry statements are executed) + # (log "sol" when a matching Solicitation is received) + ##if packet(0,1) = 1 { log(debug,"sol"); } +} + +# The subnet where the server is attached +# (i.e., the server has an address in this subnet) +subnet6 fc00:501:ffff:100::/64 { + # Two addresses available to clients + # (the third client should get NoAddrsAvail) + range6 fc00:501:ffff:100::10 fc00:501:ffff:100::11; + + # Use the whole /64 prefix for temporary addresses + # (i.e., direct application of RFC 4941) + range6 fc00:501:ffff:100:: temporary; + + # Some /64 prefixes available for Prefix Delegation (RFC 3633) + prefix6 fc00:501:ffff:100:: fc00:501:ffff:111:: /64; +} + +# A second subnet behind a relay agent +subnet6 fc00:501:ffff:101::/64 { + range6 fc00:501:ffff:101::10 fc00:501:ffff:101::11; + + # Override of the global definitions, + # works only when a resource (address or prefix) is assigned + option dhcp6.name-servers fc00:501:ffff:101:200:ff:fe00:3f3e; + +} + +# A third subnet behind a relay agent chain +subnet6 fc00:501:ffff:102::/64 { + range6 fc00:501:ffff:102::10 fc00:501:ffff:102::11; +} + diff --git a/dhcpd6.xml b/dhcpd6.xml new file mode 100644 index 0000000..63bccf7 --- /dev/null +++ b/dhcpd6.xml @@ -0,0 +1,88 @@ + + + + + + + ISC DHCPv6 4.x Server + + + + ISC Dynamic Host Configuration Protocol for IPv6 Server + + + + + /etc/init.d/dhcpd6 start + + + /etc/init.d/dhcpd6 restart + + + /etc/init.d/dhcpd6 stop + + + /etc/init.d/dhcpd6 status + + + + dhcpd6 + /usr/sbin/dhcpd6 + + + + + network + + + + diff --git a/if-up.d.dhcpd-restart-hook b/if-up.d.dhcpd-restart-hook index 9a259e3..a83ab27 100644 --- a/if-up.d.dhcpd-restart-hook +++ b/if-up.d.dhcpd-restart-hook @@ -57,6 +57,7 @@ fi . /etc/sysconfig/network/ifcfg-"$CONFIG" 2>/dev/null || true : ${DHCPD_IFUP_RESTART:=auto} +: ${DHCPD6_IFUP_RESTART:=auto} iface_needs_restart() { @@ -65,17 +66,17 @@ iface_needs_restart() -f /proc/net/vlan/$1 } -case "$0" in -*if-up.d*) +dhcpv4_server_restart() +{ # # don't do anything if we are disabled either # in the /etc/sysconfig/dhcpd or per interface # in the /etc/sysconfig/network/ifcfg-"$CONFIG" # - test "$DHCPD_IFUP_RESTART" = no && exit 0 + test "$DHCPD_IFUP_RESTART" = no && return 0 # don't restart for loopback interface - case $INTERFACE in (lo) exit 0 ;; esac + case $INTERFACE in (lo) return 0 ;; esac restart_needed=$DHCPD_IFUP_RESTART if test -n "$DHCPD_INTERFACE" \ @@ -86,7 +87,7 @@ case "$0" in # don't restart when _one_ involved # interface is not available/up yet - is_iface_up $I || exit 0 + is_iface_up $I || return 0 # check if this interface is involved if test "$I" = "$INTERFACE" ; then @@ -102,6 +103,50 @@ case "$0" in if test "$restart_needed" = yes ; then /etc/init.d/dhcpd try-restart fi +} +dhcpv6_server_restart() +{ + # + # don't do anything if we are disabled either + # in the /etc/sysconfig/dhcpd or per interface + # in the /etc/sysconfig/network/ifcfg-"$CONFIG" + # + test "$DHCPD6_IFUP_RESTART" = no && return 0 + + # don't restart for loopback interface + case $INTERFACE in (lo) return 0 ;; esac + + restart_needed=$DHCPD6_IFUP_RESTART + if test -n "$DHCPD6_INTERFACE" \ + -a "$restart_needed" != yes ; + then + for I in $DHCPD6_INTERFACE ; do + test -n "$I" || continue + + # don't restart when _one_ involved + # interface is not available/up yet + is_iface_up $I || return 0 + + # check if this interface is involved + if test "$I" = "$INTERFACE" ; then + + # check if a restart is needed + if iface_needs_restart $I ; then + restart_needed=yes + fi + fi + done + fi + + if test "$restart_needed" = yes ; then + /etc/init.d/dhcpd6 try-restart + fi +} + +case "$0" in +*if-up.d*) + dhcpv4_server_restart + dhcpv6_server_restart ;; *if-down.d*) # don't do anything diff --git a/rc.dhcpd b/rc.dhcpd index 21874f4..a4d94a8 100644 --- a/rc.dhcpd +++ b/rc.dhcpd @@ -2,63 +2,70 @@ # Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH # Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH # Copyright (c) 2002, 2003 SuSE Linux AG +# Copyright (c) 2004-2008 SUSE LINUX Products GmbH, Nuernberg, Germany. # -# Author: Rolf Haberrecker , 1997, 1998, 1999 -# Peter Poeml , 2000, 2001, 2002, 2003 +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. # -# /etc/init.d/dhcpd +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Rolf Haberrecker , 1997-1999 +# Peter Poeml , 2000-2006 +# Marius Tomaschewski , 2006-2010 +# +# /etc/init.d/dhcp-server # and its symbolic link -# /usr/sbin/rcdhcpd +# /usr/sbin/rcdhcp-server # ### BEGIN INIT INFO -# Provides: dhcpd -# Required-Start: $network $remote_fs network-remotefs -# Should-Start: $named $syslog $time ldap ndsd -# Required-Stop: $network $remote_fs network-remotefs -# Should-Stop: $named $syslog ldap ndsd +# Provides: dhcp-server +# Required-Start: $remote_fs $network +# Should-Start: network-remotefs $named $syslog $time ldap ndsd +# Required-Stop: $remote_fs $network +# Should-Stop: network-remotefs $named $syslog ldap ndsd # Default-Start: 3 5 # Default-Stop: 0 1 2 6 -# Short-Description: DHCP Server -# Description: Start DHCP (Dynamic Host Configuration Protocol) -# server. (Note: if configured for failover it +# Short-Description: ISC DHCP 4.x Server +# Description: Start ISC DHCP (Dynamic Host Configuration Protocol) +# 4.x series server. +# (Note: if configured for failover it # needs to rely on time synchronisation.) ### END INIT INFO +test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd -if [ -s /etc/sysconfig/dhcpd ]; then +SUPPORTS_CHROOT="yes" +SUPPORTS_RUN_AS="yes" +SUPPORTS_HUP="no" - . /etc/sysconfig/dhcpd +DHCPDv_OPT=-4 +test "$SUPPORTS_CHROOT" = no && DHCPD_RUN_CHROOTED=no +test "$SUPPORTS_RUN_AS" = no && DHCPD_RUN_AS="" +test "$DHCPD_BINARY" = "/usr/sbin/dhcpd.lpf" -o \ + "$DHCPD_BINARY" = "/usr/sbin/dhcpd.bsd" && \ +DHCPD_BINARY=/usr/sbin/dhcpd -else - # pre 8.0 - - # Source SuSE config - . /etc/rc.config - - test -s /etc/rc.config.d/dhcpd.rc.config && \ - . /etc/rc.config.d/dhcpd.rc.config - - # Determine the base and follow a runlevel link name. - base=${0##*/} - link=${base#*[SK][0-9][0-9]} - - # Force execution if not called by a runlevel directory. - test $link = $base && START_DHCPD=yes - test "$START_DHCPD" = yes || exit 0 - -fi - - -test "$DHCPD_RUN_CHROOTED" = "yes" && CHROOT_PREFIX=/var/lib/dhcp/ -DAEMON="DHCP server" -[ "$DHCPD_BINARY" = /usr/sbin/dhcpd.lpf ] && DHCPD_BINARY=/usr/sbin/dhcpd +DAEMON='ISC DHCPv4 4.x Server' DAEMON_BIN=${DHCPD_BINARY:=/usr/sbin/dhcpd} DAEMON_CONF=/etc/dhcpd.conf +DAEMON_STATE=/var/lib/dhcp +DAEMON_LEASES=dhcpd.leases DAEMON_PIDFILE=/var/run/dhcpd.pid STARTPROC_LOGFILE=/var/log/rc.dhcpd.log -SUPPORTS_HUP="no" LDAP_CONF=/etc/openldap/ldap.conf +test "$DHCPD_RUN_CHROOTED" = "yes" && \ +CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX='' + # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status @@ -88,11 +95,15 @@ rc_reset # with force-reload (in case signalling is not supported) are # considered a success. -if ! [ -x $DAEMON_BIN ]; then +if ! [ -x "$DAEMON_BIN" ]; then + if [ "$1" = "stop" ]; then exit 0; fi echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting." - rc_failed 1 - rc_status -v1 - rc_exit + exit 5 +fi +if ! [ -r "$DAEMON_CONF" ] ; then + if [ "$1" = "stop" ]; then exit 0; fi + echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting." + exit 6 fi # remove empty pid files to avoid disturbing warnings by checkproc/killproc @@ -117,7 +128,9 @@ case "$1" in ## If the interfaces are not set, skip starting of dhcpd ## and return with "program not configured" if [ -z "$DHCPD_INTERFACE" ]; then - echo -n "... set DHCPD_INTERFACE in /etc/sysconfig/dhcpd" + var="DHCPD_INTERFACE" + case $DHCPDv_OPT in -6) var=DHCPD6_INTERFACE ;; esac + echo -n "... set $var in /etc/sysconfig/dhcpd" # Tell the user this has skipped rc_status -s # service is not configured @@ -128,7 +141,7 @@ case "$1" in DHCPD_INTERFACE="" fi - jail=/var/lib/dhcp; leases=dhcpd.leases + jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES if ! [ -e $jail/db/$leases ]; then # until 9.0, the lease file was in /var/lib/dhcp and part of the package if test -e $jail/$leases -a '!' -L $jail/$leases; then @@ -150,7 +163,7 @@ case "$1" in if test "$DHCPD_RUN_CHROOTED" = "yes" ; then ## copy the conf file to the chroot jail (dhcpd has to be restarted anyway, ## when it has changed) and change path to leases file - for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF; do + for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do if test -d "${i}" ; then test -d "$CHROOT_PREFIX/${i}" || \ mkdir -p "$CHROOT_PREFIX/${i}" @@ -165,18 +178,19 @@ case "$1" in cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \ || { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; } done - libdir=$(basename $(echo /var/lib/dhcp/lib*)) + libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*)) if test -x /usr/bin/ldd ; then get_ldd_deps() { ldd_wl="\/${libdir}\/lib" ldd_bl="\/${libdir}\/libc\." + /usr/bin/ldd "$1" | \ while read -sr a b c d ; do [ -n "$c" ] || continue [[ $c =~ $ldd_wl ]] || continue [[ $c =~ $ldd_bl ]] && continue echo $c - done < <(/usr/bin/ldd "$1") + done } else get_ldd_deps() { :; } @@ -191,11 +205,16 @@ case "$1" in done | sort -u` for i in $cplibs ; do if [ -s "$i" ]; then - cp -pL "$i" "/var/lib/dhcp/$libdir/" \ + cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \ || { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; } - fi + fi done - DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/dhcpd.leases" + + # mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6} + mkdir -p ${CHROOT_PREFIX}/proc + mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null + + DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES" ## If there is a pid file containing a pid, the machine might have crashed. pid files in ## /var/run are always cleaned up at boot time, but this is not the case for the pid file in @@ -203,26 +222,32 @@ case "$1" in ## incidentally contains the pid of a running process. If this process is not a 'dhcpd', ## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.) if test -e $CHROOT_PREFIX/$DAEMON_PIDFILE -a -s $CHROOT_PREFIX/$DAEMON_PIDFILE; then - i=$(<$CHROOT_PREFIX/$DAEMON_PIDFILE) - if pidof dhcpd &>/dev/null; then - echo -n "(already running) " - else + p=$(<$CHROOT_PREFIX/$DAEMON_PIDFILE) + if test -n "$p" && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then + echo -n '(already running) ' + else rm $CHROOT_PREFIX/$DAEMON_PIDFILE fi fi - + else + DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES" fi if [ -n "$DHCPD_RUN_AS" ]; then DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)" DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP" + + if test "$DHCPD_RUN_CHROOTED" = "yes" ; then + chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \ + "$CHROOT_PREFIX/${DAEMON_PIDFILE%/*}" + fi fi ## check syntax with -t (output to log file) and start only when the syntax is okay rm -f $STARTPROC_LOGFILE # start log error=0 - if ! $DAEMON_BIN -t -cf $CHROOT_PREFIX/$DAEMON_CONF > $STARTPROC_LOGFILE 2>&1 ; then + if ! $DAEMON_BIN $DHCPDv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $DAEMON_PIDFILE > $STARTPROC_LOGFILE 2>&1 ; then error=1 else ## Start daemon. If this fails the return value is set appropriate. @@ -230,9 +255,9 @@ case "$1" in ## to match the LSB spec. test "$2" = "-v" && echo -en \ - "\nexecuting '$DAEMON_BIN $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'" + "\nexecuting '$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'" - $DAEMON_BIN $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE + $DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE ret=$? fi @@ -259,9 +284,10 @@ case "$1" in kill $(<$CHROOT_PREFIX/$DAEMON_PIDFILE) 2>/dev/null fi - # remove libraries from the chroot jail, just so they are not left over - # if the server is deinstalled - if [ "$DHCPD_RUN_CHROOTED" = yes ]; then + # umount proc and remove libraries from the chroot jail, + # so they are not left over if the server is deinstalled + if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then + umount ${CHROOT_PREFIX}/proc 2>/dev/null rm -f $CHROOT_PREFIX/lib*/* fi @@ -300,8 +326,8 @@ case "$1" in echo -n "Reload service $DAEMON" if [ "$SUPPORTS_HUP" = "yes" ]; then - killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN - #touch $DAEMON_PIDFILE + killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $CHROOT_PREFIX/$DAEMON_PIDFILE rc_status -v else $0 stop && sleep 3 && $0 start @@ -315,8 +341,8 @@ case "$1" in echo -n "Reload service $DAEMON" if [ "$SUPPORTS_HUP" = "yes" ]; then # If it supports signalling: - killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN - #touch $DAEMON_PIDFILE + killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $CHROOT_PREFIX/$DAEMON_PIDFILE rc_status -v else ## Otherwise if it does not support reload: @@ -354,10 +380,10 @@ case "$1" in ## this nice bit is from Edwin Groothuis: ## check syntax (quiet) - $DAEMON_BIN -q -t -cf $DAEMON_CONF + $DAEMON_BIN $DHCPDv_OPT -q -t -cf $DAEMON_CONF if ! [ $? -eq 0 ]; then ## check syntax (verbose) - $DAEMON_BIN -t -cf $DAEMON_CONF + $DAEMON_BIN $DHCPDv_OPT -t -cf $DAEMON_CONF echo -e '\nConfig is NOT okay\n' else echo 'Config is okay. Hope you also specified existent network devices ;) ' @@ -365,10 +391,10 @@ case "$1" in ## in v3, lease file checking is also implemented if [ $DAEMON_BIN != "/usr/sbin/dhcpd-2" ]; then ## check leases file (quiet) - $DAEMON_BIN -q -T -cf $DAEMON_CONF -lf /var/lib/dhcp/db/dhcpd.leases + $DAEMON_BIN $DHCPDv_OPT -q -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES if ! [ $? -eq 0 ]; then ## check leases file (verbose) - $DAEMON_BIN -T -cf $DAEMON_CONF -lf /var/lib/dhcp/db/dhcpd.leases + $DAEMON_BIN $DHCPDv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES echo -e '\nLease file is NOT okay' else echo 'Lease file is okay' diff --git a/rc.dhcpd6 b/rc.dhcpd6 new file mode 100644 index 0000000..29770a9 --- /dev/null +++ b/rc.dhcpd6 @@ -0,0 +1,413 @@ +#! /bin/bash +# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH +# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH +# Copyright (c) 2002, 2003 SuSE Linux AG +# Copyright (c) 2004-2008 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Rolf Haberrecker , 1997-1999 +# Peter Poeml , 2000-2006 +# Marius Tomaschewski , 2006-2010 +# +# /etc/init.d/dhcp-server +# and its symbolic link +# /usr/sbin/rcdhcp-server +# +### BEGIN INIT INFO +# Provides: dhcp6-server +# Required-Start: $remote_fs $network +# Should-Start: network-remotefs $named $syslog $time ldap ndsd +# Required-Stop: $remote_fs $network +# Should-Stop: network-remotefs $named $syslog ldap ndsd +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: ISC DHCP 4.x Server +# Description: Start ISC DHCP (Dynamic Host Configuration Protocol) +# 4.x series server. +# (Note: if configured for failover it +# needs to rely on time synchronisation.) +### END INIT INFO + +test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd + +SUPPORTS_CHROOT="yes" +SUPPORTS_RUN_AS="yes" +SUPPORTS_HUP="no" + +DHCPDv_OPT=-6 +DHCPD_RUN_CHROOTED=$DHCPD6_RUN_CHROOTED +DHCPD_RUN_AS=$DHCPD6_RUN_AS +DHCPD_BINARY=$DHCPD6_BINARY +DHCPD_INTERFACE=$DHCPD6_INTERFACE +DHCPD_CONF_INCLUDE_FILES=$DHCPD6_CONF_INCLUDE_FILES +DHCPD_OTHER_ARGS=$DHCPD6_OTHER_ARGS + +test "$SUPPORTS_CHROOT" = no && DHCPD_RUN_CHROOTED=no +test "$SUPPORTS_RUN_AS" = no && DHCPD_RUN_AS="" + +DAEMON='ISC DHCPv6 4.x Server' +DAEMON_BIN=${DHCPD_BINARY:=/usr/sbin/dhcpd6} +DAEMON_CONF=/etc/dhcpd6.conf +DAEMON_STATE=/var/lib/dhcp6 +DAEMON_LEASES=dhcpd6.leases +DAEMON_PIDFILE=/var/run/dhcpd6.pid +STARTPROC_LOGFILE=/var/log/rc.dhcpd6.log +LDAP_CONF= + +test "$DHCPD_RUN_CHROOTED" = "yes" && \ +CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX='' + +# Shell functions sourced from /etc/rc.status: +# rc_check check and set local and overall rc status +# rc_status check and set local and overall rc status +# rc_status -v ditto but be verbose in local rc status +# rc_status -v -r ditto and clear the local rc status +# rc_failed set local and overall rc status to failed +# rc_failed set local and overall rc status to +# rc_reset clear local rc status (overall remains) +# rc_exit exit appropriate to overall rc status +. /etc/rc.status + +# First reset status of this service +rc_reset + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - insufficient privilege +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signalling is not supported) are +# considered a success. + +if ! [ -x "$DAEMON_BIN" ]; then + if [ "$1" = "stop" ]; then exit 0; fi + echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting." + exit 5 +fi +if ! [ -r "$DAEMON_CONF" ] ; then + if [ "$1" = "stop" ]; then exit 0; fi + echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting." + exit 6 +fi + +# remove empty pid files to avoid disturbing warnings by checkproc/killproc +# (these can occur if dhcpd does not start correctly) +test -e $DAEMON_PIDFILE && ! test -s $DAEMON_PIDFILE && rm $DAEMON_PIDFILE +test -e $CHROOT_PREFIX/$DAEMON_PIDFILE && ! test -s $CHROOT_PREFIX/$DAEMON_PIDFILE && rm $CHROOT_PREFIX/$DAEMON_PIDFILE + +case "$1" in + start) + echo -n "Starting $DAEMON " + + ## If there is no conf file, skip starting of dhcpd + ## and return with "program not configured" + if ! [ -f $DAEMON_CONF ]; then + echo -n "... no configuration file found"; + # Tell the user this has skipped + rc_status -s + # service is not configured + exit 6; + fi + + ## If the interfaces are not set, skip starting of dhcpd + ## and return with "program not configured" + if [ -z "$DHCPD_INTERFACE" ]; then + var="DHCPD_INTERFACE" + case $DHCPDv_OPT in -6) var=DHCPD6_INTERFACE ;; esac + echo -n "... set $var in /etc/sysconfig/dhcpd" + # Tell the user this has skipped + rc_status -s + # service is not configured + exit 6; + fi + + if [ "$DHCPD_INTERFACE" = "ANY" ]; then + DHCPD_INTERFACE="" + fi + + jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES + if ! [ -e $jail/db/$leases ]; then + # until 9.0, the lease file was in /var/lib/dhcp and part of the package + if test -e $jail/$leases -a '!' -L $jail/$leases; then + # this is the case where the %post script runs _before_ the old package is + # removed (i.e., dhcpd.leases has not renamed to .rpmsave yet) + mv $jail/$leases $jail/db/$leases && \ + ln -s db/$leases $jail/ + elif test -e $jail/$leases.rpmsave; then + # this is what's left when the package is already gone. + mv $jail/$leases.rpmsave $jail/db/$leases && \ + ln -s db/$leases $jail/ + else + # fresh installation: + # a lease file must be present. the server won't start without + touch $jail/db/$leases + fi + fi + + if test "$DHCPD_RUN_CHROOTED" = "yes" ; then + ## copy the conf file to the chroot jail (dhcpd has to be restarted anyway, + ## when it has changed) and change path to leases file + for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do + if test -d "${i}" ; then + test -d "$CHROOT_PREFIX/${i}" || \ + mkdir -p "$CHROOT_PREFIX/${i}" + elif test -e "${i}" ; then + test -d "$CHROOT_PREFIX/${i%/*}" || \ + mkdir -p "$CHROOT_PREFIX/${i%/*}" + fi + done + rm -f $CHROOT_PREFIX/dev/urandom + for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc/{gai.conf,nsswitch.conf,resolv.conf,host.conf,hosts,localtime} /dev/urandom; do + if ! test -e "$i"; then continue; fi # neither of them is absolutely necessary + cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \ + || { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; } + done + libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*)) + if test -x /usr/bin/ldd ; then + get_ldd_deps() + { + ldd_wl="\/${libdir}\/lib" + ldd_bl="\/${libdir}\/libc\." + /usr/bin/ldd "$1" | \ + while read -sr a b c d ; do + [ -n "$c" ] || continue + [[ $c =~ $ldd_wl ]] || continue + [[ $c =~ $ldd_bl ]] && continue + echo $c + done + } + else + get_ldd_deps() { :; } + fi + cplibs=`for i in /$libdir/{libresolv.so.*,libnss_*.so.*} \ + /$libdir/{libpthread.so.0,libdl.so.2} ; + do + if [ -s "$i" ] ; then + echo "$i" + get_ldd_deps "$i" + fi + done | sort -u` + for i in $cplibs ; do + if [ -s "$i" ]; then + cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \ + || { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; } + fi + done + + # mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6} + mkdir -p ${CHROOT_PREFIX}/proc + mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null + + DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES" + + ## If there is a pid file containing a pid, the machine might have crashed. pid files in + ## /var/run are always cleaned up at boot time, but this is not the case for the pid file in + ## the chroot jail. Therefore, and old pid file may exist. This is only a problem if it + ## incidentally contains the pid of a running process. If this process is not a 'dhcpd', + ## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.) + if test -e $CHROOT_PREFIX/$DAEMON_PIDFILE -a -s $CHROOT_PREFIX/$DAEMON_PIDFILE; then + p=$(<$CHROOT_PREFIX/$DAEMON_PIDFILE) + if test -n "$p" && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then + echo -n '(already running) ' + else + rm $CHROOT_PREFIX/$DAEMON_PIDFILE + fi + fi + else + DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES" + fi + + if [ -n "$DHCPD_RUN_AS" ]; then + DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)" + DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP" + + if test "$DHCPD_RUN_CHROOTED" = "yes" ; then + chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \ + "$CHROOT_PREFIX/${DAEMON_PIDFILE%/*}" + fi + fi + + + ## check syntax with -t (output to log file) and start only when the syntax is okay + rm -f $STARTPROC_LOGFILE # start log + error=0 + if ! $DAEMON_BIN $DHCPDv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $DAEMON_PIDFILE > $STARTPROC_LOGFILE 2>&1 ; then + error=1 + else + ## Start daemon. If this fails the return value is set appropriate. + ## The init script should return 0, even if service is already running, + ## to match the LSB spec. + + test "$2" = "-v" && echo -en \ + "\nexecuting '$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'" + + $DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE + ret=$? + fi + + if [ $error -gt 0 -o ${ret:-0} -gt 0 ]; then + cat $STARTPROC_LOGFILE + ## set status to failed + rc_failed + else + [ "$DHCPD_RUN_CHROOTED" = "yes" ] && echo -n "[chroot]" || : + fi + + # Remember status and be verbose + rc_status -v + ;; + stop) + echo -n "Shutting down $DAEMON " + + ## Stop daemon with killproc(8) and if this fails + ## set echo the echo return value. + + killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -TERM $DAEMON_BIN + ret=$? + if test -s $CHROOT_PREFIX/$DAEMON_PIDFILE; then + kill $(<$CHROOT_PREFIX/$DAEMON_PIDFILE) 2>/dev/null + fi + + # umount proc and remove libraries from the chroot jail, + # so they are not left over if the server is deinstalled + if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then + umount ${CHROOT_PREFIX}/proc 2>/dev/null + rm -f $CHROOT_PREFIX/lib*/* + fi + + # Remember status and be verbose + rc_failed $ret + rc_status -v + ;; + try-restart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi + # Remember status and be quiet + rc_status + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + sleep 3 + $0 start + + # Remember status and be quiet + rc_status + ;; + force-reload) + ## Signal the daemon to reload its config. Most daemons + ## do this on signal 1 (SIGHUP). + ## If it does not support it, restart. + + echo -n "Reload service $DAEMON" + + if [ "$SUPPORTS_HUP" = "yes" ]; then + killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $CHROOT_PREFIX/$DAEMON_PIDFILE + rc_status -v + else + $0 stop && sleep 3 && $0 start + rc_status + fi + ;; + reload) + ## Like force-reload, but if daemon does not support + ## signalling, do nothing (!) + + echo -n "Reload service $DAEMON" + if [ "$SUPPORTS_HUP" = "yes" ]; then + # If it supports signalling: + killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $CHROOT_PREFIX/$DAEMON_PIDFILE + rc_status -v + else + ## Otherwise if it does not support reload: + rc_failed 3 + rc_status -v + fi + ;; + status) + echo -n "Checking for $DAEMON: " + ## Check status with checkproc(8), if process is running + ## checkproc will return with exit status 0. + + # Status has a slightly different for the status command: + # 0 - service running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running + + # NOTE: checkproc returns LSB compliant status values. + checkproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE $DAEMON_BIN + rc_status -v + ;; + probe) + ## Optional: Probe for the necessity of a reload, + ## give out the argument which is required for a reload. + + rc=0 + for i in /etc/sysconfig/dhcpd $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES; do + test $i -nt $CHROOT_PREFIX/$DAEMON_PIDFILE && rc=1 + done + test $rc = 1 && echo restart + ;; + check-syntax|syntax-check) + echo "Checking syntax of $DAEMON_CONF: " + + ## this nice bit is from Edwin Groothuis: + ## check syntax (quiet) + $DAEMON_BIN $DHCPDv_OPT -q -t -cf $DAEMON_CONF + if ! [ $? -eq 0 ]; then + ## check syntax (verbose) + $DAEMON_BIN $DHCPDv_OPT -t -cf $DAEMON_CONF + echo -e '\nConfig is NOT okay\n' + else + echo 'Config is okay. Hope you also specified existent network devices ;) ' + + ## in v3, lease file checking is also implemented + if [ $DAEMON_BIN != "/usr/sbin/dhcpd-2" ]; then + ## check leases file (quiet) + $DAEMON_BIN $DHCPDv_OPT -q -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES + if ! [ $? -eq 0 ]; then + ## check leases file (verbose) + $DAEMON_BIN $DHCPDv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES + echo -e '\nLease file is NOT okay' + else + echo 'Lease file is okay' + fi + fi + fi + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|check-syntax} [-v]" + exit 1 +esac +rc_exit diff --git a/rc.dhcrelay b/rc.dhcrelay index d238669..bf6779b 100644 --- a/rc.dhcrelay +++ b/rc.dhcrelay @@ -2,8 +2,10 @@ # Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH # Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH # Copyright (c) 2002 SuSE Linux AG +# Copyright (c) 2003-2010 SUSE LINUX Products GmbH # # Author: Peter Poeml , 2001 +# Marius Tomaschewski , 2010 # # /etc/init.d/dhcrelay # and its symbolic link @@ -18,23 +20,23 @@ # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: DHCP Relay -# Description: Start DHCP (Dynamic Host Configuration Protocol) -# gateway, relaying DHCP requests from one -# physical network segment to another. +# Description: Start DHCP (Dynamic Host Configuration Protocol) +# relay agent, forwarding DHCP requests from one +# physical network segment to another. ### END INIT INFO - -test -s /etc/sysconfig/dhcrelay && \ - . /etc/sysconfig/dhcrelay - -DAEMON="dhcp relay agent" +DAEMON="ISC DHCPv4 relay agent" DAEMON_BIN=/usr/sbin/dhcrelay DAEMON_CONF=/etc/sysconfig/dhcrelay DAEMON_PIDFILE=/var/run/dhcrelay.pid STARTPROC_LOGFILE=/var/log/rc.dhcrelay.log SUPPORTS_HUP="no" -test -x $DAEMON_BIN || exit 5 +test -s "$DAEMON_CONF" && "$DAEMON_CONF" +test -x $DAEMON_BIN || { + echo >&2 "$0: \"$DAEMON_BIN\" is not executable." + test "x$1" = xstop && exit 0 || exit 5 +} # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status diff --git a/rc.dhcrelay6 b/rc.dhcrelay6 new file mode 100644 index 0000000..0207ed7 --- /dev/null +++ b/rc.dhcrelay6 @@ -0,0 +1,220 @@ +#! /bin/sh +# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH +# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH +# Copyright (c) 2002 SuSE Linux AG +# Copyright (c) 2003-2010 SUSE LINUX Products GmbH +# +# Author: Peter Poeml , 2001 +# Marius Tomaschewski , 2010 +# +# /etc/init.d/dhcrelay6 +# and its symbolic link +# /usr/sbin/rcdhcrelay6 +# +### BEGIN INIT INFO +# Provides: dhcrelay6 +# Required-Start: $network $remote_fs network-remotefs +# Should-Start: $named $syslog $time +# Required-Stop: $network $remote_fs network-remotefs +# Should-Stop: $named $syslog +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: DHCPv6 Relay +# Description: Start DHCPv6 (Dynamic Host Configuration Protocol) +# relay agent, forwarding DHCP requests from one +# physical network segment to another. +### END INIT INFO + + +DAEMON="ISC DHCPv6 relay agent" +DAEMON_BIN=/usr/sbin/dhcrelay6 +DAEMON_CONF=/etc/sysconfig/dhcrelay +DAEMON_PIDFILE=/var/run/dhcrelay6.pid +STARTPROC_LOGFILE=/var/log/rc.dhcrelay6.log +SUPPORTS_HUP="no" + +test -s "$DAEMON_CONF" && "$DAEMON_CONF" +test -x $DAEMON_BIN || { + echo >&2 "$0: \"$DAEMON_BIN\" is not executable." + test "x$1" = xstop && exit 0 || exit 5 +} + +# Shell functions sourced from /etc/rc.status: +# rc_check check and set local and overall rc status +# rc_status check and set local and overall rc status +# rc_status -v ditto but be verbose in local rc status +# rc_status -v -r ditto and clear the local rc status +# rc_failed set local and overall rc status to failed +# rc_failed set local and overall rc status to +# rc_reset clear local rc status (overall remains) +# rc_exit exit appropriate to overall rc status +. /etc/rc.status + +# First reset status of this service +rc_reset + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - insufficient privilege +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signalling is not supported) are +# considered a success. + +case "$1" in + start) + echo -n "Starting $DAEMON" + checkproc $DAEMON_BIN && { echo -n "... already running"; rc_status -v; exit 0; } + + for l in $DHCRELAY6_LOWER_INTERFACES ; do + test x"$l" = x && continue + DHCRELAY6_LOWER_INTERFACES_ARGS="$DHCRELAY6_LOWER_INTERFACES_ARGS -l $l" + done + for u in $DHCRELAY6_UPPER_INTERFACES ; do + test x"$u" = x && continue + DHCRELAY6_UPPER_INTERFACES_ARGS="$DHCRELAY6_UPPER_INTERFACES_ARGS -u $u" + done + + ## If interfaces or servers are not set, skip starting of dhcrelay + ## and return with "program not configured" + if [ "x$DHCRELAY6_LOWER_INTERFACES_ARGS" = x -o \ + "x$DHCRELAY6_UPPER_INTERFACES_ARGS" = x ]; then + # Tell the user this has skipped + rc_status -s + # service is not configured + exit 6; + fi + + + ## Start daemon with startproc(8). If this fails + ## the echo return value is set appropriate. + + # startproc should return 0, even if service is + # already running to match LSB spec. + test "$2" = "-v" && echo -en \ + "\nexecuting '$DAEMON_BIN $DHCRELAY6_OPTIONS $DHCRELAY6_LOWER_INTERFACES_ARGS $DHCRELAY6_UPPER_INTERFACES_ARGS'" + startproc -q -l $STARTPROC_LOGFILE $DAEMON_BIN $DHCRELAY6_OPTIONS $DHCRELAY6_LOWER_INTERFACES_ARGS $DHCRELAY6_UPPER_INTERFACES_ARGS + rc=$? + if ! [ $rc -eq 0 ]; then + if [ $link = $base ] ; then + ## be quiet + cat $STARTPROC_LOGFILE + else + ## be verbose + echo -e -n " please see $STARTPROC_LOGFILE for details "; + fi + ## set status to failed + rc_failed + fi + + # Remember status and be verbose + rc_status -v + ;; + stop) + echo -n "Shutting down $DAEMON" + ## Stop daemon with killproc(8) and if this fails + ## set echo the echo return value. + + killproc -p $DAEMON_PIDFILE -TERM $DAEMON_BIN + + # Remember status and be verbose + rc_status -v + ;; + try-restart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi + # Remember status and be quiet + rc_status + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + sleep 1 + $0 start + + # Remember status and be quiet + rc_status + ;; + force-reload) + ## Signal the daemon to reload its config. Most daemons + ## do this on signal 1 (SIGHUP). + ## If it does not support it, restart. + + $0 stop && sleep 1 && $0 start + rc_status + + echo -n "Reload service $DAEMON" + + if "$SUPPORTS_HUP" = "yes" ; then + killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $DAEMON_PIDFILE + rc_status -v + else + $0 stop && $0 start + rc_status + fi + ;; + reload) + ## Like force-reload, but if daemon does not support + ## signalling, do nothing (!) + + if "$SUPPORTS_HUP" = "yes" ; then + # If it supports signalling: + echo -n "Reload service $DAEMON" + killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN + #touch $DAEMON_PIDFILE + rc_status -v + else + ## Otherwise if it does not support reload: + rc_failed 3 + rc_status -v + fi + ;; + status) + echo -n "Checking for dhcp relay agent: " + ## Check status with checkproc(8), if process is running + ## checkproc will return with exit status 0. + + # Status has a slightly different for the status command: + # 0 - service running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running + + # NOTE: checkproc returns LSB compliant status values. + checkproc -p $DAEMON_PIDFILE $DAEMON_BIN + rc_status -v + ;; + probe) + ## Optional: Probe for the necessity of a reload, + ## give out the argument which is required for a reload. + + if [ "$DAEMON_CONF" -nt "$DAEMON_PIDFILE" ]; then + if [ "$SUPPORTS_HUP" = "yes" ]; then + echo reload + else + echo restart + fi + fi + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe} [-v]" + exit 1 + ;; +esac +rc_exit diff --git a/sysconfig.dhcpd b/sysconfig.dhcpd index 406cb88..7aab6fa 100644 --- a/sysconfig.dhcpd +++ b/sysconfig.dhcpd @@ -1,24 +1,38 @@ ## Path: Network/DHCP/DHCP server -## Description: DHCP server settings +## Description: DHCPv4 server settings ## Type: string ## Default: "" ## ServiceRestart: dhcpd # -# Interface(s) for the DHCP server to listen on. +# Interface(s) for the DHCPv4 server to listen on. # # A special keyword is ANY, it will cause dhcpd to autodetect available # interfaces. # -# Examples: DHCPD_INTERFACE="eth0" -# DHCPD_INTERFACE="eth0 eth1 eth2 tr0 wlan0" -# DHCPD_INTERFACE="internal0 internal1" +# Examples: DHCPD_INTERFACE="eth0 eth1 eth2" # DHCPD_INTERFACE="ANY" # DHCPD_INTERFACE="" +## Path: Network/DHCP/DHCP server +## Description: DHCPv6 server settings +## Type: string +## Default: "" +## ServiceRestart: dhcpd6 +# +# Interface(s) for the DHCPv6 server to listen on. +# +# A special keyword is ANY, it will cause dhcpd to autodetect available +# interfaces. +# +# Examples: DHCPD6_INTERFACE="eth0 eth1 eth2" +# DHCPD6_INTERFACE="ANY" +# +DHCPD6_INTERFACE="" + ## Type: list(yes,no,auto,) ## Default: -## Description: Restart dhcp server when interface goes up (again) +## Description: Restart dhcpv4 server when interface goes up (again) # # When the dhcp server is listening on a virtual interface, e.g. bridge, # bonding or vlan, and this interface gets deleted and recreated during @@ -38,6 +52,28 @@ DHCPD_INTERFACE="" # DHCPD_IFUP_RESTART="" +## Type: list(yes,no,auto,) +## Default: +## Description: Restart dhcpv6 server when interface goes up (again) +# +# When the dhcp server is listening on a virtual interface, e.g. bridge, +# bonding or vlan, and this interface gets deleted and recreated during +# a network restart, dhcpd will stop answering requests on this interface +# and needs a restart as well. +# Begining with SLE-10 SP3, we install an if-up.d post script (see ifup(8) +# and also ifservices(5)), enabled in auto mode by default. This variable +# can be used to force or avoid the dhcp server restart: +# +# no: do not restart dhcpd +# yes: force a dhcp server restart +# auto: (default) restart for virtual interfaces (bond,bridge,vlan) when +# all interfaces used in DHCPD_INTERFACE variable are up as well. +# +# Except of this global setting, the variable can be specified per interface +# in the interface configurations (/etc/sysconfig/network/ifcfg-$name). +# +DHCPD6_IFUP_RESTART="" + ## Type: yesno ## Default: yes ## ServiceRestart: dhcpd @@ -57,6 +93,25 @@ DHCPD_IFUP_RESTART="" # DHCPD_RUN_CHROOTED="yes" +## Type: yesno +## Default: yes +## ServiceRestart: dhcpd6 +# +# Shall the DHCP server dhcpd run in a chroot jail (/var/lib/dhcp)? +# +# Each time you start dhcpd with the init script, /etc/dhcpd.conf will +# be copied to /var/lib/dhcp/etc/. +# +# Some files that are important for hostname to IP address resolution +# (/etc/{gai.conf,nsswitch.conf,resolv.conf,host.conf,hosts,localtime}, +# /lib/lib{resolv.so.*,libnss_*.so.*,libpthread.so.0,libdl.so.2}) will +# also be copied to the chroot jail by the init script when you start +# it (less than 1MB altogether). +# +# The pid file will be in /var/lib/dhcp/var/run/dhcpd.pid. +# +DHCPD6_RUN_CHROOTED="yes" + ## Type: string ## Default: "" ## ServiceRestart: dhcpd @@ -73,6 +128,22 @@ DHCPD_RUN_CHROOTED="yes" # DHCPD_CONF_INCLUDE_FILES="" +## Type: string +## Default: "" +## ServiceRestart: dhcpd6 +# +# Since version 3, dhcpd.conf can contain include statements. +# If you enter the names of any include files here, _all_ conf +# files will be copied to $chroot/etc/, when dhcpd is started in the +# chroot jail. (/etc/dhcpd.conf is always copied.) +# +# For your convenience, you can also specify entire directories, like +# "/etc/dhcpd.conf.d". +# +# Example: "/etc/dhcpd.conf.shared /etc/dhcpd.conf.bootp-clients" +# +DHCPD6_CONF_INCLUDE_FILES="" + ## Type: string ## Default: "dhcpd" ## ServiceRestart: dhcpd @@ -82,6 +153,15 @@ DHCPD_CONF_INCLUDE_FILES="" # DHCPD_RUN_AS="dhcpd" +## Type: string +## Default: "dhcpd" +## ServiceRestart: dhcpd6 +# +# Leave empty or enter "root" to let dhcpd run as root. +# Enter "dhcpd" to run dhcpd as user 'dhcpd'. +# +DHCPD6_RUN_AS="dhcpd" + ## Type: string ## Default: "" ## ServiceRestart: dhcpd @@ -91,6 +171,15 @@ DHCPD_RUN_AS="dhcpd" # DHCPD_OTHER_ARGS="" +## Type: string +## Default: "" +## ServiceRestart: dhcpd6 +# +# Other arguments that you want dhcpd to be started with +# (e.g. "-p 1234" for a non-standard port to listen on) +# +DHCPD6_OTHER_ARGS="" + ## Type: string ## Default: "" ## ServiceRestart: dhcpd @@ -102,3 +191,14 @@ DHCPD_OTHER_ARGS="" # DHCPD_BINARY="" +## Type: string +## Default: "" +## ServiceRestart: dhcpd6 +# +# You may specify another dhcpd binary to be run. +# The full path needs to be specified. +# +# If empty, the default applies. +# +DHCPD6_BINARY="" + diff --git a/sysconfig.dhcrelay b/sysconfig.dhcrelay index 90923d9..c51c45c 100644 --- a/sysconfig.dhcrelay +++ b/sysconfig.dhcrelay @@ -4,11 +4,9 @@ ## Default: "" ## ServiceRestart: dhcrelay # -# Interface(s) for DHCP relay agent to listen on +# Interface(s) for DHCPv4 relay agent to listen on # -# Examples: DHCPD_INTERFACE="eth0" -# DHCPD_INTERFACE="eth0 eth1 eth2 tr0 wlan0" -# DHCPD_INTERFACE="internal0 internal1" +# Example: DHCPD_INTERFACE="eth0 eth1 eth2 wlan0" # DHCRELAY_INTERFACES="" @@ -16,7 +14,7 @@ DHCRELAY_INTERFACES="" ## Default: "" ## ServiceRestart: dhcrelay # -# DHCP servers to be used by DHCP relay agent +# DHCPv4 servers to be used by DHCPv4 relay agent # (separated by spaces, e.g. "192.168.0.11 191.168.0.12") # DHCRELAY_SERVERS="" @@ -25,8 +23,37 @@ DHCRELAY_SERVERS="" ## Default: "" ## ServiceRestart: dhcrelay # -# Additional options +# Additional DHCPv4 relay start options # Example: "-c 8" # DHCRELAY_OPTIONS="" +## Type: string +## Default: "" +## ServiceRestart: dhcrelay6 +# +# Specifies the ``lower'' network interface for DHCPv6 relay mode +# separated by spaces. +# The format of the lower interface is: "[address%]ifname[#index]". +# +DHCRELAY6_LOWER_INTERFACES_ARGS="" + +## Type: string +## Default: "" +## ServiceRestart: dhcrelay6 +# +# Specifies the ``upper'' network interface for DHCPv6 relay mode +# separated by spaces. +# The format of the upper interface is "[address%]ifname". +# +DHCRELAY6_UPPER_INTERFACES_ARGS="" + +## Type: string +## Default: "" +## ServiceRestart: dhcrelay6 +# +# Additional DHCPv6 relay start options +# Example: "-c 8 -I" +# +DHCRELAY6_OPTIONS="" + diff --git a/sysconfig.syslog-dhcpd b/sysconfig.syslog-dhcpd index 3da1710..95be31a 100644 --- a/sysconfig.syslog-dhcpd +++ b/sysconfig.syslog-dhcpd @@ -3,10 +3,24 @@ ## ServiceRestart: syslog # # The filename mentioned here will be added with the "-a ..." option as -# additional socket via SYSLOGD_PARAMS when syslogd is started. +# additional socket via SYSLOGD_PARAMS when syslogd is started or used +# to generate an include file for another syslog daemons. # -# This additional socket is needed in case that syslogd is restarted. Otherwise -# a chrooted dhcpd won't be able to continue logging. +# This additional socket is needed in case that syslogd is restarted. +# Otherwise a chrooted dhcpd won't be able to continue logging. # SYSLOGD_ADDITIONAL_SOCKET_DHCP="/var/lib/dhcp/dev/log" +## Type: string +## Default: "/var/lib/dhcp6/dev/log" +## ServiceRestart: syslog +# +# The filename mentioned here will be added with the "-a ..." option as +# additional socket via SYSLOGD_PARAMS when syslogd is started or used +# to generate an include file for another syslog daemons. +# +# This additional socket is needed in case that syslogd is restarted. +# Otherwise a chrooted dhcpd won't be able to continue logging. +# +SYSLOGD_ADDITIONAL_SOCKET_DHCP6="/var/lib/dhcp6/dev/log" +