From 5d669bfaf21b80b79e46874f480bd4e9d7351cfd Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 19 Oct 2018 15:32:31 +0800 Subject: [PATCH] dhcpcd: Bind to system NOTE: This only makes 'dhcpcd' be built and installed, and doesn't affect the existing 'dhclient'. --- etc/Makefile | 3 +- etc/mtree/BSD.usr.dist | 6 +++ etc/mtree/BSD.var.dist | 4 ++ sbin/Makefile | 1 + sbin/dhcpcd/Makefile | 103 +++++++++++++++++++++++++++++++++++++++++ sbin/dhcpcd/config.h | 16 +++++++ 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 sbin/dhcpcd/Makefile create mode 100644 sbin/dhcpcd/config.h diff --git a/etc/Makefile b/etc/Makefile index bf8bc5ff4b..ca2b93d7d4 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -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) diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 5dbe9aca7a..521ff22799 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -132,6 +132,8 @@ .. custom .. + dhcpcd-hooks + .. gcc47 .. gcc50 @@ -193,6 +195,10 @@ contrib .. .. + dhcpcd + hooks + .. + .. diskless .. drivers diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist index d230485902..f999b5e178 100644 --- a/etc/mtree/BSD.var.dist +++ b/etc/mtree/BSD.var.dist @@ -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 diff --git a/sbin/Makefile b/sbin/Makefile index bfad110493..fd12f5abb6 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -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 index 0000000000..601c5777fb --- /dev/null +++ b/sbin/dhcpcd/Makefile @@ -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 diff --git a/sbin/dhcpcd/config.h b/sbin/dhcpcd/config.h new file mode 100644 index 0000000000..27a5f71a78 --- /dev/null +++ b/sbin/dhcpcd/config.h @@ -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 +#include "compat/crypt/hmac.h" -- 2.41.0