summaryrefslogtreecommitdiff
path: root/extra/dhcp
diff options
context:
space:
mode:
Diffstat (limited to 'extra/dhcp')
-rw-r--r--extra/dhcp/01-dhclient-script-fix-bare-ip.patch13
-rw-r--r--extra/dhcp/02-dhclient-script-remove-bashisms.patch28
-rw-r--r--extra/dhcp/03-fix-unwind-import.patch16
-rw-r--r--extra/dhcp/dhcpd.confd28
-rw-r--r--extra/dhcp/dhcpd.initd115
5 files changed, 200 insertions, 0 deletions
diff --git a/extra/dhcp/01-dhclient-script-fix-bare-ip.patch b/extra/dhcp/01-dhclient-script-fix-bare-ip.patch
new file mode 100644
index 0000000..7b3165d
--- /dev/null
+++ b/extra/dhcp/01-dhclient-script-fix-bare-ip.patch
@@ -0,0 +1,13 @@
+diff --git a/client/scripts/linux b/client/scripts/linux
+index 0c42969..3cd2a75 100755
+--- a/client/scripts/linux
++++ b/client/scripts/linux
+@@ -394,7 +394,7 @@ case "$reason" in
+ make_resolv_conf
+ else
+ # flush all IPs from interface
+- ip -4 addr flush dev ${interface}
++ ${ip} -4 addr flush dev ${interface}
+ exit_with_hooks 2
+ fi
+
diff --git a/extra/dhcp/02-dhclient-script-remove-bashisms.patch b/extra/dhcp/02-dhclient-script-remove-bashisms.patch
new file mode 100644
index 0000000..afa1048
--- /dev/null
+++ b/extra/dhcp/02-dhclient-script-remove-bashisms.patch
@@ -0,0 +1,28 @@
+diff --git a/client/scripts/linux b/client/scripts/linux
+index 0c42969..2e7274b 100755
+--- a/client/scripts/linux
++++ b/client/scripts/linux
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ # dhclient-script for Linux. Dan Halbert, March, 1997.
+ # Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
+ # No guarantees about this. I'm a novice at the details of Linux
+@@ -428,7 +428,7 @@ case "$reason" in
+ # Check if any IPv6 address on this interface is marked as
+ # tentative.
+ ${ip} addr show ${interface} | grep inet6 | grep tentative \
+- &> /dev/null
++ > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ # Wait for duplicate address detection to complete or for
+ # the timeout specified as --dad-wait-time.
+@@ -437,7 +437,7 @@ case "$reason" in
+ # We're going to poll for the tentative flag every second.
+ sleep 1
+ ${ip} addr show ${interface} | grep inet6 | grep tentative \
+- &> /dev/null
++ > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ break;
+ fi
diff --git a/extra/dhcp/03-fix-unwind-import.patch b/extra/dhcp/03-fix-unwind-import.patch
new file mode 100644
index 0000000..8b87fdb
--- /dev/null
+++ b/extra/dhcp/03-fix-unwind-import.patch
@@ -0,0 +1,16 @@
+bind assumes _Unwind_GetIP is a function which is not necessarily
+true. In some implementations of libunwind it's a macro.
+This fixes the build on Alpine on armhf and armv7.
+
+--- a/bind/bind-9.11.36/lib/isc/backtrace.c
++++ b/bind/bind-9.11.36/lib/isc/backtrace.c
+@@ -81,8 +81,7 @@ isc_backtrace_gettrace(void **addrs, int
+ return (ISC_R_SUCCESS);
+ }
+ #elif defined(BACKTRACE_GCC)
+-extern int _Unwind_Backtrace(void* fn, void* a);
+-extern void* _Unwind_GetIP(void* ctx);
++#include <unwind.h>
+
+ typedef struct {
+ void **result;
diff --git a/extra/dhcp/dhcpd.confd b/extra/dhcp/dhcpd.confd
new file mode 100644
index 0000000..5cd2eec
--- /dev/null
+++ b/extra/dhcp/dhcpd.confd
@@ -0,0 +1,28 @@
+# /etc/conf.d/dhcpd: config file for /etc/init.d/dhcpd
+
+# If you require more than one instance of dhcpd you can create symbolic
+# links to dhcpd service like so
+# cd /etc/init.d
+# ln -s dhcpd dhcpd.foo
+# cd ../conf.d
+# cp dhcpd dhcpd.foo
+# Now you can edit dhcpd.foo and specify a different configuration file.
+# You'll also need to specify a pidfile in that dhcpd.conf file.
+# See the pid-file-name option in the dhcpd.conf man page for details.
+
+# If you wish to run dhcpd in a chroot, uncomment the following line
+# DHCPD_CHROOT="/var/lib/dhcp/chroot"
+
+# All file paths below are relative to the chroot.
+# You can specify a different chroot directory but MAKE SURE it's empty.
+
+# Specify a configuration file - the default is /etc/dhcp/dhcpd.conf
+# DHCPD_CONF="/etc/dhcp/dhcpd.conf"
+
+# Configure which interface or interfaces to for dhcpd to listen on.
+# List all interfaces space separated. If this is not specified then
+# we listen on all interfaces.
+# DHCPD_IFACE=""
+
+# Insert any other dhcpd options - see the man page for a full list.
+# DHCPD_OPTS=""
diff --git a/extra/dhcp/dhcpd.initd b/extra/dhcp/dhcpd.initd
new file mode 100644
index 0000000..f69ae71
--- /dev/null
+++ b/extra/dhcp/dhcpd.initd
@@ -0,0 +1,115 @@
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcpd.init5,v 1.1 2011/12/04 22:45:07 vapier Exp $
+
+extra_commands="configtest"
+
+: ${DHCPD_CONF:=/etc/dhcp/${SVCNAME}.conf}
+
+depend() {
+ need net
+ after firewall
+ use logger dns
+}
+
+get_var() {
+ local var="$(sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' "${chroot}${DHCPD_CONF}")"
+ echo ${var:-$2}
+}
+
+checkconfig() {
+ set -- ${DHCPD_OPTS} ${chroot:+-chroot} ${chroot} -t
+
+ dhcpd "$@" 1>/dev/null 2>&1
+ local ret=$?
+ if [ ${ret} -ne 0 ] ; then
+ eerror "${SVCNAME} has detected a syntax error in your configuration files:"
+ dhcpd "$@"
+ fi
+
+ return ${ret}
+}
+
+configtest() {
+ local chroot=${DHCPD_CHROOT%/}
+
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
+ eend $?
+}
+
+start() {
+ local chroot=${DHCPD_CHROOT%/}
+
+ # Work out our cffile if it's in our DHCPD_OPTS
+ case " ${DHCPD_OPTS} " in
+ *" -cf "*)
+ DHCPD_CONF=" ${DHCPD_OPTS} "
+ DHCPD_CONF="${DHCPD_CONF##* -cf }"
+ DHCPD_CONF="${DHCPD_CONF%% *}"
+ ;;
+ *) DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}"
+ ;;
+ esac
+
+ if [ -n "${chroot}" ] ; then
+ # the config test want's these to exist
+ mkdir -p \
+ "${chroot}"/run/dhcp \
+ "${chroot}"/var/lib/dhcp \
+ "${chroot}"/etc/dhcp
+ fi
+
+ # see comment in get_var() above
+ if [ ! -f "${chroot}${DHCPD_CONF}" ] ; then
+ eerror "${chroot}${DHCPD_CONF} does not exist"
+ return 1
+ fi
+
+ checkconfig || return 1
+
+ checkpath -d -o dhcp:dhcp "${chroot}"/run/dhcp "${chroot}"/var/lib/dhcp
+
+ local leasefile="$(get_var lease-file-name /var/lib/dhcp/${SVCNAME}.leases)"
+ checkpath -f -o dhcp:dhcp "${chroot}${leasefile}"
+
+ # Setup LD_PRELOAD so name resolution works in our chroot.
+ if [ -n "${chroot}" ] ; then
+ checkpath -d -o root:root -m 755 "${chroot}"/dev "${chroot}"/etc "${chroot}"/proc
+ cp -pP /etc/localtime /etc/resolv.conf "${chroot}"/etc/
+ export LD_PRELOAD="${LD_PRELOAD} libresolv.so libnss_dns.so"
+ if ! mountinfo -q "${chroot}/proc" ; then
+ mount --bind /proc "${chroot}/proc"
+ fi
+ fi
+
+ local pidfile="$(get_var pid-file-name /run/dhcp/${SVCNAME}.pid)"
+
+ ebegin "Starting ${chroot:+chrooted }${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/dhcpd \
+ --pidfile "${chroot}/${pidfile}" \
+ -- ${DHCPD_OPTS} -q -pf "${pidfile}" -lf "${leasefile}" \
+ -user dhcp -group dhcp \
+ ${chroot:+-chroot} ${chroot} ${DHCPD_IFACE}
+ eend $? \
+ && save_options chroot "${chroot}" \
+ && save_options pidfile "${pidfile}"
+}
+
+stop() {
+ local chroot="$(get_options chroot)"
+
+ ebegin "Stopping ${chroot:+chrooted }${SVCNAME}"
+ start-stop-daemon --stop --exec /usr/sbin/dhcpd \
+ --pidfile "${chroot}/$(get_options pidfile)"
+ res=$?
+
+ if [ ${res} -eq 0 ] && [ -n "${chroot}" ] ; then
+ if mountinfo -q "${chroot}/proc" ; then
+ umount "${chroot}/proc"
+ fi
+ fi
+
+ eend $res
+}