diff options
Diffstat (limited to 'main/dhcp')
-rw-r--r-- | main/dhcp/APKBUILD | 84 | ||||
-rw-r--r-- | main/dhcp/dhcp-3.0-fix-perms.patch | 15 | ||||
-rw-r--r-- | main/dhcp/dhcp.post-install | 5 | ||||
-rw-r--r-- | main/dhcp/dhcp.post-upgrade | 19 | ||||
-rw-r--r-- | main/dhcp/dhcp.pre-install | 5 | ||||
-rw-r--r-- | main/dhcp/dhcp.pre-upgrade | 8 | ||||
-rw-r--r-- | main/dhcp/dhcpd.confd | 30 | ||||
-rw-r--r-- | main/dhcp/dhcpd.initd | 95 | ||||
-rw-r--r-- | main/dhcp/dhcrelay.confd | 13 | ||||
-rw-r--r-- | main/dhcp/dhcrelay.initd | 33 | ||||
-rw-r--r-- | main/dhcp/linux_ipv6_discover.patch | 50 |
11 files changed, 357 insertions, 0 deletions
diff --git a/main/dhcp/APKBUILD b/main/dhcp/APKBUILD new file mode 100644 index 0000000000..94f7f9c1dc --- /dev/null +++ b/main/dhcp/APKBUILD @@ -0,0 +1,84 @@ +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=dhcp +pkgver=4.2.1_p1 +_realver=${pkgver/_p/-P} +pkgrel=1 +pkgdesc="ISC Dynamic Host Configuration Protocol (DHCP)" +url="https://www.isc.org/" +arch="all" +license="ISC" +depends= +makedepends="perl" +install="dhcp.pre-install dhcp.post-install dhcp.pre-upgrade dhcp.post-upgrade" +subpackages="$pkgname-doc $pkgname-dev dhclient dhcrelay" +source="http://ftp.isc.org/isc/dhcp/$pkgname-$_realver.tar.gz + linux_ipv6_discover.patch + dhcp-3.0-fix-perms.patch + dhcrelay.initd + dhcrelay.confd + dhcpd.confd + dhcpd.initd" + +prepare() { + cd "$srcdir/$pkgname-$_realver" + patch -p1 -i "$srcdir"/dhcp-3.0-fix-perms.patch || return 1 + # patch -p1 -i ../linux_ipv6_discover.patch || return 1 +} + +build() { + cd "$srcdir/$pkgname-$_realver" + # fix ipv6 + export CFLAGS="$CFLAGS -D_GNU_SOURCE" + ./configure --prefix=/usr \ + --sysconfdir=/etc/dhcp \ + --with-cli-pid-file=/var/run/dhcp/dhclient.pid \ + --with-cli-lease-file=/var/lib/dhcp/dhclient.leases \ + --with-srv-pid-file=/var/run/dhcp/dhcpd.pid \ + --with-srv-lease-file=/var/lib/dhcp/dhcpd.leases \ + --with-relay-pid-file=/var/run/dhcp/dhcrelay.pid \ + --enable-dhcpv6 \ + --enable-paranoia \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info + make || return 1 +} + +package() { + cd "$srcdir/$pkgname-$_realver" + make DESTDIR="$pkgdir" install + + install -m755 -D "$srcdir"/dhcpd.initd "$pkgdir"/etc/init.d/dhcpd + install -m644 -D "$srcdir"/dhcpd.confd "$pkgdir"/etc/conf.d/dhcpd + install -d "$pkgdir"/var/lib/dhcp + install -d "$pkgdir"/var/run/dhcp +} + +dhclient() { + pkgdesc="ISC dhcp client" + install -d "$subpkgdir"/var/lib/dhcp + install -d "$subpkgdir"/var/run/dhcp + install -d "$subpkgdir"/usr/sbin + install -d "$subpkgdir"/etc/dhcp + mv "$pkgdir"/usr/sbin/dhclient "$subpkgdir"/usr/sbin/ + mv "$pkgdir"/etc/dhcp/dhclient.conf "$subpkgdir"/etc/dhcp/ +} + +dhcrelay() { + pkgdesc="ISC dhcp relay server" + replaces="dhcp" + install -d "$pkgdir"/var/run/dhcp + install -d "$subpkgdir"/usr/sbin + mv "$pkgdir"/usr/sbin/dhcrelay "$subpkgdir"/usr/sbin/ + install -m755 -D "$srcdir"/dhcrelay.initd \ + "$subpkgdir"/etc/init.d/dhcrelay + install -m644 -D "$srcdir"/dhcrelay.confd \ + "$subpkgdir"/etc/conf.d/dhcrelay +} + +md5sums="22e6f1eff6d5cfe2621a06cc62ba5b70 dhcp-4.2.1-P1.tar.gz +37abf1fb047a353e91b022fafdabf39a linux_ipv6_discover.patch +a9eaf182dae3984670da52f20ae10fba dhcp-3.0-fix-perms.patch +1597c012bb1a2c0828254c87f0a904ad dhcrelay.initd +db84514fe15fd7d81136afbaae738f55 dhcrelay.confd +df32707f5bbe5363306420b5dc6e6b40 dhcpd.confd +be2259371681bd4ab8a577b1b1a989ae dhcpd.initd" diff --git a/main/dhcp/dhcp-3.0-fix-perms.patch b/main/dhcp/dhcp-3.0-fix-perms.patch new file mode 100644 index 0000000000..78725c2c79 --- /dev/null +++ b/main/dhcp/dhcp-3.0-fix-perms.patch @@ -0,0 +1,15 @@ +--- a/server/dhcpd.c 2003-11-05 14:08:09.000000000 -0800 ++++ b/server/dhcpd.c 2003-11-05 14:15:32.000000000 -0800 +@@ -602,6 +602,12 @@ + if (lftest) + exit (0); + ++#if defined (PARANOIA) ++ /* Set proper permissions... */ ++ if (lchown (path_dhcpd_db, set_uid, set_gid)) ++ log_fatal ("lchown(%s, %d, %d): %m", path_dhcpd_db, (int) set_uid, (int) set_gid); ++#endif /* PARANOIA */ ++ + /* Discover all the network interfaces and initialize them. */ + discover_interfaces (DISCOVER_SERVER); + diff --git a/main/dhcp/dhcp.post-install b/main/dhcp/dhcp.post-install new file mode 100644 index 0000000000..01195dbd34 --- /dev/null +++ b/main/dhcp/dhcp.post-install @@ -0,0 +1,5 @@ +#!/bin/sh + +chown dhcp:dhcp var/run/dhcp var/lib/dhcp +exit 0 + diff --git a/main/dhcp/dhcp.post-upgrade b/main/dhcp/dhcp.post-upgrade new file mode 100644 index 0000000000..19df74a47b --- /dev/null +++ b/main/dhcp/dhcp.post-upgrade @@ -0,0 +1,19 @@ +#!/bin/sh + +# we have renamed dhcp to dhcpd. Try cleanup for users + +moved= +for i in /etc/runlevel/*/dhcp; do + if [ -L "$i" ]; then + rm $i + ln -s /etc/init.d/clamsmtpd ${i}d + moved=1 + fi +done + +if [ -n "$moved" ]; then + echo " *" + echo " * NOTICE: the /etc/init.d/dhcp script have been renamed to /etc/init.d/dhcpd" + echo " *" +fi + diff --git a/main/dhcp/dhcp.pre-install b/main/dhcp/dhcp.pre-install new file mode 100644 index 0000000000..9c623bfb9e --- /dev/null +++ b/main/dhcp/dhcp.pre-install @@ -0,0 +1,5 @@ +#!/bin/sh + +adduser -h /var/lib/dhcp -s /bin/false -D dhcp 2>/dev/null +exit 0 + diff --git a/main/dhcp/dhcp.pre-upgrade b/main/dhcp/dhcp.pre-upgrade new file mode 100644 index 0000000000..090f654b9a --- /dev/null +++ b/main/dhcp/dhcp.pre-upgrade @@ -0,0 +1,8 @@ +#!/bin/sh + +# script renamed. Try save users settings if needed + +if [ -f /etc/conf.d/dhcp ] && [ ! -f /etc/conf.d/dhcpd ]; then + mv /etc/conf.d/dhcp /etc/conf.d/dhcpd +fi + diff --git a/main/dhcp/dhcpd.confd b/main/dhcp/dhcpd.confd new file mode 100644 index 0000000000..df09ec7082 --- /dev/null +++ b/main/dhcp/dhcpd.confd @@ -0,0 +1,30 @@ +# /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="/chroot/dhcp" + +# Then run emerge dhcp --config +# 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/main/dhcp/dhcpd.initd b/main/dhcp/dhcpd.initd new file mode 100644 index 0000000000..447578c907 --- /dev/null +++ b/main/dhcp/dhcpd.initd @@ -0,0 +1,95 @@ +#!/sbin/runscript +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcpd.init2,v 1.1 2009/07/09 14:45:22 chainsaw Exp $ + +opts="configtest" + +DHCPD_CONF=${DHCPD_CONF:-/etc/dhcp/dhcpd.conf} + +depend() { + need net + after firewall + use logger dns +} + +get_var() { + sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' \ + "${DHCPD_CHROOT}/${DHCPD_CONF}" +} + +checkconfig() { + /usr/sbin/dhcpd -cf ${DHCPD_CHROOT}/${DHCPD_CONF} -t 1>/dev/null 2>&1 + ret=$? + if [ $ret -ne 0 ]; then + eerror "${SVCNAME} has detected a syntax error in your configuration files:" + /usr/sbin/dhcpd -cf ${DHCPD_CHROOT}/${DHCPD_CONF} -t + fi + + return $ret +} + +configtest() { + ebegin "Checking ${SVCNAME} configuration" + checkconfig + eend $? +} + +start() { + # Work out our cffile if it's on 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 [ ! -f "${DHCPD_CHROOT}/${DHCPD_CONF}" ] ; then + eerror "${DHCPD_CHROOT}/${DHCPD_CONF} does not exist" + return 1 + fi + + checkconfig || return 1 + + local leasefile="$(get_var lease-file-name)" + leasefile="${DHCPD_CHROOT}/${leasefile:-/var/lib/dhcp/dhcpd.leases}" + if [ ! -f "${leasefile}" ] ; then + ebegin "Creating ${leasefile}" + touch "${leasefile}" + chown dhcp:dhcp "${leasefile}" + eend $? || return 1 + fi + + # Setup LD_PRELOAD so name resolution works in our chroot. + if [ -n "${DHCPD_CHROOT}" ] ; then + LD_PRELOAD="${LD_PRELOAD} /usr/lib/libresolv.so" + export LD_PRELOAD="${LD_PRELOAD} /usr/lib/libnss_dns.so" + fi + + local pidfile="$(get_var pid-file-name)" + pidfile="${pidfile:-/var/run/dhcp/dhcpd.pid}" + + ebegin "Starting ${DHCPD_CHROOT:+chrooted }${SVCNAME}" + start-stop-daemon --start --exec /usr/sbin/dhcpd \ + --pidfile "${DHCPD_CHROOT}/${pidfile}" \ + -- ${DHCPD_OPTS} -q -pf "${pidfile}" \ + -user dhcp -group dhcp \ + ${DHCPD_CHROOT:+-chroot} ${DHCPD_CHROOT} ${DHCPD_IFACE} + eend $? \ + && save_options chroot "${DHCPD_CHROOT}" \ + && save_options pidfile "${pidfile}" +} + +stop() { + local chroot="$(get_options chroot)" + + checkconfig || return 1 + + ebegin "Stopping ${chroot:+chrooted }${SVCNAME}" + start-stop-daemon --stop --exec /usr/sbin/dhcpd \ + --pidfile "${chroot}/$(get_options pidfile)" + eend $? +} diff --git a/main/dhcp/dhcrelay.confd b/main/dhcp/dhcrelay.confd new file mode 100644 index 0000000000..1102d3a41b --- /dev/null +++ b/main/dhcp/dhcrelay.confd @@ -0,0 +1,13 @@ +# /etc/conf.d/dhcrelay: config file for /etc/init.d/dhcrelay + +# Configure which interface or interfaces to for dhcrelay to listen on +# and send to. +# List all interfaces space separated. If this is not specified then +# we use all interfaces. +#IFACE="" + +# Insert any other options needed. See dhcrelay(8) for details. +#DHCRELAY_OPTS="" + +# Space separated list of IPs to forward BOOTP/DHCP packets to. +DHCRELAY_SERVERS="" diff --git a/main/dhcp/dhcrelay.initd b/main/dhcp/dhcrelay.initd new file mode 100644 index 0000000000..2be915f313 --- /dev/null +++ b/main/dhcp/dhcrelay.initd @@ -0,0 +1,33 @@ +#!/sbin/runscript +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcrelay.init,v 1.2 2007/03/22 15:36:59 uberlord Exp $ + +depend() { + need net + use logger + after firewall +} + +start() { + if [ -z "${DHCRELAY_SERVERS}" ]; then + eerror "No DHCRELAY_SERVERS specified in /etc/conf.d/dhcrelay" + return 1 + fi + + local IFACES= i= + for i in ${IFACE} ; do + IFACES="${IFACES} -i ${i}" + done + + ebegin "Starting dhcrelay" + start-stop-daemon --start --exec /usr/sbin/dhcrelay \ + -- -q ${IFACES} ${DHCRELAY_OPTS} ${DHCRELAY_SERVERS} + eend $? +} + +stop() { + ebegin "Stopping dhcrelay" + start-stop-daemon --stop --pidfile /var/run/dhcp/dhcrelay.pid + eend $? +} diff --git a/main/dhcp/linux_ipv6_discover.patch b/main/dhcp/linux_ipv6_discover.patch new file mode 100644 index 0000000000..ebf3865e6a --- /dev/null +++ b/main/dhcp/linux_ipv6_discover.patch @@ -0,0 +1,50 @@ +diff -Naur dhcp-4.1.0a2/common/discover.c dhcp-4.1.0a2-mcn/common/discover.c +--- dhcp-4.1.0a2/common/discover.c 2008-08-29 18:48:57.000000000 +0100 ++++ dhcp-4.1.0a2-mcn/common/discover.c 2008-10-02 13:02:06.000000000 +0100 +@@ -443,15 +443,17 @@ + } + + #ifdef DHCPv6 +- ifaces->fp6 = fopen("/proc/net/if_inet6", "r"); +- if (ifaces->fp6 == NULL) { +- log_error("Error opening '/proc/net/if_inet6' to " +- "list IPv6 interfaces; %m"); +- close(ifaces->sock); +- ifaces->sock = -1; +- fclose(ifaces->fp); +- ifaces->fp = NULL; +- return 0; ++ if (local_family == AF_INET6) { ++ ifaces->fp6 = fopen("/proc/net/if_inet6", "r"); ++ if (ifaces->fp6 == NULL) { ++ log_error("Error opening '/proc/net/if_inet6' to " ++ "list IPv6 interfaces; %m"); ++ close(ifaces->sock); ++ ifaces->sock = -1; ++ fclose(ifaces->fp); ++ ifaces->fp = NULL; ++ return 0; ++ } + } + #endif + +@@ -720,7 +722,8 @@ + } + #ifdef DHCPv6 + if (!(*err)) { +- return next_iface6(info, err, ifaces); ++ if (local_family == AF_INET6) ++ return next_iface6(info, err, ifaces); + } + #endif + return 0; +@@ -736,7 +739,8 @@ + close(ifaces->sock); + ifaces->sock = -1; + #ifdef DHCPv6 +- fclose(ifaces->fp6); ++ if (local_family == AF_INET6) ++ fclose(ifaces->fp6); + ifaces->fp6 = NULL; + #endif + } |