dhcpcd: Bind to system
authorAaron LI <aly@aaronly.me>
Fri, 19 Oct 2018 07:32:31 +0000 (15:32 +0800)
committerAaron LI <aly@aaronly.me>
Wed, 14 Nov 2018 12:53:35 +0000 (20:53 +0800)
NOTE:
This only makes 'dhcpcd' be built and installed, and doesn't affect the
existing 'dhclient'.

etc/Makefile
etc/mtree/BSD.usr.dist
etc/mtree/BSD.var.dist
sbin/Makefile
sbin/dhcpcd/Makefile [new file with mode: 0644]
sbin/dhcpcd/config.h [new file with mode: 0644]

index bf8bc5f..ca2b93d 100644 (file)
@@ -17,7 +17,8 @@ BINUPDATE+=mail.rc locate.rc
 .else
 BINUPDATE+=${.CURDIR}/../usr.bin/mail/misc/mail.rc \
        ${.CURDIR}/../usr.bin/locate/locate/locate.rc \
-       ${.CURDIR}/../contrib/openresolv/resolvconf.conf
+       ${.CURDIR}/../contrib/openresolv/resolvconf.conf \
+       ${.CURDIR}/../contrib/dhcpcd/src/dhcpcd.conf
 .endif
 
 # Initial distribution files are installed read-write (644)
index 5dbe9ac..521ff22 100644 (file)
         ..
         custom
         ..
+        dhcpcd-hooks
+        ..
         gcc47
         ..
         gcc50
                 contrib
                 ..
             ..
+            dhcpcd
+                hooks
+                ..
+            ..
             diskless
             ..
             drivers
index d230485..f999b5e 100644 (file)
@@ -28,6 +28,8 @@
     ..
 /set mode=0755
     db
+        dhcpcd
+        ..
     ..
     empty               mode=0555 flags=schg
     ..
@@ -52,6 +54,8 @@
     preserve
     ..
     run
+        dhcpcd
+        ..
         ppp             gname=network mode=0770
         ..
         resolvconf
index bfad110..fd12f5a 100644 (file)
@@ -12,6 +12,7 @@ SUBDIR=       adjkerntz \
        devd \
        devfsctl \
        dhclient \
+       dhcpcd \
        disklabel32 \
        disklabel64 \
        diskinfo \
diff --git a/sbin/dhcpcd/Makefile b/sbin/dhcpcd/Makefile
new file mode 100644 (file)
index 0000000..601c577
--- /dev/null
@@ -0,0 +1,103 @@
+# Derived from NetBSD's Makefile for dhcpcd
+
+DISTDIR=       ${.CURDIR}/../../contrib/dhcpcd
+
+PROG=          dhcpcd
+
+SRCDIR=                ${DISTDIR}/src
+.PATH:         ${SRCDIR}
+CFLAGS+=       -DHAVE_CONFIG_H -I${.CURDIR} -I${SRCDIR} -I${DISTDIR}
+SRCS=          common.c control.c dhcpcd.c duid.c eloop.c logerr.c
+SRCS+=         if.c if-options.c route.c sa.c script.c
+SRCS+=         dhcp-common.c dhcpcd-embedded.c
+SRCS+=         if-bsd.c
+
+CFLAGS+=       -DAUTH
+SRCS+=         auth.c
+
+CFLAGS+=       -DARP -DINET
+SRCS+=         arp.c bpf.c dhcp.c ipv4.c
+CFLAGS+=       -DIPV4LL -DARPING
+SRCS+=         ipv4ll.c
+
+CFLAGS+=       -DINET6
+SRCS+=         ipv6.c ipv6nd.c
+CFLAGS+=       -DDHCP6
+SRCS+=         dhcp6.c
+
+.PATH:         ${DISTDIR}/compat
+SRCS+=         pidfile.c reallocarray.c strtoi.c strtou.c
+.PATH:         ${DISTDIR}/compat/crypt
+SRCS+=         hmac.c
+
+DPADD=         ${LIBMD} ${LIBCRYPTO}
+LDADD=         -lmd -lprivate_crypto
+LDFLAGS+=      ${PRIVATELIB_LDFLAGS}
+CFLAGS+=       -I${.CURDIR}/../../crypto/libressl/include
+
+# system directories
+_SYSCONFDIR=   /etc
+_LIBDIR=       /usr/lib
+_LIBEXECDIR=   /usr/libexec
+_DBDIR=                /var/db/dhcpcd
+_RUNDIR=       /var/run
+CFLAGS+=       -DSYSCONFDIR='"${_SYSCONFDIR}"' \
+               -DSBINDIR='"${BINDIR}"' \
+               -DLIBDIR='"${_LIBDIR}"' \
+               -DLIBEXECDIR='"${_LIBEXECDIR}"' \
+               -DDBDIR='"${_DBDIR}"' \
+               -DRUNDIR='"${_RUNDIR}"'
+
+_DATADIR=      /usr/share/examples
+_HOOKDIR=      ${_LIBEXECDIR}/dhcpcd-hooks
+_SED_CMDS=     -e 's:@SYSCONFDIR@:${_SYSCONFDIR}:g' \
+               -e 's:@DATADIR@:${_DATADIR}:g' \
+               -e 's:@DBDIR@:${_DBDIR}:g' \
+               -e 's:@LIBDIR@:${_LIBDIR}:g' \
+               -e 's:@RUNDIR@:${_RUNDIR}:g' \
+               -e 's:@HOOKDIR@:${_HOOKDIR}:g' \
+               -e 's:@SCRIPT@:${_LIBEXECDIR}/dhcpcd-run-hooks:g' \
+               -e 's:@SERVICEEXISTS@::g' \
+               -e 's:@SERVICECMD@::g' \
+               -e 's:@SERVICESTATUS@::g' \
+               -e 's:@STATUSARG@::g' \
+               -e 's:@YPDOMAIN_DIR@::g' \
+               -e 's:@YPDOMAIN_SUFFIX@::g'
+
+MAN=           dhcpcd.conf.5 dhcpcd.8
+.for f in dhcpcd.conf.5 dhcpcd.8
+CLEANFILES+=   ${f}
+${f}: ${f}.in
+       sed ${_SED_CMDS} ${SRCDIR}/${f}.in > $@
+.endfor
+
+# NOTE:
+# The configuration file 'dhcpcd.conf' is installed by 'etc/Makefile'
+
+#
+# Hooks
+#
+
+HOOKSRC=       ${DISTDIR}/hooks
+.PATH:         ${HOOKSRC}
+
+SCRIPTS=       dhcpcd-run-hooks
+SCRIPTSDIR=    ${_LIBEXECDIR}
+MAN+=          dhcpcd-run-hooks.8
+
+FILES=         01-test 02-dump 20-resolv.conf 30-hostname
+FILESDIR=      ${_HOOKDIR}
+
+# Example hooks that should not be installed by default
+.for f in 10-wpa_supplicant 15-timezone 29-lookup-hostname 50-ypbind
+FILES+=                ${f}
+FILESDIR_${f}= ${_DATADIR}/dhcpcd/hooks
+.endfor
+
+.for f in dhcpcd-run-hooks dhcpcd-run-hooks.8 50-ypbind
+CLEANFILES+=   ${f}
+${f}: ${f}.in
+       sed ${_SED_CMDS} ${HOOKSRC}/${f}.in > $@
+.endfor
+
+.include <bsd.prog.mk>
diff --git a/sbin/dhcpcd/config.h b/sbin/dhcpcd/config.h
new file mode 100644 (file)
index 0000000..27a5f71
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * dhcpcd config.h for dragonfly
+ *
+ * generated by 'configure', with custom changes
+ */
+
+#define        HAVE_SYS_QUEUE_H
+#define        TAILQ_FOREACH_SAFE      TAILQ_FOREACH_MUTABLE
+#define        HAVE_KQUEUE
+#define        HAVE_REALLOCARRAY
+#include                       "compat/reallocarray.h"
+#include                       "compat/pidfile.h"
+#include                       "compat/strtoi.h"
+#define        HAVE_MD5_H
+#define        SHA2_H                  <sha256.h>
+#include                       "compat/crypt/hmac.h"