diff options
Diffstat (limited to 'testing/dhcp')
-rw-r--r-- | testing/dhcp/PKGBUILD | 86 | ||||
-rw-r--r-- | testing/dhcp/dhclient-script-pathFixes.patch | 136 | ||||
-rw-r--r-- | testing/dhcp/dhcp | 10 | ||||
-rw-r--r-- | testing/dhcp/dhcp-4.1.1-missing-ipv6-not-fatal.patch | 39 | ||||
-rw-r--r-- | testing/dhcp/dhcp.conf.d | 6 | ||||
-rw-r--r-- | testing/dhcp/dhcp.install | 18 | ||||
-rw-r--r-- | testing/dhcp/dhcp4 | 57 | ||||
-rw-r--r-- | testing/dhcp/dhcp6 | 57 | ||||
-rwxr-xr-x | testing/dhcp/dhcpd | 40 |
9 files changed, 449 insertions, 0 deletions
diff --git a/testing/dhcp/PKGBUILD b/testing/dhcp/PKGBUILD new file mode 100644 index 000000000..05b00a406 --- /dev/null +++ b/testing/dhcp/PKGBUILD @@ -0,0 +1,86 @@ +# $Id: PKGBUILD 164255 2012-07-28 22:37:00Z eric $ +# Maintainer: Daniel Isenmann <daniel @archlinux.org> + +pkgbase=dhcp +pkgname=('dhcp' 'dhclient') + +# separate patch levels with a period to maintain proper versioning. +pkgver=4.2.4.1 +_pkgver=4.2.4-P1 + +pkgrel=1 +arch=('i686' 'x86_64') +license=('custom:isc-dhcp') +url="https://www.isc.org/software/dhcp" +makedepends=('bash' 'iproute2' 'net-tools') +source=(ftp://ftp.isc.org/isc/${pkgbase}/${_pkgver}/${pkgbase}-${_pkgver}.tar.gz{,.asc} + dhcp4 dhcp6 dhcp + dhcp-4.1.1-missing-ipv6-not-fatal.patch + dhclient-script-pathFixes.patch) +md5sums=('0ca7181024651f6323951d5498c8020b' + '0dfe000dd88555ea06b282ae5e574d5f' + 'c49b1497837ba56c54e401a66e1bab9b' + '12c2f3ae47ed23eb698eb7f1bfd80f20' + '8f357e46e1efcbb746f38737a3f977a2' + 'fd64aeb4f399dcc41ea43089a3811094' + '541b415a25a169eaf64b681405f79a80') + +build() { + cd "${srcdir}/${pkgbase}-${_pkgver}" + + # Define _GNU_SOURCE to fix IPV6. + sed '/^CFLAGS="$CFLAGS/ s/INGS"/INGS -D_GNU_SOURCE"/' -i configure + + # Make not having ipv6 non-fatal. + patch -Np0 -i "${srcdir}/dhcp-4.1.1-missing-ipv6-not-fatal.patch" + + ./configure --prefix=/usr --sysconfdir=/etc \ + --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \ + --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \ + --with-cli-lease-file=/var/state/dhclient/dhclient.leases \ + --with-cli6-lease-file=/var/state/dhclient/dhclient6.leases + + make + + patch -i "${srcdir}/dhclient-script-pathFixes.patch" client/scripts/linux +} + +package_dhcp(){ + pkgdesc="A DHCP server, client, and relay agent" + depends=('openssl>=0.9.8a') + backup=('etc/dhcpd.conf' 'etc/conf.d/dhcp') + install=dhcp.install + + cd "${srcdir}/${pkgbase}-${_pkgver}" + make DESTDIR="${pkgdir}" install + + install -D -m755 "${srcdir}/dhcp4" "${pkgdir}/etc/rc.d/dhcp4" + install -D -m755 "${srcdir}/dhcp6" "${pkgdir}/etc/rc.d/dhcp6" + install -D -m644 "${srcdir}/dhcp" "${pkgdir}/etc/conf.d/${pkgbase}" + install -d "${pkgdir}/var/state/dhcp" + + # Remove dhclient + make -C client DESTDIR="${pkgdir}" uninstall + + # install license + install -m644 -D LICENSE "${pkgdir}/usr/share/licenses/dhcp/LICENSE" +} + +package_dhclient(){ + pkgdesc="A standalone DHCP client from the dhcp package" + depends=('bash' 'iproute2' 'net-tools') + + cd "${srcdir}/${pkgbase}-${_pkgver}" + make -C client DESTDIR="${pkgdir}" install + + # move dhclient.conf to dhclient.conf.example + mv "${pkgdir}"/etc/dhclient.conf{,.example} + + install -d "${pkgdir}/var/state/dhclient" + + # install dhclient linux script + install -m755 -D client/scripts/linux "${pkgdir}/sbin/dhclient-script" + + # install license + install -m644 -D LICENSE "${pkgdir}/usr/share/licenses/dhclient/LICENSE" +} diff --git a/testing/dhcp/dhclient-script-pathFixes.patch b/testing/dhcp/dhclient-script-pathFixes.patch new file mode 100644 index 000000000..a4143ddde --- /dev/null +++ b/testing/dhcp/dhclient-script-pathFixes.patch @@ -0,0 +1,136 @@ +--- linux 2011-05-18 20:01:54.000000000 +0000 ++++ linux_new 2011-12-21 18:45:41.487171012 +0000 +@@ -23,7 +23,7 @@ + # of the $1 in its args. + + # 'ip' just looks too weird. /sbin/ip looks less weird. +-ip=/sbin/ip ++ip=/usr/sbin/ip + + make_resolv_conf() { + if [ x"$new_domain_name_servers" != x ]; then +@@ -122,9 +122,9 @@ + if [ x$reason = xPREINIT ]; then + if [ x$alias_ip_address != x ]; then + # Bring down alias interface. Its routes will disappear too. +- ifconfig $interface:0- inet 0 ++ /sbin/ifconfig $interface:0- inet 0 + fi +- ifconfig $interface 0 up ++ /sbin/ifconfig $interface 0 up + + # We need to give the kernel some time to get the interface up. + sleep 1 +@@ -151,25 +151,25 @@ + if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ + [ x$alias_ip_address != x$old_ip_address ]; then + # Possible new alias. Remove old alias. +- ifconfig $interface:0- inet 0 ++ /sbin/ifconfig $interface:0- inet 0 + fi + 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 ++ /sbin/ifconfig $interface inet 0 down + + fi + if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ + [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then + +- ifconfig $interface inet $new_ip_address $new_subnet_arg \ ++ /sbin/ifconfig $interface inet $new_ip_address $new_subnet_arg \ + $new_broadcast_arg $mtu_arg + # Add a network route to the computed network address. + for router in $new_routers; do + if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then +- route add -host $router dev $interface ++ /sbin/route add -host $router dev $interface + fi +- route add default gw $router $metric_arg dev $interface ++ /sbin/route add default gw $router $metric_arg dev $interface + done + else + # we haven't changed the address, have we changed other options +@@ -177,21 +177,21 @@ + if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then + # if we've changed routers delete the old and add the new. + for router in $old_routers; do +- route del default gw $router ++ /sbin/route del default gw $router + done + for router in $new_routers; do + if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then +- route add -host $router dev $interface ++ /sbin/route add -host $router dev $interface + fi +- route add default gw $router $metric_arg dev $interface ++ /sbin/route add default gw $router $metric_arg dev $interface + done + fi + 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 ++ /sbin/ifconfig $interface:0- inet 0 ++ /sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg ++ /sbin/route add -host $alias_ip_address $interface:0 + fi + make_resolv_conf + exit_with_hooks 0 +@@ -201,42 +201,42 @@ + || [ x$reason = xSTOP ]; then + if [ x$alias_ip_address != x ]; then + # Turn off alias interface. +- ifconfig $interface:0- inet 0 ++ /sbin/ifconfig $interface:0- inet 0 + fi + if [ x$old_ip_address != x ]; then + # Shut down interface, which will delete routes and clear arp cache. +- ifconfig $interface inet 0 down ++ /sbin/ifconfig $interface inet 0 down + fi + if [ x$alias_ip_address != x ]; then +- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg +- route add -host $alias_ip_address $interface:0 ++ /sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg ++ /sbin/route add -host $alias_ip_address $interface:0 + fi + exit_with_hooks 0 + fi + + if [ x$reason = xTIMEOUT ]; then + if [ x$alias_ip_address != x ]; then +- ifconfig $interface:0- inet 0 ++ /sbin/ifconfig $interface:0- inet 0 + fi +- ifconfig $interface inet $new_ip_address $new_subnet_arg \ ++ /sbin/ifconfig $interface inet $new_ip_address $new_subnet_arg \ + $new_broadcast_arg $mtu_arg + 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 +- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg +- route add -host $alias_ip_address dev $interface:0 ++ /sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg ++ /sbin/route add -host $alias_ip_address dev $interface:0 + fi + for router in $new_routers; do + if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then +- route add -host $router dev $interface ++ /sbin/route add -host $router dev $interface + fi +- route add default gw $router $metric_arg dev $interface ++ /sbin/route add default gw $router $metric_arg dev $interface + done + make_resolv_conf + exit_with_hooks 0 + fi +- ifconfig $interface inet 0 down ++ /sbin/ifconfig $interface inet 0 down + exit_with_hooks 1 + fi + diff --git a/testing/dhcp/dhcp b/testing/dhcp/dhcp new file mode 100644 index 000000000..d4f228d9c --- /dev/null +++ b/testing/dhcp/dhcp @@ -0,0 +1,10 @@ +# +# Arguments to be passed to the DHCP server daemon +# + +# ipv4 runtime parameters +DHCP4_ARGS="-q" + +# ipv6 runtime parameters +DHCP6_ARGS="-q" + diff --git a/testing/dhcp/dhcp-4.1.1-missing-ipv6-not-fatal.patch b/testing/dhcp/dhcp-4.1.1-missing-ipv6-not-fatal.patch new file mode 100644 index 000000000..cc5ddb843 --- /dev/null +++ b/testing/dhcp/dhcp-4.1.1-missing-ipv6-not-fatal.patch @@ -0,0 +1,39 @@ +--- common/discover.c 2009-09-29 21:44:49.000000000 +0200 ++++ common/discover.c_new 2010-06-30 19:40:02.000000000 +0200 +@@ -443,7 +443,7 @@ + } + + #ifdef DHCPv6 +- if (local_family == AF_INET6) { ++ if ((local_family == AF_INET6) && !access("/proc/net/if_inet6", R_OK)) { + ifaces->fp6 = fopen("/proc/net/if_inet6", "r"); + if (ifaces->fp6 == NULL) { + log_error("Error opening '/proc/net/if_inet6' to " +@@ -454,6 +454,8 @@ + ifaces->fp = NULL; + return 0; + } ++ } else { ++ ifaces->fp6 = NULL; + } + #endif + +@@ -721,7 +723,7 @@ + return 1; + } + #ifdef DHCPv6 +- if (!(*err)) { ++ if (!(*err) && ifaces->fp6) { + if (local_family == AF_INET6) + return next_iface6(info, err, ifaces); + } +@@ -740,7 +742,8 @@ + ifaces->sock = -1; + #ifdef DHCPv6 + if (local_family == AF_INET6) { +- fclose(ifaces->fp6); ++ if(ifaces->fp6) ++ fclose(ifaces->fp6); + ifaces->fp6 = NULL; + } + #endif diff --git a/testing/dhcp/dhcp.conf.d b/testing/dhcp/dhcp.conf.d new file mode 100644 index 000000000..99ba6d13d --- /dev/null +++ b/testing/dhcp/dhcp.conf.d @@ -0,0 +1,6 @@ +# +# Arguments to be passed to the DHCP server daemon +# + +DHCP_ARGS="-q" + diff --git a/testing/dhcp/dhcp.install b/testing/dhcp/dhcp.install new file mode 100644 index 000000000..5302be4b5 --- /dev/null +++ b/testing/dhcp/dhcp.install @@ -0,0 +1,18 @@ +# arg 1: the new package version +post_install() { + [ -f var/state/dhcp/dhcpd.leases ] || : >var/state/dhcp/dhcpd.leases + [ -f var/state/dhcp/dhcpd6.leases ] || : >var/state/dhcp/dhcpd6.leases + #echo "If dhcpd doesn't start, ensure the ipv6 kernel module is loaded." + + echo + echo "==> The dhcp server has now two rc.d scripts." + echo "==> Use '/etc/rc.d/dhcp6' to use IPv6 dhcp server or" + echo "==> '/etc/rc.d/dhcp4' to use IPv4 dhcp server." + echo "==> Make sure that you change your DAEMONS array in '/etc/rc.conf'!" +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + post_install $1 +} diff --git a/testing/dhcp/dhcp4 b/testing/dhcp/dhcp4 new file mode 100644 index 000000000..8e1277a37 --- /dev/null +++ b/testing/dhcp/dhcp4 @@ -0,0 +1,57 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/dhcp + +PIDFILE="/var/run/dhcpd.pid" + +if [[ -f $PIDFILE ]]; then + read -r PID < "$PIDFILE" + + # prevent stale pidfiles from hanging around + if [[ ! -d /proc/$PID ]]; then + echo 'pid not found. deleteing stale pidfile' + unset PID + rm -f "$PIDFILE" + fi +fi + +case "$1" in + start) + stat_busy "Starting DHCPv4 Server" + if [[ $PID ]]; then + stat_fail + exit 1 + fi + if /usr/sbin/dhcpd -4 -pf "$PIDFILE" $DHCP4_ARGS; then + add_daemon dhcp4 + stat_done + else + stat_fail + exit 1 + fi + ;; + stop) + stat_busy "Stopping DHCPv4 Server" + if [[ ! $PID ]]; then + stat_fail + exit 1 + fi + if { kill $PID && rm -f "$PIDFILE"; } &>/dev/null; then + rm_daemon dhcp4 + stat_done + else + stat_fail + exit 1 + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac + diff --git a/testing/dhcp/dhcp6 b/testing/dhcp/dhcp6 new file mode 100644 index 000000000..6b4b4d359 --- /dev/null +++ b/testing/dhcp/dhcp6 @@ -0,0 +1,57 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/dhcp + +PIDFILE="/var/run/dhcp6.pid" + +if [[ -f $PIDFILE ]]; then + read -r PID < "$PIDFILE" + + # prevent stale pidfiles from hanging around + if [[ ! -d /proc/$PID ]]; then + echo 'pid not found. deleteing stale pidfile' + unset PID + rm -f "$PIDFILE" + fi +fi + +case "$1" in + start) + stat_busy "Starting DHCPv6 Server" + if [[ $PID ]]; then + stat_fail + exit 1 + fi + if /usr/sbin/dhcpd -6 -pf "$PIDFILE" $DHCP6_ARGS; then + add_daemon dhcp6 + stat_done + else + stat_fail + exit 1 + fi + ;; + stop) + stat_busy "Stopping DHCPv6 Server" + if [[ ! $PID ]]; then + stat_fail + exit 1 + fi + if { kill $PID && rm -f "$PIDFILE"; } &>/dev/null; then + rm_daemon dhcp6 + stat_done + else + stat_fail + exit 1 + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac + diff --git a/testing/dhcp/dhcpd b/testing/dhcp/dhcpd new file mode 100755 index 000000000..1fbb31e7c --- /dev/null +++ b/testing/dhcp/dhcpd @@ -0,0 +1,40 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/dhcp + +PIDFILE="/var/run/dhcpd.pid" +PID=`cat $PIDFILE 2>/dev/null` +case "$1" in + start) + stat_busy "Starting DHCP Server" + if [ "$PID" = "" ]; then + /usr/sbin/dhcpd $DHCP_ARGS + fi + if [ "$PID" != "" -o $? -gt 0 ]; then + stat_fail + else + add_daemon dhcpd + stat_done + fi + ;; + stop) + stat_busy "Stopping DHCP Server" + [ ! -z "$PID" ] && kill $PID &> /dev/null + rm -f $PIDFILE + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon dhcpd + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac |