Переглянути джерело

dhcp: Add dhcp package

Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
Jun Yuan Tan 9 місяців тому
батько
коміт
7fa80aaaa7
28 змінених файлів з 1818 додано та 0 видалено
  1. 151 0
      recipes-connectivity/dhcp/dhcp.inc
  2. 27 0
      recipes-connectivity/dhcp/dhcp/0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch
  3. 62 0
      recipes-connectivity/dhcp/dhcp/0001-workaround-busybox-limitation-in-linux-dhclient-script.patch
  4. 114 0
      recipes-connectivity/dhcp/dhcp/0002-dhclient-dbus.patch
  5. 35 0
      recipes-connectivity/dhcp/dhcp/0003-link-with-lcrypto.patch
  6. 157 0
      recipes-connectivity/dhcp/dhcp/0004-Fix-out-of-tree-builds.patch
  7. 33 0
      recipes-connectivity/dhcp/dhcp/0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch
  8. 62 0
      recipes-connectivity/dhcp/dhcp/0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch
  9. 25 0
      recipes-connectivity/dhcp/dhcp/0009-remove-dhclient-script-bash-dependency.patch
  10. 223 0
      recipes-connectivity/dhcp/dhcp/0012-dhcp-correct-the-intention-for-xml2-lib-search.patch
  11. 64 0
      recipes-connectivity/dhcp/dhcp/0013-fixup_use_libbind.patch
  12. 93 0
      recipes-connectivity/dhcp/dhcp/0027-Add-missed-sd-notify-patch-to-manage-dhcpd-with-syst.patch
  13. 14 0
      recipes-connectivity/dhcp/dhcp/add-riscv-support.patch
  14. BIN
      recipes-connectivity/dhcp/dhcp/bind.tar.gz
  15. 13 0
      recipes-connectivity/dhcp/dhcp_%.bbappend
  16. 39 0
      recipes-connectivity/dhcp/dhcp_4.4.3.bb
  17. 12 0
      recipes-connectivity/dhcp/files/default-relay
  18. 7 0
      recipes-connectivity/dhcp/files/default-server
  19. 39 0
      recipes-connectivity/dhcp/files/dhclient-systemd-wrapper
  20. 50 0
      recipes-connectivity/dhcp/files/dhclient.conf
  21. 13 0
      recipes-connectivity/dhcp/files/dhclient.service
  22. 349 0
      recipes-connectivity/dhcp/files/dhcp-CLOEXEC.patch
  23. 108 0
      recipes-connectivity/dhcp/files/dhcpd.conf
  24. 15 0
      recipes-connectivity/dhcp/files/dhcpd.service
  25. 15 0
      recipes-connectivity/dhcp/files/dhcpd6.service
  26. 10 0
      recipes-connectivity/dhcp/files/dhcrelay.service
  27. 44 0
      recipes-connectivity/dhcp/files/init-relay
  28. 44 0
      recipes-connectivity/dhcp/files/init-server

+ 151 - 0
recipes-connectivity/dhcp/dhcp.inc

@@ -0,0 +1,151 @@
+SECTION = "console/network"
+SUMMARY = "Internet Software Consortium DHCP package"
+DESCRIPTION = "DHCP (Dynamic Host Configuration Protocol) is a protocol \
+which allows individual devices on an IP network to get their own \
+network configuration information from a server.  DHCP helps make it \
+easier to administer devices."
+
+HOMEPAGE = "http://www.isc.org/"
+
+LICENSE = "ISC"
+LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;md5=613211e713c4ffc489ec370e1caceabb"
+
+DEPENDS = "openssl bind"
+
+SRC_URI = "http://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
+           file://init-relay file://default-relay \
+           file://init-server file://default-server \
+           file://dhclient.conf file://dhcpd.conf \
+           file://dhclient-systemd-wrapper \
+           file://dhclient.service \
+           file://dhcpd.service file://dhcrelay.service \
+           file://dhcpd6.service \
+           "
+UPSTREAM_CHECK_URI = "http://ftp.isc.org/isc/dhcp/"
+UPSTREAM_CHECK_REGEX = "(?P<pver>\d+\.\d+\.(\d+?))/"
+
+inherit autotools-brokensep systemd useradd update-rc.d
+
+USERADD_PACKAGES = "${PN}-server"
+USERADD_PARAM:${PN}-server = "--system --no-create-home --home-dir /var/run/${BPN} --shell /bin/false --user-group ${BPN}"
+
+SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client"
+SYSTEMD_SERVICE:${PN}-server = "dhcpd.service dhcpd6.service"
+SYSTEMD_AUTO_ENABLE:${PN}-server = "disable"
+
+SYSTEMD_SERVICE:${PN}-relay = "dhcrelay.service"
+SYSTEMD_AUTO_ENABLE:${PN}-relay = "disable"
+
+SYSTEMD_SERVICE:${PN}-client = "dhclient.service"
+SYSTEMD_AUTO_ENABLE:${PN}-client = "disable"
+
+INITSCRIPT_PACKAGES = "dhcp-server"
+INITSCRIPT_NAME:dhcp-server = "dhcp-server"
+INITSCRIPT_PARAMS:dhcp-server = "defaults"
+
+CFLAGS += "-D_GNU_SOURCE"
+EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \
+                --with-srv6-lease-file=${localstatedir}/lib/dhcp/dhcpd6.leases \
+                --with-cli-lease-file=${localstatedir}/lib/dhcp/dhclient.leases \
+                --with-cli6-lease-file=${localstatedir}/lib/dhcp/dhclient6.leases \
+                --enable-paranoia --disable-static \
+                --with-randomdev=/dev/random \
+                 \
+		--enable-libtool \
+               "
+
+PACKAGECONFIG[system-libbind] = "--with-libbind=${STAGING_DIR_HOST},--without-libbind,bind"
+
+#Enable shared libs per dhcp README
+do_configure:prepend () {
+	cp configure.ac+lt configure.ac
+}
+
+do_install:append () {
+	install -d ${D}${sysconfdir}/init.d
+	install -d ${D}${sysconfdir}/default
+	install -d ${D}${sysconfdir}/dhcp
+	install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
+	install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
+	install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
+	install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
+
+	rm -f ${D}${sysconfdir}/dhclient.conf*
+	rm -f ${D}${sysconfdir}/dhcpd.conf*
+	install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
+	install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
+
+	install -d ${D}${base_sbindir}/
+	if [ "${sbindir}" != "${base_sbindir}" ]; then
+		mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
+	fi
+	install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
+
+	# Install systemd unit files
+	install -d ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
+	sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service
+	sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
+	sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
+	sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
+	sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
+
+	install -d ${D}${base_sbindir}
+	install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper
+	install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system
+	sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service
+	sed -i -e 's,@BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service
+}
+
+PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
+
+PACKAGES:remove = "${PN}"
+RDEPENDS:${PN}-client += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'iproute2', '', d)}"
+RDEPENDS:${PN}-dev = ""
+RDEPENDS:${PN}-staticdev = ""
+FILES:${PN}-libs = "${libdir}/libdhcpctl.so.0* ${libdir}/libomapi.so.0* ${libdir}/libdhcp.so.0*"
+
+FILES:${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server"
+RRECOMMENDS:${PN}-server = "dhcp-server-config"
+
+FILES:${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
+
+FILES:${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
+
+FILES:${PN}-client = "${base_sbindir}/dhclient \
+                      ${base_sbindir}/dhclient-script \
+                      ${sysconfdir}/dhcp/dhclient.conf \
+                      ${base_sbindir}/dhclient-systemd-wrapper \
+                     "
+
+FILES:${PN}-omshell = "${bindir}/omshell"
+
+pkg_postinst:dhcp-server() {
+    mkdir -p $D/${localstatedir}/lib/dhcp
+    touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
+    touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
+}
+
+pkg_postinst:dhcp-client() {
+    mkdir -p $D/${localstatedir}/lib/dhcp
+}
+
+pkg_postrm:dhcp-server() {
+    rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
+    rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
+
+    if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
+        echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
+    fi
+}
+
+pkg_postrm:dhcp-client() {
+    rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
+    rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
+
+    if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
+        echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
+    fi
+}

+ 27 - 0
recipes-connectivity/dhcp/dhcp/0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch

@@ -0,0 +1,27 @@
+From 7cc29144535a622fc671dc86eb1da65b0473a7c4 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 16:14:22 +0800
+Subject: [PATCH 01/11] define macro _PATH_DHCPD_CONF and _PATH_DHCLIENT_CONF
+
+Upstream-Status: Inappropriate [OE specific]
+
+Rebase to 4.3.6
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ includes/site.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+Index: dhcp-4.4.3/includes/site.h
+===================================================================
+--- dhcp-4.4.3.orig/includes/site.h
++++ dhcp-4.4.3/includes/site.h
+@@ -148,7 +148,8 @@
+ /* Define this if you want the dhcpd.conf file to go somewhere other than
+    the default location.   By default, it goes in /etc/dhcpd.conf. */
+ 
+-/* #define _PATH_DHCPD_CONF	"/etc/dhcpd.conf" */
++#define _PATH_DHCPD_CONF	"/etc/dhcp/dhcpd.conf"
++#define _PATH_DHCLIENT_CONF	"/etc/dhcp/dhclient.conf"
+ 
+ /* Network API definitions.   You do not need to choose one of these - if
+    you don't choose, one will be chosen for you in your system's config

+ 62 - 0
recipes-connectivity/dhcp/dhcp/0001-workaround-busybox-limitation-in-linux-dhclient-script.patch

@@ -0,0 +1,62 @@
+From eec0503cfc36f63d777f5cb3f2719cecedcb8468 Mon Sep 17 00:00:00 2001
+From: Haris Okanovic <haris.okanovic@ni.com>
+Date: Mon, 7 Jan 2019 13:22:09 -0600
+Subject: [PATCH] Workaround busybox limitation in Linux dhclient-script
+
+Busybox is a lightweight implementation of coreutils commonly used on
+space-constrained embedded Linux distributions. It's implementation of
+chown and chmod doesn't provide a "--reference" option added to
+client/scripts/linux as of commit 9261cb14. This change works around
+that limitation by using stat to read ownership and permissions flags
+and simple chown/chmod calls supported in both coreutils and busybox.
+
+    modified:   client/scripts/linux
+
+Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
+Upstream-Status: Pending [ISC-Bugs #48771]
+---
+ client/scripts/linux | 17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+Index: dhcp-4.4.3/client/scripts/linux
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/linux
++++ dhcp-4.4.3/client/scripts/linux
+@@ -32,6 +32,17 @@
+ # if your system holds ip tool in a non-standard location.
+ ip=/sbin/ip
+ 
++chown_chmod_by_reference() {
++    local reference_file="$1"
++    local target_file="$2"
++
++    local owner=$(stat -c "%u:%g" "$reference_file")
++    local perm=$(stat -c "%a" "$reference_file")
++
++    chown "$owner" "$target_file"
++    chmod "$perm" "$target_file"
++}
++
+ # update /etc/resolv.conf based on received values
+ # This updated version mostly follows Debian script by Andrew Pollock et al.
+ make_resolv_conf() {
+@@ -74,8 +85,7 @@ make_resolv_conf() {
+         fi
+ 
+ 	if [ -f /etc/resolv.conf ]; then
+-	    chown --reference=/etc/resolv.conf $new_resolv_conf
+-	    chmod --reference=/etc/resolv.conf $new_resolv_conf
++	    chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
+ 	fi
+         mv -f $new_resolv_conf /etc/resolv.conf
+     # DHCPv6
+@@ -101,8 +111,7 @@ make_resolv_conf() {
+         fi
+ 
+ 	if [ -f /etc/resolv.conf ]; then
+-            chown --reference=/etc/resolv.conf $new_resolv_conf
+-            chmod --reference=/etc/resolv.conf $new_resolv_conf
++	    chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
+ 	fi
+         mv -f $new_resolv_conf /etc/resolv.conf
+     fi

+ 114 - 0
recipes-connectivity/dhcp/dhcp/0002-dhclient-dbus.patch

@@ -0,0 +1,114 @@
+From be7540d31c356e80ee02e90e8bf162b7ac6e5ba5 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 14:56:56 +0800
+Subject: [PATCH 02/11] dhclient dbus
+
+Upstream-Status: Inappropriate [distribution]
+
+Rebase to 4.3.6
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ client/scripts/bsdos   | 5 +++++
+ client/scripts/freebsd | 5 +++++
+ client/scripts/linux   | 5 +++++
+ client/scripts/netbsd  | 5 +++++
+ client/scripts/openbsd | 5 +++++
+ client/scripts/solaris | 5 +++++
+ 6 files changed, 30 insertions(+)
+
+Index: dhcp-4.4.3/client/scripts/bsdos
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/bsdos
++++ dhcp-4.4.3/client/scripts/bsdos
+@@ -45,6 +45,11 @@ exit_with_hooks() {
+     . /etc/dhclient-exit-hooks
+   fi
+ # probably should do something with exit status of the local script
++  if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++    dbus-send --system --dest=com.redhat.dhcp \
++      --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++      'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++  fi
+   exit $exit_status
+ }
+ 
+Index: dhcp-4.4.3/client/scripts/freebsd
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/freebsd
++++ dhcp-4.4.3/client/scripts/freebsd
+@@ -89,6 +89,11 @@ exit_with_hooks() {
+     . /etc/dhclient-exit-hooks
+   fi
+ # probably should do something with exit status of the local script
++  if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++    dbus-send --system --dest=com.redhat.dhcp \
++      --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++      'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++  fi
+   exit $exit_status
+ }
+ 
+Index: dhcp-4.4.3/client/scripts/linux
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/linux
++++ dhcp-4.4.3/client/scripts/linux
+@@ -174,6 +174,11 @@ exit_with_hooks() {
+         exit_status=$?
+     fi
+ 
++    if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++        dbus-send --system --dest=com.redhat.dhcp \
++           --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++           'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++    fi
+     exit $exit_status
+ }
+ 
+Index: dhcp-4.4.3/client/scripts/netbsd
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/netbsd
++++ dhcp-4.4.3/client/scripts/netbsd
+@@ -45,6 +45,11 @@ exit_with_hooks() {
+     . /etc/dhclient-exit-hooks
+   fi
+ # probably should do something with exit status of the local script
++  if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++    dbus-send --system --dest=com.redhat.dhcp \
++      --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++      'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++  fi
+   exit $exit_status
+ }
+ 
+Index: dhcp-4.4.3/client/scripts/openbsd
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/openbsd
++++ dhcp-4.4.3/client/scripts/openbsd
+@@ -45,6 +45,11 @@ exit_with_hooks() {
+     . /etc/dhclient-exit-hooks
+   fi
+ # probably should do something with exit status of the local script
++  if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++    dbus-send --system --dest=com.redhat.dhcp \
++      --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++      'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++  fi
+   exit $exit_status
+ }
+ 
+Index: dhcp-4.4.3/client/scripts/solaris
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/solaris
++++ dhcp-4.4.3/client/scripts/solaris
+@@ -26,6 +26,11 @@ exit_with_hooks() {
+     . /etc/dhclient-exit-hooks
+   fi
+ # probably should do something with exit status of the local script
++  if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
++    dbus-send --system --dest=com.redhat.dhcp \
++      --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
++      'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
++  fi
+   exit $exit_status
+ }
+ 

+ 35 - 0
recipes-connectivity/dhcp/dhcp/0003-link-with-lcrypto.patch

@@ -0,0 +1,35 @@
+From d80bd792323dbd56269309f85b4506eb6b1b60e9 Mon Sep 17 00:00:00 2001
+From: Andrei Gherzan <andrei@gherzan.ro>
+Date: Tue, 15 Aug 2017 15:05:47 +0800
+Subject: [PATCH 03/11] link with lcrypto
+
+From 4.2.0 final release, -lcrypto check was removed and we compile
+static libraries
+from bind that are linked to libcrypto. This is why i added a patch in
+order to add
+-lcrypto to LIBS.
+
+Upstream-Status: Pending
+Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
+
+Rebase to 4.3.6
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ configure.ac | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+Index: dhcp-4.4.3/configure.ac
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac
++++ dhcp-4.4.3/configure.ac
+@@ -603,6 +603,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
+ # Look for optional headers.
+ AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
+ 
++# find an MD5 library
++AC_SEARCH_LIBS(MD5_Init, [crypto])
++AC_SEARCH_LIBS(MD5Init, [crypto])
++
+ # Solaris needs some libraries for functions
+ AC_SEARCH_LIBS(socket, [socket])
+ AC_SEARCH_LIBS(inet_ntoa, [nsl])

+ 157 - 0
recipes-connectivity/dhcp/dhcp/0004-Fix-out-of-tree-builds.patch

@@ -0,0 +1,157 @@
+From cccec0344d68dac4100b6f260ee24e7c2da9dfda Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 15:08:22 +0800
+Subject: [PATCH 04/11] Fix out of tree builds
+
+Upstream-Status: Pending
+
+RP 2013/03/21
+
+Rebase to 4.3.6
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ client/Makefile.am  | 4 ++--
+ common/Makefile.am  | 3 ++-
+ dhcpctl/Makefile.am | 2 ++
+ omapip/Makefile.am  | 1 +
+ relay/Makefile.am   | 2 +-
+ server/Makefile.am  | 2 +-
+ 6 files changed, 9 insertions(+), 5 deletions(-)
+
+Index: dhcp-4.4.3/common/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/common/Makefile.am
++++ dhcp-4.4.3/common/Makefile.am
+@@ -1,8 +1,8 @@
+ AM_CPPFLAGS = -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"'
+ AM_CFLAGS = $(LDAP_CFLAGS)
+ 
+-lib_LIBRARIES = libdhcp.a
+-libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c dhcp4o6.c \
++lib_LTLIBRARIES = libdhcp.la
++libdhcp_la_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c dhcp4o6.c \
+ 		      discover.c dispatch.c dlpi.c dns.c ethernet.c execute.c \
+ 		      fddi.c icmp.c inet.c lpf.c memory.c nit.c ns_name.c \
+ 		      options.c packet.c parse.c print.c raw.c resolv.c \
+Index: dhcp-4.4.3/dhcpctl/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/dhcpctl/Makefile.am
++++ dhcp-4.4.3/dhcpctl/Makefile.am
+@@ -4,30 +4,30 @@ BINDLIBISCCFGDIR=@BINDLIBISCCFGDIR@
+ BINDLIBISCDIR=@BINDLIBISCDIR@
+ 
+ bin_PROGRAMS = omshell
+-lib_LIBRARIES = libdhcpctl.a
++lib_LTLIBRARIES = libdhcpctl.la
+ noinst_PROGRAMS = cltest cltest2
+ man_MANS = omshell.1 dhcpctl.3
+ EXTRA_DIST = $(man_MANS)
+ 
+ omshell_SOURCES = omshell.c
+-omshell_LDADD = libdhcpctl.a ../common/libdhcp.a ../omapip/libomapi.a \
+-		$(BINDLIBIRSDIR)/libirs.a \
+-		$(BINDLIBDNSDIR)/libdns.a \
+-	        $(BINDLIBISCCFGDIR)/libisccfg.a \
+-		$(BINDLIBISCDIR)/libisc.a
++omshell_LDADD = libdhcpctl.la ../common/libdhcp.la ../omapip/libomapi.la \
++		$(BINDLIBIRSDIR)/libirs.la \
++		$(BINDLIBDNSDIR)/libdns.la \
++	        $(BINDLIBISCCFGDIR)/libisccfg.la \
++		$(BINDLIBISCDIR)/libisc.la
+ 
+-libdhcpctl_a_SOURCES = dhcpctl.c callback.c remote.c
++libdhcpctl_la_SOURCES = dhcpctl.c callback.c remote.c
+ 
+ cltest_SOURCES = cltest.c
+-cltest_LDADD = libdhcpctl.a ../common/libdhcp.a ../omapip/libomapi.a \
+-	       $(BINDLIBIRSDIR)/libirs.a \
+-	       $(BINDLIBDNSDIR)/libdns.a \
+-	       $(BINDLIBISCCFGDIR)/libisccfg.a \
+-	       $(BINDLIBISCDIR)/libisc.a
++cltest_LDADD = libdhcpctl.la ../common/libdhcp.la ../omapip/libomapi.la \
++	       $(BINDLIBIRSDIR)/libirs.la \
++	       $(BINDLIBDNSDIR)/libdns.la \
++	       $(BINDLIBISCCFGDIR)/libisccfg.la \
++	       $(BINDLIBISCDIR)/libisc.la
+ 
+ cltest2_SOURCES = cltest2.c
+-cltest2_LDADD = libdhcpctl.a ../common/libdhcp.a ../omapip/libomapi.a \
+-	       $(BINDLIBIRSDIR)/libirs.a \
+-	       $(BINDLIBDNSDIR)/libdns.a \
+-	       $(BINDLIBISCCFGDIR)/libisccfg.a \
+-	       $(BINDLIBISCDIR)/libisc.a
++cltest2_LDADD = libdhcpctl.la ../common/libdhcp.la ../omapip/libomapi.la \
++	       $(BINDLIBIRSDIR)/libirs.la \
++	       $(BINDLIBDNSDIR)/libdns.la \
++	       $(BINDLIBISCCFGDIR)/libisccfg.la \
++	       $(BINDLIBISCDIR)/libisc.la
+Index: dhcp-4.4.3/server/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/server/Makefile.am
++++ dhcp-4.4.3/server/Makefile.am
+@@ -4,7 +4,7 @@
+ # production code. Sadly, we are not there yet.
+ SUBDIRS = . tests
+ 
+-AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
++AM_CPPFLAGS = -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"' -I$(top_srcdir)/includes
+ 
+ dist_sysconf_DATA = dhcpd.conf.example
+ sbin_PROGRAMS = dhcpd
+Index: dhcp-4.4.3/client/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/client/Makefile.am
++++ dhcp-4.4.3/client/Makefile.am
+@@ -5,7 +5,7 @@
+ SUBDIRS = . tests
+ 
+ AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"'
+-AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"'
++AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"' -I$(top_srcdir)/includes
+ 
+ dist_sysconf_DATA = dhclient.conf.example
+ sbin_PROGRAMS = dhclient
+Index: dhcp-4.4.3/omapip/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/omapip/Makefile.am
++++ dhcp-4.4.3/omapip/Makefile.am
+@@ -3,10 +3,10 @@ BINDLIBDNSDIR=@BINDLIBDNSDIR@
+ BINDLIBISCCFGDIR=@BINDLIBISCCFGDIR@
+ BINDLIBISCDIR=@BINDLIBISCDIR@
+ 
+-lib_LIBRARIES = libomapi.a
++lib_LTLIBRARIES = libomapi.la
+ noinst_PROGRAMS = svtest
+ 
+-libomapi_a_SOURCES = protocol.c buffer.c alloc.c result.c connection.c \
++libomapi_la_SOURCES = protocol.c buffer.c alloc.c result.c connection.c \
+ 		       errwarn.c listener.c dispatch.c generic.c support.c \
+ 		       handle.c message.c convert.c hash.c auth.c inet_addr.c \
+ 		       array.c trace.c toisc.c iscprint.c isclib.c
+@@ -15,8 +15,8 @@ man_MANS = omapi.3
+ EXTRA_DIST = $(man_MANS)
+ 
+ svtest_SOURCES = test.c
+-svtest_LDADD = libomapi.a \
+-	       $(BINDLIBIRSDIR)/libirs.a \
+-	       $(BINDLIBDNSDIR)/libdns.a \
+-	       $(BINDLIBISCCFGDIR)/libisccfg.a \
+-	       $(BINDLIBISCDIR)/libisc.a
++svtest_LDADD = libomapi.la \
++	       $(BINDLIBIRSDIR)/libirs.la \
++	       $(BINDLIBDNSDIR)/libdns.la \
++	       $(BINDLIBISCCFGDIR)/libisccfg.la \
++	       $(BINDLIBISCDIR)/libisc.la
+Index: dhcp-4.4.3/relay/Makefile.am
+===================================================================
+--- dhcp-4.4.3.orig/relay/Makefile.am
++++ dhcp-4.4.3/relay/Makefile.am
+@@ -1,6 +1,6 @@
+ SUBDIRS = . tests
+ 
+-AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"'
++AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"' -I$(top_srcdir)/includes
+ 
+ sbin_PROGRAMS = dhcrelay
+ dhcrelay_SOURCES = dhcrelay.c

+ 33 - 0
recipes-connectivity/dhcp/dhcp/0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch

@@ -0,0 +1,33 @@
+From 2e8ff0e4f6d39e346ea86b8c514ab4ccc78fa359 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 15:24:14 +0800
+Subject: [PATCH 05/11] dhcp-client: fix invoke dhclient-script failed on
+ Read-only file system
+
+In read-only file system, '/etc' is on the readonly partition,
+and '/etc/resolv.conf' is symlinked to a separate writable
+partition.
+
+In this situation, we create temp files 'resolv.conf.dhclient-new'
+in /tmp dir.
+
+Upstream-Status: Pending
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ client/scripts/linux | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: dhcp-4.4.3/client/scripts/linux
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/linux
++++ dhcp-4.4.3/client/scripts/linux
+@@ -40,7 +40,7 @@ make_resolv_conf() {
+     # DHCPv4
+     if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
+        [ -n "$new_domain_name_servers" ]; then
+-        new_resolv_conf=/etc/resolv.conf.dhclient-new
++        new_resolv_conf=/tmp/resolv.conf.dhclient-new
+         rm -f $new_resolv_conf
+ 
+         if [ -n "$new_domain_name" ]; then

+ 62 - 0
recipes-connectivity/dhcp/dhcp/0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch

@@ -0,0 +1,62 @@
+From 7107511fd209f08f9a96f8938041ae48f3295895 Mon Sep 17 00:00:00 2001
+From: Christopher Larson <chris_larson@mentor.com>
+Date: Tue, 15 Aug 2017 16:17:49 +0800
+Subject: [PATCH 07/11] Add configure argument to make the libxml2 dependency
+ explicit and determinisitic.
+
+Upstream-Status: Pending
+
+Signed-off-by: Christopher Larson <chris_larson@mentor.com>
+
+Rebase to 4.3.6
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ configure.ac | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+Index: dhcp-4.4.3/configure.ac
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac
++++ dhcp-4.4.3/configure.ac
+@@ -633,6 +633,17 @@ if test "$have_nanosleep" = "rt"; then
+ 	LIBS="-lrt $LIBS"
+ fi
+ 
++AC_ARG_WITH(libxml2,
++	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
++	with_libxml2="$withval", with_libxml2="no")
++
++if test x$with_libxml2 != xno; then
++	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],
++		[if test x$with_libxml2 != xauto; then
++			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
++		fi])
++fi
++
+ # check for /dev/random (declares ISC_PATH_RANDOMDEV)
+ AC_MSG_CHECKING(for random device)
+ AC_ARG_WITH(randomdev,
+Index: dhcp-4.4.3/configure.ac+lt
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac+lt
++++ dhcp-4.4.3/configure.ac+lt
+@@ -900,6 +900,18 @@ elif test "$want_libtool" = "yes" -a "$u
+ fi
+ AM_CONDITIONAL(INSTALL_BIND, test "$want_install_bind" = "yes")
+ 
++AC_ARG_WITH(libxml2,
++	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
++	with_libxml2="$withval", with_libxml2="no")
++
++if test x$with_libxml2 != xno; then
++	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],,
++		[if test x$with_libxml2 != xauto; then
++			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
++		fi])
++fi
++
++
+ # OpenLDAP support.
+ AC_ARG_WITH(ldap,
+     AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),

+ 25 - 0
recipes-connectivity/dhcp/dhcp/0009-remove-dhclient-script-bash-dependency.patch

@@ -0,0 +1,25 @@
+From f3f8b7726e50e24ef3edf5fa5a17e31d39118d7e Mon Sep 17 00:00:00 2001
+From: Andre McCurdy <armccurdy@gmail.com>
+Date: Tue, 15 Aug 2017 15:49:31 +0800
+Subject: [PATCH 09/11] remove dhclient-script bash dependency
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
+
+Rebase to 4.3.6
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ client/scripts/linux | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: dhcp-4.4.3/client/scripts/linux
+===================================================================
+--- dhcp-4.4.3.orig/client/scripts/linux
++++ dhcp-4.4.3/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

+ 223 - 0
recipes-connectivity/dhcp/dhcp/0012-dhcp-correct-the-intention-for-xml2-lib-search.patch

@@ -0,0 +1,223 @@
+From 501543b3ef715488a142e3d301ff2733aa33eec7 Mon Sep 17 00:00:00 2001
+From: Awais Belal <awais_belal@mentor.com>
+Date: Wed, 25 Oct 2017 21:00:05 +0500
+Subject: [PATCH] dhcp: correct the intention for xml2 lib search
+
+A missing case breaks the build when libxml2 is
+required and found appropriately. The third argument
+to the function AC_SEARCH_LIB is action-if-found which
+was mistakenly been used for the case where the library
+is not found and hence breaks the configure phase
+where it shoud actually pass.
+We now pass on silently when action-if-found is
+executed.
+
+Upstream-Status: Pending
+
+Signed-off-by: Awais Belal <awais_belal@mentor.com>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: dhcp-4.4.3/configure.ac
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac
++++ dhcp-4.4.3/configure.ac
+@@ -1,5 +1,7 @@
+ AC_INIT([DHCP],[4.4.3],[dhcp-users@isc.org])
+ 
++# for libtool
++AC_CONFIG_MACRO_DIR([m4])
+ 
+ # we specify "foreign" to avoid having to have the GNU mandated files,
+ # like AUTHORS, COPYING, and such
+@@ -60,7 +62,6 @@ AC_SUBST(BINDCONFIG)
+ # Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
+ AC_USE_SYSTEM_EXTENSIONS
+ 
+-AC_PROG_RANLIB
+ 
+ AC_PATH_PROG(AR, ar)
+ AC_SUBST(AR)
+@@ -603,10 +604,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
+ # Look for optional headers.
+ AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
+ 
+-# find an MD5 library
+-AC_SEARCH_LIBS(MD5_Init, [crypto])
+-AC_SEARCH_LIBS(MD5Init, [crypto])
+-
+ # Solaris needs some libraries for functions
+ AC_SEARCH_LIBS(socket, [socket])
+ AC_SEARCH_LIBS(inet_ntoa, [nsl])
+@@ -633,17 +630,6 @@ if test "$have_nanosleep" = "rt"; then
+ 	LIBS="-lrt $LIBS"
+ fi
+ 
+-AC_ARG_WITH(libxml2,
+-	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
+-	with_libxml2="$withval", with_libxml2="no")
+-
+-if test x$with_libxml2 != xno; then
+-	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],
+-		[if test x$with_libxml2 != xauto; then
+-			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
+-		fi])
+-fi
+-
+ # check for /dev/random (declares ISC_PATH_RANDOMDEV)
+ AC_MSG_CHECKING(for random device)
+ AC_ARG_WITH(randomdev,
+@@ -806,22 +792,22 @@ no)
+ 	if test ! -d "$use_libbind"; then
+ 		AC_MSG_ERROR([Cannot find bind directory at $use_libbind])
+ 	fi
+-	if test ! -d "$use_libbind/include" -o \
+-	        ! -f "$use_libbind/include/isc/buffer.h"
++	if test ! -d "$use_libbind/$includedir" -o \
++	        ! -f "$use_libbind/$includedir/isc/buffer.h"
+ 	then
+-		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/include])
++		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/$includedir])
+ 	fi
+-	if test	! -d "$use_libbind/lib" -o \
+-	        \( ! -f "$use_libbind/lib/libisc.a" -a \
+-		   ! -f	"$use_libbind/lib/libisc.la" \)
++	if test	! -d "$use_libbind/$libdir" -o \
++	        \( ! -f "$use_libbind/$libdir/libisc.a" -a \
++		   ! -f	"$use_libbind/$libdir/libisc.la" \)
+ 	then
+-		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/$libdir])
+ 	fi
+ 	BINDDIR="$use_libbind"
+-	BINDLIBIRSDIR="$BINDDIR/lib"
+-	BINDLIBDNSDIR="$BINDDIR/lib"
+-	BINDLIBISCCFGDIR="$BINDDIR/lib"
+-	BINDLIBISCDIR="$BINDDIR/lib"
++	BINDLIBIRSDIR="$BINDDIR/$libdir"
++	BINDLIBDNSDIR="$BINDDIR/$libdir"
++	BINDLIBISCCFGDIR="$BINDDIR/$libdir"
++	BINDLIBISCDIR="$BINDDIR/$libdir"
+ 	DISTCHECK_LIBBIND_CONFIGURE_FLAG="--with-libbind=$use_libbind"
+ 	;;
+ esac
+@@ -849,39 +835,38 @@ case "$build_os" in
+ esac
+ 
+ want_libtool="no"
++LT_INIT
++want_libtool="yes"
+ 
+ BINDLT=
+ DISTCHECK_LIBTOOL_CONFIGURE_FLAG=
+ AC_ARG_ENABLE(libtool,
+ 	AS_HELP_STRING([--enable-libtool],
+-[use GNU libtool for dynamic shared libraries (default is no).]),
++[use GNU libtool for dynamic shared libraries (default is yes).]),
+ 	want_libtool="$enableval")
+ 
+ if test "$use_libbind" != "no"; then
+ 	if test "$want_libtool" = "yes" -a \
+-	        ! -f "$use_libbind/lib/libisc.la"
++	        ! -f "$use_libbind/$libdir/libisc.la"
+ 	then
+-		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/$libdir])
+ 	fi
+ 	if test "$want_libtool" = "no" -a \
+-	        ! -f "$use_libbind/lib/libisc.a"
++	        ! -f "$use_libbind/$libdir/libisc.a"
+ 	then
+-		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/$libdir])
+ 	fi
+ fi
+ 
+-
+-if test "$want_libtool" = "yes"; then
+-	AC_MSG_WARN([legacy configure is used but libtool is enabled. Trying to recover...])
+-	# expand $ac_configure_args
+-	eval "set my_configure_args $ac_configure_args"
+-	shift
+-	cd $srcdir; exec ./config+lt "$@"
+-	AC_MSG_ERROR([Recovering failed])
++if test "$want_libtool" = "no"; then
++	AC_MSG_ERROR([libtool configure is used but libtool is disabled?])
+ fi
+ 
+-DHLIBS=LIBRARIES
+-A=a
++DHLIBS=LTLIBRARIES
++A=la
++BINDLT="--with-libtool --disable-symtable"
++DISTCHECK_LIBTOOL_CONFIGURE_FLAG="--enable-libtool"
++
+ 
+ AC_SUBST(DHLIBS)
+ AC_SUBST(A)
+@@ -895,6 +880,7 @@ AC_SUBST(Q)
+ # install bind includes and libraries
+ 
+ want_install_bind="no"
++want_install_bind="yes"
+ if test "$want_libtool" = "yes"; then
+ 	want_install_bind="yes"
+ fi
+@@ -903,7 +889,7 @@ if test "$use_libbind" != "no"; then
+ fi
+ AC_ARG_ENABLE(bind_install,
+ 	AS_HELP_STRING([--enable-bind-install],
+-[install bind includes and libraries (default is no).]),
++[install bind includes and libraries.]),
+ 	want_install_bind="$enableval")
+ if test "$want_install_bind" = "yes"; then
+         if test "$use_libbind" != "no"; then
+@@ -914,6 +900,18 @@ elif test "$want_libtool" = "yes" -a "$u
+ fi
+ AM_CONDITIONAL(INSTALL_BIND, test "$want_install_bind" = "yes")
+ 
++AC_ARG_WITH(libxml2,
++	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
++	with_libxml2="$withval", with_libxml2="no")
++
++if test x$with_libxml2 != xno; then
++	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],,
++		[if test x$with_libxml2 != xauto; then
++			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
++		fi])
++fi
++
++
+ # OpenLDAP support.
+ AC_ARG_WITH(ldap,
+     AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
+@@ -985,6 +983,17 @@ if test x$ldap = xyes || test x$ldapcryp
+     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
+ fi
+ 
++AC_ARG_WITH(systemd,
++        AC_HELP_STRING([--with-systemd],
++                       [enable sending status notifications to systemd daemon (default is no)]),
++        [systemd=$withval],
++        [systemd=no])
++
++if test x$systemd = xyes ; then
++   AC_CHECK_LIB(systemd, sd_notifyf, ,
++                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
++fi
++
+ # Append selected warning levels to CFLAGS before substitution (but after
+ # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
+ CFLAGS="$CFLAGS $STD_CWARNINGS"
+@@ -1029,6 +1038,10 @@ AC_CONFIG_FILES([
+ ])
+ AC_OUTPUT
+ 
++AC_MSG_NOTICE([postconfig: run automake in $srcdir])
++(cd $srcdir; automake)
++AC_MSG_NOTICE([postconfig: rerun config.status])
++sh ./config.status
+ 
+ if test "$enable_dhcpv4o6" = "yes"; then
+ 	DHCP_VERSIONS="DHCPv4, DHCPv6 and DHCPv4-over-DHCPv6"

+ 64 - 0
recipes-connectivity/dhcp/dhcp/0013-fixup_use_libbind.patch

@@ -0,0 +1,64 @@
+lib and include path is hardcoded for use_libbind 
+
+use libdir and includedir vars
+
+Upstream-Status: Pending
+Signed-off-by: Armin Kuster <akuster808@gmail.com>
+
+Index: dhcp-4.4.3/configure.ac+lt
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac+lt
++++ dhcp-4.4.3/configure.ac+lt
+@@ -792,22 +792,22 @@ no)
+ 	if test ! -d "$use_libbind"; then
+ 		AC_MSG_ERROR([Cannot find bind directory at $use_libbind])
+ 	fi
+-	if test ! -d "$use_libbind/include" -o \
+-	        ! -f "$use_libbind/include/isc/buffer.h"
++	if test ! -d "$use_libbind/$includedir" -o \
++	        ! -f "$use_libbind/$includedir/isc/buffer.h"
+ 	then
+-		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/include])
++		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/$includedir])
+ 	fi
+-	if test	! -d "$use_libbind/lib" -o \
+-	        \( ! -f "$use_libbind/lib/libisc.a" -a \
+-		   ! -f	"$use_libbind/lib/libisc.la" \)
++	if test	! -d "$use_libbind/$libdir" -o \
++	        \( ! -f "$use_libbind/$libdir/libisc.a" -a \
++		   ! -f	"$use_libbind/$libdir/libisc.la" \)
+ 	then
+-		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/$libdir])
+ 	fi
+ 	BINDDIR="$use_libbind"
+-	BINDLIBIRSDIR="$BINDDIR/lib"
+-	BINDLIBDNSDIR="$BINDDIR/lib"
+-	BINDLIBISCCFGDIR="$BINDDIR/lib"
+-	BINDLIBISCDIR="$BINDDIR/lib"
++	BINDLIBIRSDIR="$BINDDIR/$libdir"
++	BINDLIBDNSDIR="$BINDDIR/$libdir"
++	BINDLIBISCCFGDIR="$BINDDIR/$libdir"
++	BINDLIBISCDIR="$BINDDIR/$libdir"
+ 	DISTCHECK_LIBBIND_CONFIGURE_FLAG="--with-libbind=$use_libbind"
+ 	;;
+ esac
+@@ -847,14 +847,14 @@ AC_ARG_ENABLE(libtool,
+ 
+ if test "$use_libbind" != "no"; then
+ 	if test "$want_libtool" = "yes" -a \
+-	        ! -f "$use_libbind/lib/libisc.la"
++	        ! -f "$use_libbind/$libdir/libisc.la"
+ 	then
+-		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/$libdir])
+ 	fi
+ 	if test "$want_libtool" = "no" -a \
+-	        ! -f "$use_libbind/lib/libisc.a"
++	        ! -f "$use_libbind/$libdir/libisc.a"
+ 	then
+-		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
++		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/$libdir])
+ 	fi
+ fi
+ 

+ 93 - 0
recipes-connectivity/dhcp/dhcp/0027-Add-missed-sd-notify-patch-to-manage-dhcpd-with-syst.patch

@@ -0,0 +1,93 @@
+From d1b1f91a7982be28acdfb580996c93aafcc76cc2 Mon Sep 17 00:00:00 2001
+From: Pavel Zhukov <pzhukov@redhat.com>
+Date: Thu, 7 Nov 2019 14:47:45 +0100
+Subject: [PATCH 27/28] Add missed sd notify patch to manage dhcpd with systemd
+
+---
+ configure.ac     | 11 +++++++++++
+ relay/dhcrelay.c | 12 ++++++++++++
+ server/dhcpd.c   | 12 ++++++++++++
+ 3 files changed, 35 insertions(+)
+
+Index: dhcp-4.4.3/configure.ac+lt
+===================================================================
+--- dhcp-4.4.3.orig/configure.ac+lt
++++ dhcp-4.4.3/configure.ac+lt
+@@ -983,6 +983,17 @@ if test x$ldap = xyes || test x$ldapcryp
+     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
+ fi
+ 
++AC_ARG_WITH(systemd,
++        AC_HELP_STRING([--with-systemd],
++                       [enable sending status notifications to systemd daemon (default is no)]),
++        [systemd=$withval],
++        [systemd=no])
++
++if test x$systemd = xyes ; then
++   AC_CHECK_LIB(systemd, sd_notifyf, ,
++                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
++fi
++
+ # Append selected warning levels to CFLAGS before substitution (but after
+ # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
+ CFLAGS="$CFLAGS $STD_CWARNINGS"
+Index: dhcp-4.4.3/relay/dhcrelay.c
+===================================================================
+--- dhcp-4.4.3.orig/relay/dhcrelay.c
++++ dhcp-4.4.3/relay/dhcrelay.c
+@@ -32,6 +32,10 @@
+ #include <sys/time.h>
+ #include <isc/file.h>
+ 
++#ifdef HAVE_LIBSYSTEMD
++#include <systemd/sd-daemon.h>
++#endif
++
+ TIME default_lease_time = 43200; /* 12 hours... */
+ TIME max_lease_time = 86400; /* 24 hours... */
+ struct tree_cache *global_options[256];
+@@ -840,6 +844,14 @@ main(int argc, char **argv) {
+ 	signal(SIGTERM, dhcp_signal_handler);  /* kill */
+ #endif
+ 
++#ifdef HAVE_LIBSYSTEMD
++        /* We are ready to process incomming packets. Let's notify systemd */
++        sd_notifyf(0, "READY=1\n"
++                   "STATUS=Dispatching packets...\n"
++                   "MAINPID=%lu",
++                   (unsigned long) getpid());
++#endif
++
+ 	/* Start dispatching packets and timeouts... */
+ 	dispatch();
+ 
+Index: dhcp-4.4.3/server/dhcpd.c
+===================================================================
+--- dhcp-4.4.3.orig/server/dhcpd.c
++++ dhcp-4.4.3/server/dhcpd.c
+@@ -60,6 +60,10 @@ gid_t set_gid = 0;
+ struct class unknown_class;
+ struct class known_class;
+ 
++#ifdef HAVE_LIBSYSTEMD
++#include <systemd/sd-daemon.h>
++#endif
++
+ struct iaddr server_identifier;
+ int server_identifier_matched;
+ 
+@@ -1057,6 +1061,14 @@ main(int argc, char **argv) {
+ 	/* Log that we are about to start working */
+ 	log_info("Server starting service.");
+ 
++#ifdef HAVE_LIBSYSTEMD
++        /* We are ready to process incomming packets. Let's notify systemd */
++        sd_notifyf(0, "READY=1\n"
++                   "STATUS=Dispatching packets...\n"
++                   "MAINPID=%lu",
++                   (unsigned long) getpid());
++#endif
++
+ 	/*
+ 	 * Receive packets and dispatch them...
+ 	 * dispatch() will never return.

+ 14 - 0
recipes-connectivity/dhcp/dhcp/add-riscv-support.patch

@@ -0,0 +1,14 @@
+diff --git a/bind/bind-9.11.36/config.sub b/bind/bind-9.11.36/config2.sub
+index 61cb4bc..145abd0 100644
+--- a/bind/bind-9.11.36/config.sub
++++ b/bind/bind-9.11.36/config.sub
+@@ -301,7 +301,7 @@ case $basic_machine in
+        | pdp10 | pdp11 | pj | pjl \
+        | powerpc | powerpc64 | powerpc64le | powerpcle \
+        | pyramid \
+-       | rl78 | rx \
++       | riscv64 | rl78 | rx \
+        | score \
+        | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+        | sh64 | sh64le \
+

BIN
recipes-connectivity/dhcp/dhcp/bind.tar.gz


+ 13 - 0
recipes-connectivity/dhcp/dhcp_%.bbappend

@@ -0,0 +1,13 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI += "\
+    file://dhcp-CLOEXEC.patch \
+    file://0027-Add-missed-sd-notify-patch-to-manage-dhcpd-with-syst.patch \
+    file://bind.tar.gz;unpack=0 \
+"
+
+do_configure:prepend () {
+	#Replace bind.tar.gz without riscv64 with our patched one
+	rm -f ${S}/bind/bind.tar.gz
+	install ${S}/../bind.tar.gz ${S}/bind/
+}

+ 39 - 0
recipes-connectivity/dhcp/dhcp_4.4.3.bb

@@ -0,0 +1,39 @@
+require dhcp.inc
+
+SRC_URI += "file://0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch \
+            file://0002-dhclient-dbus.patch \
+            file://0003-link-with-lcrypto.patch \
+            file://0004-Fix-out-of-tree-builds.patch \
+            file://0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch \
+            file://0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch \
+            file://0009-remove-dhclient-script-bash-dependency.patch \
+            file://0012-dhcp-correct-the-intention-for-xml2-lib-search.patch \
+            file://0013-fixup_use_libbind.patch \
+            file://0001-workaround-busybox-limitation-in-linux-dhclient-script.patch \
+"
+
+SRC_URI[md5sum] = "9076af4cc1293dde5a7c6cae7de6ab45"
+SRC_URI[sha256sum] = "0e3ec6b4c2a05ec0148874bcd999a66d05518378d77421f607fb0bc9d0135818"
+
+LDFLAGS:append = " -pthread"
+
+PACKAGECONFIG ?= "systemd"
+PACKAGECONFIG[bind-httpstats] = "--with-libxml2,--without-libxml2,libxml2"
+PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
+
+CFLAGS += "-fcommon"
+
+python dhcp_split_compat() {
+    do_split_packages(d,
+                      root = '${libdir}',
+                      file_regex = r'^lib(.*)\.so\..*',
+                      output_pattern = '${PN}-lib%s',
+                      description = 'dhcp %s library',
+                      extra_depends = '',
+                      allow_links = True)
+}
+
+PACKAGES:remove = "dhcp-libs"
+PACKAGES_DYNAMIC = "^${PN}-lib.*"
+
+PACKAGE_PREPROCESS_FUNCS += "dhcp_split_compat"

+ 12 - 0
recipes-connectivity/dhcp/files/default-relay

@@ -0,0 +1,12 @@
+# Defaults for dhcp-relay initscript
+# sourced by /etc/init.d/dhcp-relay
+
+# What servers should the DHCP relay forward requests to?
+# e.g: SERVERS="192.168.0.1"
+SERVERS=""
+
+# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests?
+INTERFACES=""
+
+# Additional options that are passed to the DHCP relay daemon?
+OPTIONS=""

+ 7 - 0
recipes-connectivity/dhcp/files/default-server

@@ -0,0 +1,7 @@
+# Defaults for dhcp initscript
+# sourced by /etc/init.d/dhcp-server
+# installed at /etc/default/dhcp-server by the maintainer scripts
+
+# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
+#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
+INTERFACES=""

+ 39 - 0
recipes-connectivity/dhcp/files/dhclient-systemd-wrapper

@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# In case the interface is used for nfs, skip it.
+nfsroot=0
+interfaces=""
+exec 9<&0 < /proc/mounts
+while read dev mtpt fstype rest; do
+    if test $mtpt = "/" ; then
+        case $fstype in
+            nfs | nfs4)
+                nfsroot=1
+                nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'`
+                break
+                ;;
+            *)
+                ;;
+        esac
+    fi
+done
+exec 0<&9 9<&-
+
+if [ $nfsroot -eq 0 ]; then
+    interfaces="$INTERFACES"
+else
+    if [ -x /bin/ip -o -x /sbin/ip ] ; then
+	nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'`
+    fi
+    for i in $INTERFACES; do
+	if test "x$i" = "x$nfs_iface"; then
+            echo "dhclient skipping nfsroot interface $i"
+	else
+	    interfaces="$interfaces $i"
+	fi
+    done
+fi
+
+if test "x$interfaces" != "x"; then
+    /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf /var/lib/dhcp/dhclient.leases $interfaces
+fi

+ 50 - 0
recipes-connectivity/dhcp/files/dhclient.conf

@@ -0,0 +1,50 @@
+# Configuration file for /sbin/dhclient, which is included in Debian's
+#	dhcp3-client package.
+#
+# This is a sample configuration file for dhclient. See dhclient.conf's
+#	man page for more information about the syntax of this file
+#	and a more comprehensive list of the parameters understood by
+#	dhclient.
+#
+# Normally, if the DHCP server provides reasonable information and does
+#	not leave anything out (like the domain name, for example), then
+#	few changes must be made to this file, if any.
+#
+
+#send host-name "andare.fugue.com";
+#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
+#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,
+	netbios-name-servers, netbios-scope;
+#require subnet-mask, domain-name-servers;
+#timeout 60;
+#retry 60;
+#reboot 10;
+#select-timeout 5;
+#initial-interval 2;
+#script "/etc/dhcp3/dhclient-script";
+#media "-link0 -link1 -link2", "link0 link1";
+#reject 192.33.137.209;
+
+#alias {
+#  interface "eth0";
+#  fixed-address 192.5.5.213;
+#  option subnet-mask 255.255.255.255;
+#}
+
+#lease {
+#  interface "eth0";
+#  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;
+#}

+ 13 - 0
recipes-connectivity/dhcp/files/dhclient.service

@@ -0,0 +1,13 @@
+[Unit]
+Description=Dynamic Host Configuration Protocol (DHCP)
+Wants=network.target
+Before=network.target
+After=systemd-udevd.service
+
+[Service]
+EnvironmentFile=-@SYSCONFDIR@/default/dhcp-client
+ExecStart=@BASE_SBINDIR@/dhclient-systemd-wrapper
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target

+ 349 - 0
recipes-connectivity/dhcp/files/dhcp-CLOEXEC.patch

@@ -0,0 +1,349 @@
+Index: dhcp-4.4.3/client/clparse.c
+===================================================================
+--- dhcp-4.4.3.orig/client/clparse.c
++++ dhcp-4.4.3/client/clparse.c
+@@ -265,7 +265,7 @@ int read_client_conf_file (const char *n
+ 	int token;
+ 	isc_result_t status;
+ 
+-	if ((file = open (name, O_RDONLY)) < 0)
++	if ((file = open (name, O_RDONLY | O_CLOEXEC)) < 0)
+ 		return uerr2isc (errno);
+ 
+ 	cfile = NULL;
+@@ -341,7 +341,7 @@ void read_client_leases ()
+ 
+ 	/* Open the lease file.   If we can't open it, just return -
+ 	   we can safely trust the server to remember our state. */
+-	if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
++	if ((file = open (path_dhclient_db, O_RDONLY | O_CLOEXEC)) < 0)
+ 		return;
+ 
+ 	cfile = NULL;
+Index: dhcp-4.4.3/client/dhclient.c
+===================================================================
+--- dhcp-4.4.3.orig/client/dhclient.c
++++ dhcp-4.4.3/client/dhclient.c
+@@ -255,11 +255,11 @@ main(int argc, char **argv) {
+ 	/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
+ 	   2 (stderr) are open. To do this, we assume that when we
+ 	   open a file the lowest available file descriptor is used. */
+-	fd = open("/dev/null", O_RDWR);
++	fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 0)
+-		fd = open("/dev/null", O_RDWR);
++		fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 1)
+-		fd = open("/dev/null", O_RDWR);
++		fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 2)
+ 		log_perror = 0; /* No sense logging to /dev/null. */
+ 	else if (fd != -1)
+@@ -664,7 +664,7 @@ main(int argc, char **argv) {
+ 		long temp;
+ 		int e;
+ 
+-		if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
++		if ((pidfd = fopen(path_dhclient_pid, "re")) != NULL) {
+ 			e = fscanf(pidfd, "%ld\n", &temp);
+ 			oldpid = (pid_t)temp;
+ 
+@@ -3721,7 +3721,7 @@ void rewrite_client_leases ()
+ 
+ 	if (leaseFile != NULL)
+ 		fclose (leaseFile);
+-	leaseFile = fopen (path_dhclient_db, "w");
++	leaseFile = fopen (path_dhclient_db, "we");
+ 	if (leaseFile == NULL) {
+ 		log_error ("can't create %s: %m", path_dhclient_db);
+ 		return;
+@@ -3916,7 +3916,7 @@ write_duid(struct data_string *duid)
+ 		return DHCP_R_INVALIDARG;
+ 
+ 	if (leaseFile == NULL) {	/* XXX? */
+-		leaseFile = fopen(path_dhclient_db, "w");
++		leaseFile = fopen(path_dhclient_db, "we");
+ 		if (leaseFile == NULL) {
+ 			log_error("can't create %s: %m", path_dhclient_db);
+ 			return ISC_R_IOERROR;
+@@ -3961,7 +3961,7 @@ write_client6_lease(struct client_state
+ 		return DHCP_R_INVALIDARG;
+ 
+ 	if (leaseFile == NULL) {	/* XXX? */
+-		leaseFile = fopen(path_dhclient_db, "w");
++		leaseFile = fopen(path_dhclient_db, "we");
+ 		if (leaseFile == NULL) {
+ 			log_error("can't create %s: %m", path_dhclient_db);
+ 			return ISC_R_IOERROR;
+@@ -4120,7 +4120,7 @@ int write_client_lease (client, lease, r
+ 		return 1;
+ 
+ 	if (leaseFile == NULL) {	/* XXX */
+-		leaseFile = fopen (path_dhclient_db, "w");
++		leaseFile = fopen (path_dhclient_db, "we");
+ 		if (leaseFile == NULL) {
+ 			log_error ("can't create %s: %m", path_dhclient_db);
+ 			return 0;
+@@ -4706,9 +4706,9 @@ void detach ()
+ 	(void) close(2);
+ 
+ 	/* Reopen them on /dev/null. */
+-	(void) open("/dev/null", O_RDWR);
+-	(void) open("/dev/null", O_RDWR);
+-	(void) open("/dev/null", O_RDWR);
++	(void) open("/dev/null", O_RDWR | O_CLOEXEC);
++	(void) open("/dev/null", O_RDWR | O_CLOEXEC);
++	(void) open("/dev/null", O_RDWR | O_CLOEXEC);
+ 
+ 	write_client_pid_file ();
+ 
+@@ -4726,14 +4726,14 @@ void write_client_pid_file ()
+ 		return;
+ 	}
+ 
+-	pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
++	pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
+ 
+ 	if (pfdesc < 0) {
+ 		log_error ("Can't create %s: %m", path_dhclient_pid);
+ 		return;
+ 	}
+ 
+-	pf = fdopen (pfdesc, "w");
++	pf = fdopen (pfdesc, "we");
+ 	if (!pf) {
+ 		close(pfdesc);
+ 		log_error ("Can't fdopen %s: %m", path_dhclient_pid);
+Index: dhcp-4.4.3/common/bpf.c
+===================================================================
+--- dhcp-4.4.3.orig/common/bpf.c
++++ dhcp-4.4.3/common/bpf.c
+@@ -94,7 +94,7 @@ int if_register_bpf (info)
+ 	for (b = 0; 1; b++) {
+ 		/* %Audit% 31 bytes max. %2004.06.17,Safe% */
+ 		sprintf(filename, BPF_FORMAT, b);
+-		sock = open (filename, O_RDWR, 0);
++		sock = open (filename, O_RDWR | O_CLOEXEC, 0);
+ 		if (sock < 0) {
+ 			if (errno == EBUSY) {
+ 				continue;
+Index: dhcp-4.4.3/common/dlpi.c
+===================================================================
+--- dhcp-4.4.3.orig/common/dlpi.c
++++ dhcp-4.4.3/common/dlpi.c
+@@ -817,7 +817,7 @@ dlpiopen(const char *ifname) {
+ 	}
+ 	*dp = '\0';
+ 
+-	return open (devname, O_RDWR, 0);
++	return open (devname, O_RDWR | O_CLOEXEC, 0);
+ }
+ 
+ /*
+Index: dhcp-4.4.3/common/nit.c
+===================================================================
+--- dhcp-4.4.3.orig/common/nit.c
++++ dhcp-4.4.3/common/nit.c
+@@ -75,7 +75,7 @@ int if_register_nit (info)
+ 	struct strioctl sio;
+ 
+ 	/* Open a NIT device */
+-	sock = open ("/dev/nit", O_RDWR);
++	sock = open ("/dev/nit", O_RDWR | O_CLOEXEC);
+ 	if (sock < 0)
+ 		log_fatal ("Can't open NIT device for %s: %m", info -> name);
+ 
+Index: dhcp-4.4.3/common/resolv.c
+===================================================================
+--- dhcp-4.4.3.orig/common/resolv.c
++++ dhcp-4.4.3/common/resolv.c
+@@ -43,7 +43,7 @@ void read_resolv_conf (parse_time)
+ 	struct domain_search_list *dp, *dl, *nd;
+ 	isc_result_t status;
+ 
+-	if ((file = open (path_resolv_conf, O_RDONLY)) < 0) {
++	if ((file = open (path_resolv_conf, O_RDONLY | O_CLOEXEC)) < 0) {
+ 		log_error ("Can't open %s: %m", path_resolv_conf);
+ 		return;
+ 	}
+Index: dhcp-4.4.3/common/upf.c
+===================================================================
+--- dhcp-4.4.3.orig/common/upf.c
++++ dhcp-4.4.3/common/upf.c
+@@ -71,7 +71,7 @@ int if_register_upf (info)
+ 		/* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
+ 		sprintf(filename, "/dev/pf/pfilt%d", b);
+ 
+-		sock = open (filename, O_RDWR, 0);
++		sock = open (filename, O_RDWR | O_CLOEXEC, 0);
+ 		if (sock < 0) {
+ 			if (errno == EBUSY) {
+ 				continue;
+Index: dhcp-4.4.3/omapip/trace.c
+===================================================================
+--- dhcp-4.4.3.orig/omapip/trace.c
++++ dhcp-4.4.3/omapip/trace.c
+@@ -136,10 +136,10 @@ isc_result_t trace_begin (const char *fi
+ 		return DHCP_R_INVALIDARG;
+ 	}
+ 
+-	traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL, 0600);
++	traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL | O_CLOEXEC, 0600);
+ 	if (traceoutfile < 0 && errno == EEXIST) {
+ 		log_error ("WARNING: Overwriting trace file \"%s\"", filename);
+-		traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC,
++		traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC | O_CLOEXEC,
+ 				     0600);
+ 	}
+ 
+@@ -427,7 +427,7 @@ void trace_file_replay (const char *file
+ 	isc_result_t result;
+ 	int len;
+ 
+-	traceinfile = fopen (filename, "r");
++	traceinfile = fopen (filename, "re");
+ 	if (!traceinfile) {
+ 		log_error("Can't open tracefile %s: %m", filename);
+ 		return;
+Index: dhcp-4.4.3/relay/dhcrelay.c
+===================================================================
+--- dhcp-4.4.3.orig/relay/dhcrelay.c
++++ dhcp-4.4.3/relay/dhcrelay.c
+@@ -305,11 +305,11 @@ main(int argc, char **argv) {
+ 	/* Make sure that file descriptors 0(stdin), 1,(stdout), and
+ 	   2(stderr) are open. To do this, we assume that when we
+ 	   open a file the lowest available file descriptor is used. */
+-	fd = open("/dev/null", O_RDWR);
++	fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 0)
+-		fd = open("/dev/null", O_RDWR);
++		fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 1)
+-		fd = open("/dev/null", O_RDWR);
++		fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+ 	if (fd == 2)
+ 		log_perror = 0; /* No sense logging to /dev/null. */
+ 	else if (fd != -1)
+@@ -800,13 +800,13 @@ main(int argc, char **argv) {
+ 		/* Create the pid file. */
+ 		if (no_pid_file == ISC_FALSE) {
+ 			pfdesc = open(path_dhcrelay_pid,
+-				      O_CREAT | O_TRUNC | O_WRONLY, 0644);
++				      O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
+ 
+ 			if (pfdesc < 0) {
+ 				log_error("Can't create %s: %m",
+ 					  path_dhcrelay_pid);
+ 			} else {
+-				pf = fdopen(pfdesc, "w");
++				pf = fdopen(pfdesc, "we");
+ 				if (!pf)
+ 					log_error("Can't fdopen %s: %m",
+ 						  path_dhcrelay_pid);
+Index: dhcp-4.4.3/server/confpars.c
+===================================================================
+--- dhcp-4.4.3.orig/server/confpars.c
++++ dhcp-4.4.3/server/confpars.c
+@@ -118,7 +118,7 @@ isc_result_t read_conf_file (const char
+ 	}
+ #endif
+ 
+-	if ((file = open (filename, O_RDONLY)) < 0) {
++	if ((file = open (filename, O_RDONLY | O_CLOEXEC)) < 0) {
+ 		if (leasep) {
+ 			log_error ("Can't open lease database %s: %m --",
+ 				   path_dhcpd_db);
+Index: dhcp-4.4.3/server/db.c
+===================================================================
+--- dhcp-4.4.3.orig/server/db.c
++++ dhcp-4.4.3/server/db.c
+@@ -1105,7 +1105,7 @@ void db_startup (int test_mode)
+ 	* Therefore, in test mode we need to point db_file to a disposable
+ 	* file to protect the original lease file. */
+ 	current_db_path = (test_mode ? "/dev/null" : path_dhcpd_db);
+-	db_file = fopen (current_db_path, "a");
++	db_file = fopen (current_db_path, "ae");
+ 	if (!db_file) {
+ 		log_fatal ("Can't open %s for append.", current_db_path);
+ 	}
+@@ -1154,7 +1154,7 @@ int new_lease_file (int test_mode)
+ 		     path_dhcpd_db, (int)t) >= sizeof newfname)
+ 		log_fatal("new_lease_file: lease file path too long");
+ 
+-	db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
++	db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0664);
+ 	if (db_fd < 0) {
+ 		log_error ("Can't create new lease file: %m");
+ 		return 0;
+@@ -1175,7 +1175,7 @@ int new_lease_file (int test_mode)
+ 	}
+ #endif /* PARANOIA */
+ 
+-	if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
++	if ((new_db_file = fdopen(db_fd, "we")) == NULL) {
+ 		log_error("Can't fdopen new lease file: %m");
+ 		close(db_fd);
+ 		goto fdfail;
+Index: dhcp-4.4.3/server/dhcpd.c
+===================================================================
+--- dhcp-4.4.3.orig/server/dhcpd.c
++++ dhcp-4.4.3/server/dhcpd.c
+@@ -300,11 +300,11 @@ main(int argc, char **argv) {
+         /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
+            2 (stderr) are open. To do this, we assume that when we
+            open a file the lowest available file descriptor is used. */
+-        fd = open("/dev/null", O_RDWR);
++        fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+         if (fd == 0)
+-                fd = open("/dev/null", O_RDWR);
++                fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+         if (fd == 1)
+-                fd = open("/dev/null", O_RDWR);
++                fd = open("/dev/null", O_RDWR | O_CLOEXEC);
+         if (fd == 2)
+                 log_perror = 0; /* No sense logging to /dev/null. */
+         else if (fd != -1)
+@@ -865,7 +865,7 @@ main(int argc, char **argv) {
+ 	 */
+ 	if ((lftest == 0) && (no_pid_file == ISC_FALSE)) {
+ 		/*Read previous pid file. */
+-		if ((i = open(path_dhcpd_pid, O_RDONLY)) >= 0) {
++		if ((i = open(path_dhcpd_pid, O_RDONLY|O_CLOEXEC)) >= 0) {
+ 			status = read(i, pbuf, (sizeof pbuf) - 1);
+ 			close(i);
+ 			if (status > 0) {
+@@ -975,7 +975,7 @@ main(int argc, char **argv) {
+ 	 * appropriate.
+ 	 */
+ 	if (no_pid_file == ISC_FALSE) {
+-		i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644);
++		i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644);
+ 		if (i >= 0) {
+ 			sprintf(pbuf, "%d\n", (int) getpid());
+ 			IGNORE_RET(write(i, pbuf, strlen(pbuf)));
+@@ -1028,9 +1028,9 @@ main(int argc, char **argv) {
+                 (void) close(2);
+ 
+                 /* Reopen them on /dev/null. */
+-                (void) open("/dev/null", O_RDWR);
+-                (void) open("/dev/null", O_RDWR);
+-                (void) open("/dev/null", O_RDWR);
++                (void) open("/dev/null", O_RDWR | O_CLOEXEC);
++                (void) open("/dev/null", O_RDWR | O_CLOEXEC);
++                (void) open("/dev/null", O_RDWR | O_CLOEXEC);
+                 log_perror = 0; /* No sense logging to /dev/null. */
+ 
+        		IGNORE_RET (chdir("/"));
+Index: dhcp-4.4.3/server/ldap.c
+===================================================================
+--- dhcp-4.4.3.orig/server/ldap.c
++++ dhcp-4.4.3/server/ldap.c
+@@ -1447,7 +1447,7 @@ ldap_start (void)
+ 
+   if (ldap_debug_file != NULL && ldap_debug_fd == -1)
+     {
+-      if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY,
++      if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
+                                  S_IRUSR | S_IWUSR)) < 0)
+         log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
+                    strerror (errno));

+ 108 - 0
recipes-connectivity/dhcp/files/dhcpd.conf

@@ -0,0 +1,108 @@
+#
+# Sample configuration file for ISC dhcpd for Debian
+#
+# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
+#
+
+# The ddns-updates-style parameter controls whether or not the server will
+# attempt to do a DNS update when a lease is confirmed. We default to the
+# behavior of the version 2 packages ('none', since DHCP v2 didn't
+# have support for DDNS.)
+ddns-update-style none;
+
+# 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 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;
+
+# 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;
+#  }
+#}

+ 15 - 0
recipes-connectivity/dhcp/files/dhcpd.service

@@ -0,0 +1,15 @@
+[Unit]
+Description=DHCPv4 Server Daemon
+Documentation=man:dhcpd(8) man:dhcpd.conf(5)
+After=network.target
+After=time-sync.target
+
+[Service]
+PIDFile=/run/dhcpd.pid
+EnvironmentFile=@SYSCONFDIR@/default/dhcp-server
+EnvironmentFile=-@SYSCONFDIR@/sysconfig/dhcp-server
+ExecStartPre=@base_bindir@/touch @localstatedir@/lib/dhcp/dhcpd.leases
+ExecStart=@SBINDIR@/dhcpd -f -cf @SYSCONFDIR@/dhcp/dhcpd.conf -pf /run/dhcpd.pid $DHCPDARGS -q $INTERFACES
+
+[Install]
+WantedBy=multi-user.target

+ 15 - 0
recipes-connectivity/dhcp/files/dhcpd6.service

@@ -0,0 +1,15 @@
+[Unit]
+Description=DHCPv6 Server Daemon
+Documentation=man:dhcpd(8) man:dhcpd.conf(5)
+After=network.target
+After=time-sync.target
+
+[Service]
+PIDFile=/run/dhcpd6.pid
+EnvironmentFile=@SYSCONFDIR@/default/dhcp-server
+EnvironmentFile=-@SYSCONFDIR@/sysconfig/dhcpd6
+ExecStartPre=@base_bindir@/touch @localstatedir@/lib/dhcp/dhcpd6.leases
+ExecStart=@SBINDIR@/dhcpd -f -6 -cf @SYSCONFDIR@/dhcp/dhcpd6.conf -pf /run/dhcpd6.pid $DHCPDARGS -q $INTERFACES
+
+[Install]
+WantedBy=multi-user.target

+ 10 - 0
recipes-connectivity/dhcp/files/dhcrelay.service

@@ -0,0 +1,10 @@
+[Unit]
+Description=DHCP Relay Agent Daemon
+After=network.target
+
+[Service]
+EnvironmentFile=@SYSCONFDIR@/default/dhcp-relay
+ExecStart=@SBINDIR@/dhcrelay -d --no-pid -q $SERVERS
+
+[Install]
+WantedBy=multi-user.target

+ 44 - 0
recipes-connectivity/dhcp/files/init-relay

@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $
+#
+
+# It is not safe to start if we don't have a default configuration...
+if [ ! -f /etc/default/dhcp-relay ]; then
+	echo "/etc/default/dhcp-relay does not exist! - Aborting..."
+	echo "create this file to fix the problem."
+	exit 1
+fi
+
+# Read init script configuration (interfaces the daemon should listen on
+# and the DHCP server we should forward requests to.)
+. /etc/default/dhcp-relay
+
+# Build command line for interfaces (will be passed to dhrelay below.)
+IFCMD=""
+if test "$INTERFACES" != ""; then
+	for I in $INTERFACES; do
+		IFCMD=${IFCMD}"-i "${I}" "
+	done
+fi
+
+DHCRELAYPID=/run/dhcrelay.pid
+
+case "$1" in
+	start)
+		start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
+		;;
+	stop)
+		start-stop-daemon -K -x /usr/sbin/dhcrelay
+		;;
+	restart | force-reload)
+		$0 stop
+		sleep 2
+		$0 start
+		;;
+	*)
+		echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}"
+		exit 1 
+esac
+
+exit 0

+ 44 - 0
recipes-connectivity/dhcp/files/init-server

@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $
+#
+
+test -f /usr/sbin/dhcpd || exit 0
+
+# It is not safe to start if we don't have a default configuration...
+if [ ! -f /etc/default/dhcp-server ]; then
+	echo "/etc/default/dhcp-server does not exist! - Aborting..."
+	exit 0
+fi
+
+# Read init script configuration (so far only interfaces the daemon
+# should listen on.)
+. /etc/default/dhcp-server
+
+case "$1" in
+	start)
+		echo -n "Starting DHCP server: "
+		test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/
+		test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases	
+		start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES -user dhcp -group dhcp
+		echo "."
+		;;
+	stop)
+		echo -n "Stopping DHCP server: dhcpd3"
+		start-stop-daemon -K -x /usr/sbin/dhcpd
+		echo "."
+		;;
+	restart | force-reload)
+		$0 stop
+		sleep 2
+		$0 start
+		if [ "$?" != "0" ]; then
+			exit 1
+		fi
+		;;
+	*)
+		echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}"
+		exit 1 
+esac
+
+exit 0