summaryrefslogtreecommitdiff
path: root/repo/system/dhcp
diff options
context:
space:
mode:
Diffstat (limited to 'repo/system/dhcp')
-rw-r--r--repo/system/dhcp/01-dhclient-script-fix-bare-ip.patch13
-rw-r--r--repo/system/dhcp/02-dhclient-script-remove-bashisms.patch28
-rw-r--r--repo/system/dhcp/03-fix-unwind-import.patch16
-rw-r--r--repo/system/dhcp/dhcp.xibuild69
-rw-r--r--repo/system/dhcp/dhcpd.confd28
-rw-r--r--repo/system/dhcp/dhcpd.initd115
6 files changed, 269 insertions, 0 deletions
diff --git a/repo/system/dhcp/01-dhclient-script-fix-bare-ip.patch b/repo/system/dhcp/01-dhclient-script-fix-bare-ip.patch
new file mode 100644
index 0000000..7b3165d
--- /dev/null
+++ b/repo/system/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/repo/system/dhcp/02-dhclient-script-remove-bashisms.patch b/repo/system/dhcp/02-dhclient-script-remove-bashisms.patch
new file mode 100644
index 0000000..afa1048
--- /dev/null
+++ b/repo/system/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/repo/system/dhcp/03-fix-unwind-import.patch b/repo/system/dhcp/03-fix-unwind-import.patch
new file mode 100644
index 0000000..8b87fdb
--- /dev/null
+++ b/repo/system/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/repo/system/dhcp/dhcp.xibuild b/repo/system/dhcp/dhcp.xibuild
new file mode 100644
index 0000000..241dee1
--- /dev/null
+++ b/repo/system/dhcp/dhcp.xibuild
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+MAKEDEPS="bash iproute2 openldap"
+DEPS="musl libldap"
+
+PKG_VER=4.4.3b1
+SOURCE=https://ftp.isc.org/isc/dhcp/$PKG_VER/dhcp-$PKG_VER.tar.gz
+
+ADDITIONAL="
+01-dhclient-script-fix-bare-ip.patch
+02-dhclient-script-remove-bashisms.patch
+03-fix-unwind-import.patch
+dhcpd.confd
+dhcpd.initd
+"
+
+DESC="A DHCP server, client and relay"
+
+package () {
+ apply_patches
+
+ sed -i '/o.*dhcp_type/d' server/mdb.c &&
+ sed -r '/u.*(local|remote)_port/d' \
+ -i client/dhclient.c \
+ relay/dhcrelay.c
+}
+
+
+build () {
+ # fix ipv6
+
+ export CFLAGS="$CFLAGS -D_GNU_SOURCE \
+ -D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'"
+
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/dhcp \
+ --localstatedir=/var \
+ --with-srv-conf-file=/etc/dhcp/dhcpd.conf \
+ --with-srv-lease-file=/var/lib/dhcp/dhcpd.leases \
+ --with-srv6-lease-file=/var/lib/dhcp/dhcpd6.leases \
+ --with-cli-lease-file=/var/lib/dhcp/dhclient.leases \
+ --with-cli6-lease-file=/var/lib/dhcp/dhclient6.leases \
+ --with-srv-pid-file=/run/dhcp/dhcpd.pid \
+ --with-srv6-pid-file=/run/dhcp/dhcpd6.pid \
+ --with-cli-pid-file=/run/dhcp/dhclient.pid \
+ --with-cli6-pid-file=/run/dhcp/dhclient6.pid \
+ --with-relay-pid-file=/run/dhcp/dhcrelay.pid \
+ --with-relay6-pid-file=/run/dhcp/dhcrelay6.pid \
+ --with-libbind=no \
+ --enable-dhcpv4o6 \
+ --enable-paranoia \
+ --enable-log-pid \
+
+ make -j1 -C bind && make
+}
+
+package () {
+ make DESTDIR=$PKG_DEST install
+
+ install -d $PKG_DEST/var/lib/dhcp
+ install -d $PKG_DEST/run/dhcp
+
+
+ install -m755 -D dhcpd.initd $PKG_DEST/etc/init.d/dhcpd
+ install -m644 -D dhcpd.confd $PKG_DEST/etc/conf.d/dhcpd
+
+}
+
diff --git a/repo/system/dhcp/dhcpd.confd b/repo/system/dhcp/dhcpd.confd
new file mode 100644
index 0000000..5cd2eec
--- /dev/null
+++ b/repo/system/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/repo/system/dhcp/dhcpd.initd b/repo/system/dhcp/dhcpd.initd
new file mode 100644
index 0000000..f69ae71
--- /dev/null
+++ b/repo/system/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
+}