diff --git a/net/Makefile b/net/Makefile index 7a431960548c..ed1797e34ef2 100644 --- a/net/Makefile +++ b/net/Makefile @@ -284,6 +284,9 @@ SUBDIR += isc-dhcp43-client SUBDIR += isc-dhcp43-relay SUBDIR += isc-dhcp43-server + SUBDIR += isc-dhcp44-client + SUBDIR += isc-dhcp44-relay + SUBDIR += isc-dhcp44-server SUBDIR += istgt SUBDIR += jags SUBDIR += jakarta-commons-net diff --git a/net/isc-dhcp44-client/Makefile b/net/isc-dhcp44-client/Makefile new file mode 100644 index 000000000000..1e76e7a99005 --- /dev/null +++ b/net/isc-dhcp44-client/Makefile @@ -0,0 +1,9 @@ +# Created by: Ryan Steinmetz +# $FreeBSD$ + +COMMENT= The ISC Dynamic Host Configuration Protocol client + +SUBSYS= client +MASTERDIR= ${.CURDIR}/../isc-dhcp44-server + +.include "${MASTERDIR}/Makefile" diff --git a/net/isc-dhcp44-client/pkg-descr b/net/isc-dhcp44-client/pkg-descr new file mode 100644 index 000000000000..f7aff7b6b485 --- /dev/null +++ b/net/isc-dhcp44-client/pkg-descr @@ -0,0 +1,9 @@ +The ISC Dynamic Host Configuration Protocol Distribution provides a +freely redistributable reference implementation of all aspects of the +DHCP protocol, through a suite of DHCP tools: + + * A DHCP server + * A DHCP client (this port) + * A DHCP relay agent + +WWW: https://www.isc.org/products/DHCP/ diff --git a/net/isc-dhcp44-client/pkg-message b/net/isc-dhcp44-client/pkg-message new file mode 100644 index 000000000000..0fe9a2b27a0c --- /dev/null +++ b/net/isc-dhcp44-client/pkg-message @@ -0,0 +1,10 @@ +**** To setup dhclient, you may need to edit /etc/rc.conf to replace the + base system dhclient as follows: + + dhclient_program="%%PREFIX%%/sbin/dhclient" + dhclient_flags="-q" + + See dhclient(8), using the following command, for details about other + possible options: + + MANPATH=%%MAN1PREFIX%%/man man 8 dhclient diff --git a/net/isc-dhcp44-client/pkg-plist b/net/isc-dhcp44-client/pkg-plist new file mode 100644 index 000000000000..4eb1147a2138 --- /dev/null +++ b/net/isc-dhcp44-client/pkg-plist @@ -0,0 +1,11 @@ +sbin/dhclient +sbin/dhclient-script +man/man5/dhclient.conf.5.gz +man/man5/dhclient.leases.5.gz +man/man8/dhclient.8.gz +man/man8/dhclient-script.8.gz +@unexec if cmp -s %D/etc/dhclient.conf.example %D/etc/dhclient.conf; then rm -f %D/etc/dhclient.conf; fi +etc/dhclient.conf.example +@exec if [ ! -f %D/etc/dhclient.conf ] ; then cp -p %D/%F %B/dhclient.conf; fi +@exec [ -f /var/run/dhclient.leases ] || touch /var/run/dhclient.leases +@unexec [ -s /var/run/dhclient.leases ] || rm -f /var/run/dhclient.leases diff --git a/net/isc-dhcp44-relay/Makefile b/net/isc-dhcp44-relay/Makefile new file mode 100644 index 000000000000..092feaf74f7b --- /dev/null +++ b/net/isc-dhcp44-relay/Makefile @@ -0,0 +1,9 @@ +# Created by: Ryan Steinmetz +# $FreeBSD$ + +COMMENT= The ISC Dynamic Host Configuration Protocol relay + +SUBSYS= relay +MASTERDIR= ${.CURDIR}/../isc-dhcp44-server + +.include "${MASTERDIR}/Makefile" diff --git a/net/isc-dhcp44-relay/pkg-descr b/net/isc-dhcp44-relay/pkg-descr new file mode 100644 index 000000000000..13a4d863a58d --- /dev/null +++ b/net/isc-dhcp44-relay/pkg-descr @@ -0,0 +1,9 @@ +The ISC Dynamic Host Configuration Protocol Distribution provides a +freely redistributable reference implementation of all aspects of the +DHCP protocol, through a suite of DHCP tools: + + * A DHCP server + * A DHCP client + * A DHCP relay agent (this port) + +WWW: https://www.isc.org/products/DHCP/ diff --git a/net/isc-dhcp44-relay/pkg-message b/net/isc-dhcp44-relay/pkg-message new file mode 100644 index 000000000000..3b246d6a38c2 --- /dev/null +++ b/net/isc-dhcp44-relay/pkg-message @@ -0,0 +1,8 @@ +**** This port installs the dhcp relay daemon, but doesn't invoke dhcrelay by + default. If you want to invoke dhcrelay at startup, add the following + lines to /etc/rc.conf: + + dhcrelay_enable="YES" + dhcrelay_flags="" # command option(s) + dhcrelay_servers="" # dhcrelay server(s) + dhcrelay_ifaces="" # ethernet interface(s) diff --git a/net/isc-dhcp44-relay/pkg-plist b/net/isc-dhcp44-relay/pkg-plist new file mode 100644 index 000000000000..deb1c2c594d9 --- /dev/null +++ b/net/isc-dhcp44-relay/pkg-plist @@ -0,0 +1,6 @@ +@unexec %D/etc/rc.d/isc-dhcrelay.sh forcestop 2>/dev/null || true +@unexec %D/etc/rc.d/isc-dhcrelay forcestop 2>/dev/null || true +%%IPV6%%@unexec %D/etc/rc.d/isc-dhcrelay6 forcestop 2>/dev/null || true +%%IPV6%%etc/rc.d/isc-dhcrelay6 +sbin/dhcrelay +man/man8/dhcrelay.8.gz diff --git a/net/isc-dhcp44-server/Makefile b/net/isc-dhcp44-server/Makefile new file mode 100644 index 000000000000..56b20e4c9b46 --- /dev/null +++ b/net/isc-dhcp44-server/Makefile @@ -0,0 +1,185 @@ +# Created by: Ryan Steinmetz +# $FreeBSD$ + +PORTNAME= dhcp +PORTVERSION= 4.4.0b1 +PORTREVISION= ${DHCP_PORTREVISION} +CATEGORIES= net +MASTER_SITES= ISC/${PORTNAME}/${PORTVERSION:S/P/-P/g} \ + ZI +PKGNAMEPREFIX= isc- +PKGNAMESUFFIX= 44-${SUBSYS} +DISTNAME= ${PORTNAME}-${PORTVERSION:S/P/-P/g} + +MAINTAINER= zi@FreeBSD.org +COMMENT?= ISC Dynamic Host Configuration Protocol server + +LICENSE= ISCL + +USES= gmake + +PORTREVISION_SERVER= 0 +PORTREVISION_CLIENT= 0 +PORTREVISION_RELAY= 0 + +SUBSYS?= server + +OPTIONS_DEFINE= IPV6 + +.if ${SUBSYS} == server +OPTIONS_DEFINE+= PARANOIA LDAP LDAP_SSL BIND_SYMBOLS DHCP4O6 +OPTIONS_DEFAULT+= PARANOIA LDAP_SSL +DHCP4O6_DESC= Enable DHCPv4-over-DHCPv6 (TSV) +PARANOIA_DESC= Enable support for chroot +LDAP_SSL_DESC= Support LDAP over SSL/TLS +BIND_SYMBOLS_DESC= Enable BIND internal symbol table +.endif + +# PORTREVISION and CONFLICTS handling +.if ${SUBSYS} == client +CONFLICTS= isc-dhcp3?-client-[0-9]* isc-dhcp4[123]-client-[0-9]* +DHCP_PORTREVISION= ${PORTREVISION_CLIENT} +.elif ${SUBSYS} == relay +CONFLICTS= isc-dhcp3?-relay-[0-9]* isc-dhcp4[123]-relay-[0-9]* +DHCP_PORTREVISION= ${PORTREVISION_RELAY} +.else +CONFLICTS= isc-dhcp3?-server-[0-9]* isc-dhcp4[123]-server-[0-9]* +DHCP_PORTREVISION= ${PORTREVISION_SERVER} +.endif +MAKE_JOBS_UNSAFE= yes + +.if ${SUBSYS} == server +USERS= dhcpd +GROUPS= dhcpd +.endif + +MAN_COMPRESSED= no +GNU_CONFIGURE= yes +CPPFLAGS+= -D_PATH_DHCLIENT_SCRIPT='\"${PREFIX}/sbin/dhclient-script\"' -D_PATH_DHCLIENT_CONF='\"${PREFIX}/etc/dhclient.conf\"' -D_PATH_DHCPD_CONF='\"${PREFIX}/etc/dhcpd.conf\"' +SCRIPTS_ENV+= PKG_PREFIX=${PREFIX} + +.include + +.if ${SUBSYS} == server +CONFIGURE_ARGS+=--localstatedir=/var +CFLAGS+= -fPIC +.endif + +DESCR= ${.CURDIR}/pkg-descr +PLIST= ${.CURDIR}/pkg-plist + +.if ${SUBSYS} == server +USE_RC_SUBR= isc-dhcpd +.elif ${SUBSYS} == relay +USE_RC_SUBR= isc-dhcrelay +.endif + +SCHEMA_DIR= ${PREFIX}/share/${PKGBASE} +DOCSDIR= ${PREFIX}/share/doc/${PKGBASE} +DATADIR= /var/db + +MSG_FILE= ${.CURDIR}/pkg-message +PKGMESSAGE= ${WRKDIR}/pkg-message + +REINPLACE_SUB= PREFIX="${PREFIX}" +PKGMESSAGE_SUB= PREFIX="${PREFIX}" MAN1PREFIX="${MAN1PREFIX}" \ + DOCSDIR="${DOCSDIR}" + +.if ${PORT_OPTIONS:MPARANOIA} +CONFIGURE_ARGS+=--enable-paranoia --enable-early-chroot +SUB_LIST+= PARANOIA="yes" +.else +SUB_LIST+= PARANOIA="no" +.endif + +.if ${PORT_OPTIONS:MLDAP} +CONFIGURE_ARGS+=--with-ldap --with-ldapcrypto +USE_OPENLDAP= yes +LDAP_SCRIPT= ${WRKSRC}/contrib/ldap/dhcpd-conf-to-ldap +LDAP_SCHEMA= ${WRKSRC}/contrib/ldap/dhcp.schema +LDAP_README= ${WRKSRC}/contrib/ldap/README.ldap +CPPFLAGS+= -I${LOCALBASE}/include -L${LOCALBASE}/lib +LIBS+= -L${LOCALBASE}/lib +PORTDOCS+= README.ldap +PLIST_SUB+= SCHEMA_DIR="${SCHEMA_DIR:S,^${PREFIX}/,,}" LDAP="" +USES+= shebangfix +SHEBANG_FILES= contrib/ldap/dhcpd-conf-to-ldap +.else +PLIST_SUB+= LDAP="@comment " +.endif + +.if ${PORT_OPTIONS:MLDAP_SSL} && ${PORT_OPTIONS:MLDAP} +USES+= ssl +CONFIGURE_ARGS+=--with-ldapcrypto +LIBS+= -lssl +.endif + +.if ${PORT_OPTIONS:MIPV6} +CONFIGURE_ARGS+=--enable-dhcpv6 +PLIST_SUB+= IPV6="" +.else +CONFIGURE_ARGS+=--disable-dhcpv6 +PLIST_SUB+= IPV6="@comment " +.endif + +.if ${PORT_OPTIONS:MDHCP4O6} +CONFIGURE_ARGS+=--enable-dhcpv4o6 +PLIST_SUB+= DHCP4O6="" +.else +CONFIGURE_ARGS+=--disable-dhcpv4o6 +PLIST_SUB+= DHCP4O6="@comment " +.endif + +.if ${PORT_OPTIONS:MBIND_SYMBOLS} +USES+= perl5 +.else +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-bind_Makefile.in +.endif + +post-patch: + @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ + ${MSG_FILE} > ${PKGMESSAGE} + @${REINPLACE_CMD} -e 's|/usr/local||g' \ + ${WRKSRC}/doc/examples/dhcpd-dhcpv6.conf + @${REINPLACE_CMD} ${REINPLACE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ + ${WRKSRC}/client/dhclient.conf.example + +do-install: + ${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/${SUBSYS} install +.if ${SUBSYS} == server + ${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/dhcpctl install +#${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/dst install + ${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/omapip install + ${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/includes install + ${SETENV} DESTDIR=${STAGEDIR} ${MAKE} -C ${WRKSRC}/common install + ${INSTALL_DATA} ${WRKSRC}/dhcpctl/dhcpctl.h ${STAGEDIR}${PREFIX}/include + ${MV} ${STAGEDIR}${PREFIX}/etc/dhcpd.conf.example ${STAGEDIR}${PREFIX}/etc/dhcpd.conf.sample +.if ${PORT_OPTIONS:MIPV6} + ${INSTALL_DATA} ${WRKSRC}/doc/examples/dhcpd-dhcpv6.conf \ + ${STAGEDIR}${PREFIX}/etc/dhcpd6.conf.sample +.endif +.if ${PORT_OPTIONS:MLDAP} + @${MKDIR} ${STAGEDIR}${SCHEMA_DIR} + ${INSTALL_DATA} ${LDAP_SCHEMA} ${STAGEDIR}${SCHEMA_DIR} + ${INSTALL_SCRIPT} ${LDAP_SCRIPT} ${STAGEDIR}${PREFIX}/bin +.endif +.if ${PORT_OPTIONS:MLDAP} + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${INSTALL_MAN} ${LDAP_README} ${STAGEDIR}${DOCSDIR} +.endif +.endif +.if ${SUBSYS} == client + ${INSTALL_SCRIPT} ${WRKSRC}/client/scripts/freebsd ${STAGEDIR}${PREFIX}/sbin/dhclient-script +.elif ${SUBSYS} == server +.if ${PORT_OPTIONS:MIPV6} + @${LN} -sf isc-dhcpd ${STAGEDIR}${PREFIX}/etc/rc.d/isc-dhcpd6 +.endif +.elif ${SUBSYS} == relay +.if ${PORT_OPTIONS:MIPV6} + @${LN} -sf isc-dhcrelay ${STAGEDIR}${PREFIX}/etc/rc.d/isc-dhcrelay6 +.endif +.endif + @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ + ${MSG_FILE} > ${PKGMESSAGE} + +.include diff --git a/net/isc-dhcp44-server/distinfo b/net/isc-dhcp44-server/distinfo new file mode 100644 index 000000000000..5f3926ce81f1 --- /dev/null +++ b/net/isc-dhcp44-server/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1515530294 +SHA256 (dhcp-4.4.0b1.tar.gz) = 9bb9fcef57e31660d43c83481d60cfa16fd2ad99fd7bbe7f0ae2ca81406a80c2 +SIZE (dhcp-4.4.0b1.tar.gz) = 11151721 diff --git a/net/isc-dhcp44-server/files/extra-patch-bind_Makefile.in b/net/isc-dhcp44-server/files/extra-patch-bind_Makefile.in new file mode 100644 index 000000000000..489fcc5a9915 --- /dev/null +++ b/net/isc-dhcp44-server/files/extra-patch-bind_Makefile.in @@ -0,0 +1,11 @@ +--- bind/Makefile.in.orig 2018-01-05 14:28:00 UTC ++++ bind/Makefile.in +@@ -21,7 +21,7 @@ bindsrcdir=@BINDSRCDIR@ + prefix = @prefix@ + exec_prefix = @exec_prefix@ + +-bindconfig = --without-openssl --without-libxml2 --without-libjson \ ++bindconfig = --disable-symtable --without-openssl --without-libxml2 --without-libjson \ + --without-gssapi --disable-threads --without-lmdb \ + --includedir=@includedir@ --libdir=@libdir@ \ + @BINDLT@ @BINDIOMUX@ @BINDCONFIG@ --enable-full-report diff --git a/net/isc-dhcp44-server/files/isc-dhcpd.in b/net/isc-dhcp44-server/files/isc-dhcpd.in new file mode 100644 index 000000000000..4656dc0cafc4 --- /dev/null +++ b/net/isc-dhcp44-server/files/isc-dhcpd.in @@ -0,0 +1,536 @@ +#! /bin/sh + +# $FreeBSD$ +# +# PROVIDE: dhcpd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf to enable dhcpd: +# +# dhcpd_enable="YES" + +. /etc/rc.subr + +# service(8) does not create an authentic environment, try to guess, +# and as of 10.3-RELEASE-p0, it will not find the indented name= +# assignments below. So give it a default. +# Trailing semicolon also for service(8)'s benefit: +name="$file" ; + +case $0 in +/etc/rc*) + # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), + # so get the name of the script from $_file + name=$_file + ;; +*) + name=$0 + ;; +esac + +# default name to "dhcpd" if guessing failed +# Trailing semicolon also for service(8)'s benefit: +name="${name:-dhcpd}" ; +name=${name##*/isc-} + +paranoia=%%PARANOIA%% # compiled in paranoia? + +load_rc_config ${name} + +# override these variables in /etc/rc.conf +eval ": \${${name}_enable:=\"NO\"}" +# dhcpd_flags="" # -q -early_chroot # command option(s) +# dhcpd_ifaces="" # ethernet interface(s) +eval ": \${${name}_conf:=%%PREFIX%%/etc/${name}.conf}" # configuration file +eval ": \${${name}_withumask:=022}" # file creation mask + +eval ": \${${name}_chuser_enable:=\"%%PARANOIA%%\"}" # runs w/o privileges? +eval ": \${${name}_withuser:=dhcpd}" # user name to run as +eval ": \${${name}_withgroup:=dhcpd}" # group name to run as + +eval ": \${${name}_chroot_enable:=\"NO\"}" # runs chrooted? +eval ": \${${name}_devfs_enable:=\"YES\"}" # devfs if available? +eval ": \${${name}_chrootdir:=/var/db/${name}}" # directory to run in +# dhcpd_includedir="" # directory for included config files + +safe_run () # rc command [args...] +{ + local _rc + + _rc=$1 + shift + + if [ "${_rc}" -eq 0 ]; then + debug safe_run: "$@" + "$@" || _rc=1 + else + warn safe_run: "$@" + fi + return ${_rc} +} + +precious () # entry... +{ + local _entry _rc + + _rc=0 + for _entry; do + # do nothing if /dev, /var/run or /var/db + echo ${_entry} | egrep -q '^//*(dev|var//*(run|db))?/*$' || _rc=1 + done + debug precious: "$@" rc=${_rc} + return ${_rc} +} + +lsmod () # user group file... +{ + local _entry _user _group _rc + + _user=$1 _group=$2 + shift 2 + + _rc=0 + for _entry; do + ls -ld ${_entry} 2> /dev/null | + awk -v u=${_user} -v g=${_group} '{ + exit ((u && $3 != u) || (g && $4 != g)) + }' || _rc=1 + done + debug lsmod: "$@" rc=${_rc} + return ${_rc} +} + +safe_chmog () # entry... +{ + local _entry _user _group _usergroup _rc + + eval "_user=\${${name}_withuser}" + eval "_group=\${${name}_withgroup}" + + _rc=0 + if [ -n "${_user}" -o -n "${_group}" ]; then + _usergroup=${_user}${_group:+:${_group}} + for _entry; do + if [ -d ${_entry} ] && mounted ${_entry}; then + continue + fi + if [ -e ${_entry} ] && + ! precious ${_entry} && + ! lsmod ${_user} ${_group} ${_entry} && + ! safe_run ${_rc} chown ${_usergroup} ${_entry}; then + warn "unable to change permissions of ${_entry}" + _rc=1 + fi + done + fi + return ${_rc} +} + +safe_mkdir () # dir... +{ + local _dir _rc + + _rc=0 + for _dir; do + if [ ! -d ${_dir} ] && + ! precious ${_dir} && + ! safe_run ${_rc} mkdir -p ${_dir}; then + err 1 "unable to create directory ${_dir}" + _rc=1 + fi + done + safe_run ${_rc} safe_chmog "$@" || _rc=1 + return ${_rc} +} + +safe_rmdir () # dir... +{ + local _dir _rc + + _rc=0 + for _dir; do + if [ -d ${_dir} ] && + ! precious ${_dir} && + ! mounted ${_dir}; then + if safe_run ${_rc} rmdir ${_dir}; then + safe_run ${_rc} safe_rmdir ${_dir%/*} || _rc=1 + else + warn "unable to remove directory ${_dir}" + _rc=1 + fi + fi + done + return ${_rc} +} + +safe_touch () # file... +{ + local _file _rc + + _rc=0 + for _file; do + if [ ! -e ${_file} ] && + ! safe_run ${_rc} touch ${_file}; then + err 1 "unable to create file ${_file}" + _rc=1 + fi + done + safe_run ${_rc} safe_chmog "$@" || _rc=1 + return ${_rc} +} + +safe_remove () # entry... +{ + local _entry _rc + + _rc=0 + for _entry; do + if [ -f ${_entry} ]; then + if ! safe_run ${_rc} rm -f ${_entry}; then + warn "unable to remove file ${_entry}" + _rc=1 + fi + elif [ -d ${_entry} ] && + ! precious ${_entry} && + ! mounted ${_entry}; then + if ! safe_run ${_rc} rm -rf ${_entry}; then + warn "unable to remove directory ${_entry}" + _rc=1 + fi + fi + done + return ${_rc} +} + +safe_copy () # src dst +{ + local _src _dst _rc + + _src=$1 _dst=$2 + + _rc=0 + if [ -f ${_src} ]; then + if ! safe_run ${_rc} safe_remove ${_dst} || + ! safe_run ${_rc} cp -p ${_src} ${_dst}; then + err 1 "unable to copy file ${_src} to ${_dst}" + _rc=1 + fi + safe_run ${_rc} safe_chmog ${_dst} || _rc=1 + elif [ -d ${_src} ] && + ! precious ${_dst} && + ! mounted ${_dst}; then + if ! safe_run ${_rc} pax -rw -pe -ts "|^${_src}||" \ + ${_src} ${_dst}; then + err 1 "unable to copy directory ${_src} to ${_dst}" + _rc=1 + fi + else + err 1 "unable to copy ${_src} to ${_dst}" \ + "-- not a file or a directory" + _rc=1 + fi + return ${_rc} +} + +mounted () # dir... +{ + local _rc + + _rc=1 + if checkyesno ${name}_devfs_enable; then + mount -t devfs | awk ' + BEGIN { n = ARGC; ARGC = 2 } + { for (i = 2; i != n; i++) if ($3 == ARGV[i]) exit 1 } + ' - "$@" || _rc=0 + fi + debug mounted: "$@" rc=${_rc} + return ${_rc} +} + +safe_mount () # dir +{ + local _dir _rc + + _dir=$1 + + _rc=0 + if checkyesno ${name}_devfs_enable && + ! mounted ${_dir} && + ! safe_run ${_rc} mount -t devfs devfs ${_dir}; then + err 1 "unable to mount ${_dir}" + _rc=1 + fi + return ${_rc} +} + +safe_umount () # dir +{ + local _dir _rc + + _dir=$1 + + _rc=0 + if checkyesno ${name}_devfs_enable && + mounted ${_dir} && + ! safe_run ${_rc} umount ${_dir}; then + warn "unable to unmount ${_dir}" + _rc=1 + fi + return ${_rc} +} + +check_chuser () +{ + if checkyesno paranoia; then + if checkyesno ${name}_chuser_enable && + eval "[ -z \"\${${name}_withuser}\" -a -z \"\${${name}_withgroup}\" ]"; then + err 1 "one of ${name}_withuser and ${name}_withgroup" \ + "must be set if ${name}_chuser_enable is enabled" + fi + else + if checkyesno ${name}_chuser_enable; then + warn "${name}_chuser_enable disabled -- not compiled in" + eval "${name}_chuser_enable=NO" + fi + fi +} + +check_chroot () +{ + if checkyesno paranoia; then + if checkyesno ${name}_chroot_enable; then + if eval "[ -z \"\${${name}_chrootdir}\" ]"; then + err 1 "${name}_chrootdir must be set" \ + "if ${name}_chroot_enable is enabled" + fi + else + eval "${name}_devfs_enable=NO" + fi + else + if checkyesno ${name}_chroot_enable; then + warn "${name}_chroot_enable disabled -- not compiled in" + eval "${name}_chroot_enable=NO" + fi + eval "${name}_devfs_enable=NO" + fi +} + +_rcvar_chuser () +{ + if checkyesno paranoia && checkyesno ${name}_chuser_enable; then + eval "${name}_piddir=\${__dhcpd_piddir}/\${name}" + eval "${name}_leasesdir=\${__dhcpd_leasesdir}/\${name}" + else + eval unset "${name}_withuser= ${name}_withgroup=" + fi +} + +_rcvar_chroot () +{ + if ! checkyesno paranoia || ! checkyesno ${name}_chroot_enable; then + eval "${name}_chrootdir=" + elif checkyesno paranoia && checkyesno ${name}_chroot_enable; then + eval "${name}_devdir=\${__dhcpd_devdir}" + eval "${name}_etcdir=\${__dhcpd_etcdir}" + fi +} + +_rcvar_pidnleases () +{ + if ! checkyesno ${name}_chuser_enable; then + eval "${name}_piddir=\${__dhcpd_piddir}" + eval "${name}_leasesdir=\${__dhcpd_leasesdir}" + fi + eval "${name}_pidfile=\${${name}_piddir}/\${name}.pid" + eval "${name}_leasesfile=\${${name}_leasesdir}/\${name}.leases" + eval "${name}_conffile=\${${name}_conf}" # for convenience only + eval "${name}_confdir=\$(dirname \${${name}_conffile})" +} + +_rcvar_rooted () +{ + eval "_dhcpd_chrootdir=\${${name}_chrootdir}" + eval "_dhcpd_devdir=\${${name}_chrootdir}\${${name}_devdir}" + eval "_dhcpd_etcdir=\${${name}_chrootdir}\${${name}_etcdir}" + eval "_dhcpd_confdir=\${${name}_chrootdir}\${${name}_confdir}" + eval "_dhcpd_includedir=\${${name}_chrootdir}\${${name}_includedir}" + eval "_dhcpd_piddir=\${${name}_chrootdir}\${${name}_piddir}" + eval "_dhcpd_leasesdir=\${${name}_chrootdir}\${${name}_leasesdir}" + eval "_dhcpd_conffile=\${${name}_chrootdir}\${${name}_conffile}" + eval "_dhcpd_pidfile=\${${name}_chrootdir}\${${name}_pidfile}" + eval "_dhcpd_leasesfile=\${${name}_chrootdir}\${${name}_leasesfile}" +} + +setup_umask () +{ + if eval "[ -n \"\${${name}_withumask}\" ]"; then + eval "umask \${${name}_withumask}" + fi +} + +setup_chroot () +{ + local _hconf _hosts _ltime _rconf + + _hconf=host.conf + _hosts=hosts + _ltime=localtime + _rconf=resolv.conf + + if checkyesno paranoia && checkyesno ${name}_chroot_enable; then + if ! mounted ${_dhcpd_devdir}; then + safe_mkdir ${_dhcpd_devdir}/_ + # XXX /_ hack! so, .../dev is root owned. + fi + safe_mkdir ${_dhcpd_chrootdir} ${_dhcpd_etcdir}/_ ${_dhcpd_confdir} + # XXX /_ hack! so, .../etc is root owned. + if checkyesno ${name}_devfs_enable; then + safe_mount ${_dhcpd_devdir} + else + eval "safe_copy \${${name}_devdir} \${_dhcpd_devdir}" + fi + eval "safe_copy \${${name}_conffile} \${_dhcpd_conffile}" + eval "safe_copy \${${name}_etcdir}/\$_hconf \${_dhcpd_etcdir}/\$_hconf" + eval "safe_copy \${${name}_etcdir}/\$_hosts \${_dhcpd_etcdir}/\$_hosts" + # copy localtime only if it exists + if eval "[ -f \"\${${name}_etcdir}/\$_ltime\" ]"; then + eval "safe_copy \${${name}_etcdir}/\$_ltime \${_dhcpd_etcdir}/\$_ltime" + fi + eval "safe_copy \${${name}_etcdir}/\$_rconf \${_dhcpd_etcdir}/\$_rconf" + # copy dhcpd_includedir if defined and available + if eval "[ -d \"\${${name}_includedir}\" ]"; then + safe_mkdir ${_dhcpd_includedir} + eval "safe_copy \${${name}_includedir} \${_dhcpd_includedir}" + fi + fi +} + +setup_chuser () +{ + if checkyesno paranoia && { + checkyesno ${name}_chuser_enable || checkyesno ${name}_chroot_enable + }; then + safe_mkdir ${_dhcpd_piddir} ${_dhcpd_leasesdir} + fi +} + +setup_leases () +{ + safe_touch ${_dhcpd_leasesfile} +} + +setup_flags () +{ + if [ "${name}" = "dhcpd6" ]; then + rc_flags="${rc_flags} -6" + fi + if eval "[ -n \"\${${name}_conf}\" ]"; then + eval "rc_flags=\"\${rc_flags} -cf \${${name}_conf}\"" + fi + if eval "[ -n \"\${${name}_leasesfile}\" ]"; then + eval "rc_flags=\"\${rc_flags} -lf \${${name}_leasesfile}\"" + fi + if eval "[ -n \"\${${name}_pidfile}\" ]"; then + eval "rc_flags=\"\${rc_flags} -pf \${${name}_pidfile}\"" + fi + if eval "[ -n \"\${${name}_withuser}\" ]"; then + eval "rc_flags=\"\${rc_flags} -user \${${name}_withuser}\"" + fi + if eval "[ -n \"\${${name}_withgroup}\" ]"; then + eval "rc_flags=\"\${rc_flags} -group \${${name}_withgroup}\"" + fi + if eval "[ -n \"\${${name}_chrootdir}\" ]"; then + eval "rc_flags=\"\${rc_flags} -chroot \${${name}_chrootdir}\"" + fi + eval "rc_flags=\"\${rc_flags} \${${name}_ifaces}\"" +} + +cleanup_chroot () +{ + if checkyesno paranoia && checkyesno ${name}_chroot_enable; then + safe_umount ${_dhcpd_devdir} + fi +} + +dhcpd_stop () +{ + if sh $0 forcestatus; then + sh $0 forcestop + fi +} + +dhcpd_check () +{ + check_chuser + check_chroot +} + +dhcpd_rcvar () +{ + _rcvar_chuser + _rcvar_chroot + _rcvar_pidnleases + _rcvar_rooted +} + +dhcpd_precmd () +{ + setup_umask + setup_chroot + setup_chuser + setup_leases + setup_flags +} + +dhcpd_postcmd () +{ + cleanup_chroot +} + +dhcpd_restartprecmd () +{ + setup_chroot + setup_flags + dhcpd_checkconfig +} + +dhcpd_checkconfig () +{ + local rc_flags_mod + setup_flags + rc_flags_mod="$rc_flags" + # Eliminate '-q' flag if it is present + case "$rc_flags" in + *-q*) rc_flags_mod=`echo "${rc_flags}" | sed -Ee 's/(^-q | -q | -q$)//'` ;; + esac + if ! ${command} -t -q ${rc_flags_mod}; then + err 1 "`${command} -t ${rc_flags_mod}` Configuration file sanity check failed" + fi +} + +rcvar=${name}_enable +load_rc_config ${name} + +__dhcpd_uninstall="NO" # internal use only +__dhcpd_devdir=/dev # devices directory +__dhcpd_etcdir=/etc # etc directory +__dhcpd_piddir=/var/run # pid file directory +__dhcpd_leasesdir=/var/db # leases file directory +#__dhcpd_chrootdir=/var/db/${name} # root directory + +dhcpd_check +dhcpd_rcvar + +command=%%PREFIX%%/sbin/dhcpd +pidfile=${_dhcpd_pidfile} +eval "required_files=\${${name}_conf}" +start_precmd=dhcpd_precmd +stop_postcmd=dhcpd_postcmd +restart_precmd="dhcpd_restartprecmd" +uninstall_cmd=dhcpd_uninstall +configtest_cmd="dhcpd_restartprecmd" +extra_commands="uninstall configtest" + +run_rc_command "$1" diff --git a/net/isc-dhcp44-server/files/isc-dhcrelay.in b/net/isc-dhcp44-server/files/isc-dhcrelay.in new file mode 100644 index 000000000000..f629350d25e7 --- /dev/null +++ b/net/isc-dhcp44-server/files/isc-dhcrelay.in @@ -0,0 +1,101 @@ +#!/bin/sh + +# $FreeBSD$ +# +# PROVIDE: dhcrelay +# REQUIRE: DAEMON +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf to enable dhcrelay: +# +# dhcrelay_enable="YES" + +# override these variables in /etc/rc.conf +dhcrelay_enable=${dhcrelay_enable:-"NO"} +dhcrelay6_enable=${dhcrelay6_enable:-"NO"} +# dhcrelay_flags="" # command option(s) +# dhcrelay_servers="" # v4 dhcrelay server(s) +# dhcrelay_ifaces="" # v4 ethernet interface(s) +# dhcrelay6_lowers="" # v6 "lower" network interface(s) +# dhcrelay6_uppers="" # v6 "upper" network interface(s) + + +case $0 in +/etc/rc*) + # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), + # so get the name of the script from $_file + name=$_file + ;; +*) + name=$0 + ;; +esac + +name=${name##*/isc-} + +case ${name} in +*6) + ipversion=-6 + ;; +*) + ipversion=-4 + ;; +esac + +dhcrelay_precmd () +{ + local ifaces _servers _ifaces + + eval "_servers=\${${name}_servers}" + eval "_ifaces=\${${name}_ifaces}" + + if [ -z "${_servers}" ]; then + err 1 "no ${name} server(s) configured." + fi + + ifaces= + for iface in ${_ifaces}; do + ifaces="${ifaces} -i ${iface}" + done + + rc_flags="${rc_flags} ${ipversion} ${ifaces} ${_servers}" +} + +dhcrelay6_precmd () +{ + local lowers _lowers uppers _uppers + + eval "_lowers=\${${name}_lowers}" + eval "_uppers=\${${name}_uppers}" + + if [ -z "${_lowers}" ]; then + err 1 "no ${name} lower(s) configured." + fi + + if [ -z "${_uppers}" ]; then + err 1 "no ${name} upper(s) configured." + fi + + lowers= + for lower in ${_lowers}; do + lowers="${lowers} -l ${lower}" + done + + uppers= + for upper in ${_uppers}; do + uppers="${uppers} -u ${upper}" + done + + rc_flags="${rc_flags} ${ipversion} ${lowers} ${uppers}" +} + +. /etc/rc.subr + +rcvar=${name}_enable + +command=%%PREFIX%%/sbin/dhcrelay +pidfile=/var/run/${name}.pid +start_precmd=${name}_precmd + +load_rc_config ${name} +run_rc_command "$1" diff --git a/net/isc-dhcp44-server/files/patch-client__dhclient.conf.example b/net/isc-dhcp44-server/files/patch-client__dhclient.conf.example new file mode 100644 index 000000000000..02bfcc2fe3bc --- /dev/null +++ b/net/isc-dhcp44-server/files/patch-client__dhclient.conf.example @@ -0,0 +1,11 @@ +--- client/dhclient.conf.example.orig 2015-09-11 20:11:21 UTC ++++ client/dhclient.conf.example +@@ -11,7 +11,7 @@ retry 60; + reboot 10; + select-timeout 5; + initial-interval 2; +-script "/etc/dhclient-script"; ++script "%%PREFIX%%/sbin/dhclient-script"; + media "-link0 -link1 -link2", "link0 link1"; + reject 192.33.137.209; + diff --git a/net/isc-dhcp44-server/pkg-descr b/net/isc-dhcp44-server/pkg-descr new file mode 100644 index 000000000000..54058e91a824 --- /dev/null +++ b/net/isc-dhcp44-server/pkg-descr @@ -0,0 +1,9 @@ +The ISC Dynamic Host Configuration Protocol Distribution provides a +freely redistributable reference implementation of all aspects of the +DHCP protocol, through a suite of DHCP tools: + + * A DHCP server (this port) + * A DHCP client + * A DHCP relay agent + +WWW: https://www.isc.org/products/DHCP/ diff --git a/net/isc-dhcp44-server/pkg-message b/net/isc-dhcp44-server/pkg-message new file mode 100644 index 000000000000..a481bc1aeed3 --- /dev/null +++ b/net/isc-dhcp44-server/pkg-message @@ -0,0 +1,26 @@ +**** To setup dhcpd, please edit %%PREFIX%%/etc/dhcpd.conf. + +**** This port installs the dhcp daemon, but doesn't invoke dhcpd by default. + If you want to invoke dhcpd at startup, add these lines to /etc/rc.conf: + + dhcpd_enable="YES" # dhcpd enabled? + dhcpd_flags="-q" # command option(s) + dhcpd_conf="%%PREFIX%%/etc/dhcpd.conf" # configuration file + dhcpd_ifaces="" # ethernet interface(s) + dhcpd_withumask="022" # file creation mask + +**** If compiled with paranoia support (the default), the following rc.conf + options are also supported: + + dhcpd_chuser_enable="YES" # runs w/o privileges? + dhcpd_withuser="dhcpd" # user name to run as + dhcpd_withgroup="dhcpd" # group name to run as + dhcpd_chroot_enable="YES" # runs chrooted? + dhcpd_devfs_enable="YES" # use devfs if available? + dhcpd_rootdir="/var/db/dhcpd" # directory to run in + dhcpd_includedir="" # directory with config- + files to include + +**** WARNING: never edit the chrooted or jailed dhcpd.conf file but + %%PREFIX%%/etc/dhcpd.conf instead which is always copied where + needed upon startup. diff --git a/net/isc-dhcp44-server/pkg-plist b/net/isc-dhcp44-server/pkg-plist new file mode 100644 index 000000000000..84f017a18683 --- /dev/null +++ b/net/isc-dhcp44-server/pkg-plist @@ -0,0 +1,29 @@ +@unexec echo "You should stop the dhcpd and dhcpd6 daemons if you are permanently removing this port." +@sample etc/dhcpd.conf.sample +%%IPV6%%@sample etc/dhcpd6.conf.sample +%%IPV6%%etc/rc.d/isc-dhcpd6 +sbin/dhcpd +bin/omshell +%%LDAP%%bin/dhcpd-conf-to-ldap +man/man1/omshell.1.gz +man/man3/dhcpctl.3.gz +man/man3/omapi.3.gz +man/man5/dhcpd.conf.5.gz +man/man5/dhcpd.leases.5.gz +man/man5/dhcp-eval.5.gz +man/man5/dhcp-options.5.gz +man/man8/dhcpd.8.gz +include/dhcpctl.h +include/omapip/alloc.h +include/omapip/buffer.h +include/omapip/omapip.h +include/omapip/omapip_p.h +include/omapip/hash.h +include/omapip/trace.h +include/omapip/convert.h +include/omapip/isclib.h +include/omapip/result.h +lib/libdhcp.a +lib/libdhcpctl.a +lib/libomapi.a +%%LDAP%%%%SCHEMA_DIR%%/dhcp.schema