From 20b17ff3de68be1377183b71867b97cabf43f566 Mon Sep 17 00:00:00 2001 From: Sergey Matveychuk Date: Fri, 25 Aug 2006 12:02:58 +0000 Subject: - Update to 3.0.5rc1 - New USE_RC_SUBR order - Stop daemons on ports deinstall. (Add note in UPDATING about this) PR: ports/102489 Submitted by: maintainer --- net/isc-dhcp3-server/Makefile | 41 +- net/isc-dhcp3-server/distinfo | 18 +- net/isc-dhcp3-server/files/isc-dhcpd.in | 722 ++++++++++++++++++++++ net/isc-dhcp3-server/files/isc-dhcpd.sh.sample | 722 ---------------------- net/isc-dhcp3-server/files/isc-dhcrelay.in | 57 ++ net/isc-dhcp3-server/files/isc-dhcrelay.sh.sample | 57 -- net/isc-dhcp3-server/files/patch-server::dhcp.c | 53 -- net/isc-dhcp3-server/pkg-install | 12 +- net/isc-dhcp3-server/pkg-plist | 3 +- 9 files changed, 813 insertions(+), 872 deletions(-) create mode 100644 net/isc-dhcp3-server/files/isc-dhcpd.in delete mode 100644 net/isc-dhcp3-server/files/isc-dhcpd.sh.sample create mode 100644 net/isc-dhcp3-server/files/isc-dhcrelay.in delete mode 100644 net/isc-dhcp3-server/files/isc-dhcrelay.sh.sample delete mode 100644 net/isc-dhcp3-server/files/patch-server::dhcp.c (limited to 'net/isc-dhcp3-server') diff --git a/net/isc-dhcp3-server/Makefile b/net/isc-dhcp3-server/Makefile index 9bdf77dd2fbd..b3cb4ba3290a 100644 --- a/net/isc-dhcp3-server/Makefile +++ b/net/isc-dhcp3-server/Makefile @@ -7,8 +7,7 @@ # PORTNAME= dhcp -PORTVERSION= 3.0.4 -PORTREVISION= 2 +PORTVERSION= 3.0.5.r1 CATEGORIES= net MASTER_SITES= ${MASTER_SITE_ISC} MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history @@ -19,8 +18,6 @@ DISTNAME= ${PORTNAME}-${RELEASE}${VERSION}${PATCHLEVEL} MAINTAINER= Joerg.Pulz@frm2.tum.de COMMENT?= The ISC Dynamic Host Configuration Protocol server -USE_RC_SUBR= yes - SUBSYS?= server UNIQUENAME= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX} @@ -141,7 +138,7 @@ SAMP_FILES= client/dhclient.conf DATA_FILES= dhclient.leases .elif ${SUBSYS} == server BIN_FILES= dhcpd omshell -RC_FILES= isc-dhcpd +USE_RC_SUBR= isc-dhcpd SAMP_FILES= server/dhcpd.conf DATA_FILES= dhcpd.leases .if defined(WITH_DHCP_LDAP) @@ -151,13 +148,12 @@ LDAP_SCHEMA= contrib/dhcp.schema .endif .elif ${SUBSYS} == relay BIN_FILES= dhcrelay -RC_FILES= isc-dhcrelay +USE_RC_SUBR= isc-dhcrelay .endif SAMP_SUFX= .sample CONF_DIR= ${PREFIX}/etc -RC_DIR= ${PREFIX}/etc/rc.d SCHEMA_DIR= ${PREFIX}/share/${PKGBASE} DOCSDIR= ${PREFIX}/share/doc/${PKGBASE} DATADIR= /var/db @@ -169,21 +165,20 @@ PLIST_SUB+= LDAP="" PLIST_SUB+= LDAP="@comment " .endif REINPLACE_SUB= PREFIX=${PREFIX} -RCSCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR} .if ${OSVERSION} >= 502100 -RCSCRIPTS_SUB+= NOLOGIN=/usr/sbin/nologin +SUB_LIST+= NOLOGIN=/usr/sbin/nologin .else -RCSCRIPTS_SUB+= NOLOGIN=/sbin/nologin +SUB_LIST+= NOLOGIN=/sbin/nologin .endif .if !defined(WITHOUT_DHCP_PARANOIA) -RCSCRIPTS_SUB+= PARANOIA=YES +SUB_LIST+= PARANOIA=YES .else -RCSCRIPTS_SUB+= PARANOIA=NO +SUB_LIST+= PARANOIA=NO .endif .if !defined(WITHOUT_DHCP_JAIL) -RCSCRIPTS_SUB+= JAIL=YES +SUB_LIST+= JAIL=YES .else -RCSCRIPTS_SUB+= JAIL=NO +SUB_LIST+= JAIL=NO .endif PKGMESSAGE_SUB= PREFIX="${PREFIX}" MAN1PREFIX="${MAN1PREFIX}" \ DOCSDIR="${DOCSDIR}" SCHEMA_DIR="${SCHEMA_DIR}" @@ -208,7 +203,7 @@ extract-script: post-patch: patch-scripts patch-makefile-conf \ patch-makefiles-dist patch-man-pages \ patch-pkgmessage patch-site-conf \ - patch-rc-scripts patch-dlq + patch-dlq patch-scripts: @${REINPLACE_CMD} ${REINPLACE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ @@ -254,12 +249,6 @@ patch-makefiles-dist: patch-man-pages: @${REINPLACE_CMD} -e '/^\.Fd$$/d' ${WRKSRC}/dhcpctl/dhcpctl.3 -patch-rc-scripts: -.for f in ${RC_FILES} - @${SED} ${RCSCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ - ${FILESDIR}/${f}.sh${SAMP_SUFX} > ${WRKDIR}/${f}.sh -.endfor - patch-pkgmessage: .if ${SUBSYS} != devel @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ @@ -283,12 +272,13 @@ patch-dlq: # Post-install # -POST-INSTALL= parallel-post-install configure-package display-message +POST-INSTALL= parallel-post-install install-rc-script configure-package \ + display-message .ORDER: ${POST-INSTALL} post-install: ${POST-INSTALL} parallel-post-install: \ - strip-binary-files install-startup-files \ + strip-binary-files \ install-doc-files install-ldap-files install-sample-files \ create-conf-files create-data-files @@ -302,11 +292,6 @@ strip-binary-files: .endif .endfor -install-startup-files: -.for f in ${RC_FILES} - @${INSTALL_SCRIPT} ${WRKDIR}/${f}.sh ${RC_DIR} -.endfor - install-doc-files: .if !defined(NOPORTDOCS) @${MKDIR} ${DOCSDIR} diff --git a/net/isc-dhcp3-server/distinfo b/net/isc-dhcp3-server/distinfo index 577496bd9e86..50e34e05f3c2 100644 --- a/net/isc-dhcp3-server/distinfo +++ b/net/isc-dhcp3-server/distinfo @@ -1,9 +1,9 @@ -MD5 (dhcp-3.0.4.tar.gz) = 004ef935fd54b8046b16bdde31a9e151 -SHA256 (dhcp-3.0.4.tar.gz) = 89171155b7a9225f5eb81c83ff63f071168b87eacab05fb859b8397d36809bf7 -SIZE (dhcp-3.0.4.tar.gz) = 883245 -MD5 (dhcp-3.0.4-ldap-patch) = ad88faab5a2d134d7e96e9a984d6535b -SHA256 (dhcp-3.0.4-ldap-patch) = e90aecfd57f4a60fb7775b72a73e637c8b481fea5c34956bf95bd0b39b1441be -SIZE (dhcp-3.0.4-ldap-patch) = 154663 -MD5 (dhcp-3.0.4-dlq-patch) = 0e071945cc986d7ecdfd9b41fc4a102b -SHA256 (dhcp-3.0.4-dlq-patch) = c3fd3200eaf00fa80cb37f19bd3b9edb89497c235b5fa594a0f6f60050f64108 -SIZE (dhcp-3.0.4-dlq-patch) = 7655 +MD5 (dhcp-3.0.5rc1.tar.gz) = 0e2769a9a883f41c5130f2d3cbbf3a21 +SHA256 (dhcp-3.0.5rc1.tar.gz) = b46d94db0c74c8f42c35bc98bec2fac7bcb431b2082f3e8f2541bd5a422e0218 +SIZE (dhcp-3.0.5rc1.tar.gz) = 882983 +MD5 (dhcp-3.0.5rc1-ldap-patch) = 53d4e9c657283e4018e68521b35c6a7a +SHA256 (dhcp-3.0.5rc1-ldap-patch) = 406a8e19fc8407385c350f0f09075721ac0cea342c7ff7fe21d83d68f15c7dc9 +SIZE (dhcp-3.0.5rc1-ldap-patch) = 285970 +MD5 (dhcp-3.0.5rc1-dlq-patch) = 0e071945cc986d7ecdfd9b41fc4a102b +SHA256 (dhcp-3.0.5rc1-dlq-patch) = c3fd3200eaf00fa80cb37f19bd3b9edb89497c235b5fa594a0f6f60050f64108 +SIZE (dhcp-3.0.5rc1-dlq-patch) = 7655 diff --git a/net/isc-dhcp3-server/files/isc-dhcpd.in b/net/isc-dhcp3-server/files/isc-dhcpd.in new file mode 100644 index 000000000000..382cf789402c --- /dev/null +++ b/net/isc-dhcp3-server/files/isc-dhcpd.in @@ -0,0 +1,722 @@ +#! /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" +# + +. %%RC_SUBR%% + +name=dhcpd +paranoia=%%PARANOIA%% # compiled in paranoia? +jail=%%JAIL%% # compiled in jail? + +load_rc_config ${name} + +# override these variables in /etc/rc.conf +dhcpd_enable=${dhcpd_enable:-"NO"} +dhcpd_flags=${dhcpd_flags:-} # -q -early_chroot # command option(s) +dhcpd_conf=${dhcpd_conf:-%%PREFIX%%/etc/${name}.conf} # configuration file +dhcpd_ifaces=${dhcpd_ifaces:-} # ethernet interface(s) +dhcpd_withumask=${dhcpd_withumask:-022} # file creation mask + +dhcpd_chuser_enable=${dhcpd_chuser_enable:-"%%PARANOIA%%"} # runs w/o privileges? +dhcpd_withuser=${dhcpd_withuser:-${name}} # user name to run as +dhcpd_withgroup=${dhcpd_withgroup:-${name}} # group name to run as + +dhcpd_chroot_enable=${dhcpd_chroot_enable:-"NO"} # runs chrooted? +dhcpd_devfs_enable=${dhcpd_devfs_enable:-"YES"} # devfs if available? +dhcpd_makedev_enable=${dhcpd_makedev_enable:-"NO"} # MAKEDEV instead of devfs? +dhcpd_rootdir=${dhcpd_rootdir:-/var/db/${name}} # directory to run in +dhcpd_includedir=${dhcpd_includedir:-} # directory for included config files + +# untested +dhcpd_jail_enable=${dhcpd_jail_enable:-"NO"} # runs imprisoned? +dhcpd_hostname=${dhcpd_hostname:-} # jail hostname +dhcpd_ipaddress=${dhcpd_ipaddress:-} # jail ip address + +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 + + _user=${dhcpd_withuser} + _group=${dhcpd_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 dhcpd_devfs_enable || + checkyesno dhcpd_jail_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 dhcpd_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 dhcpd_devfs_enable && + mounted ${_dir} && + ! safe_run ${_rc} umount ${_dir}; then + warn "unable to unmount ${_dir}" + _rc=1 + fi + return ${_rc} +} + +safe_useradd () +{ + local _user _group _home _shell _gecos + + _user=$1 _group=$2 _gecos=${3:-"& daemon"} + _home=${4:-/nonexistent} _shell=${5:-%%NOLOGIN%%} + + if [ -n "${_group}" ]; then + if pw group show ${_group} 2>/dev/null; then + echo "You already have a group \"${_group}\"," \ + "so I will use it." + elif pw groupadd ${_group} -h -; then + echo "Added group \"${_group}\"." + else + echo "Adding group \"${_group}\" failed..." + echo "Please create it, and try again." + exit 1 + fi + fi + if [ -n "${_user}" ]; then + if pw user show ${_user} 2>/dev/null; then + echo "You already have a user \"${_user}\"," \ + "so I will use it." + elif pw useradd ${_user} -g ${_group} -h - \ + -d ${_home} -s ${_shell} -c "${_gecos}"; then + echo "Added user \"${_user}\"." + else + echo "Adding user \"${_user}\" failed..." + echo "Please create it, and try again." + exit 1 + fi + fi +} + +check_chuser () +{ + if checkyesno paranoia; then + if checkyesno dhcpd_chuser_enable && + [ -z "${dhcpd_withuser}" -a -z "${dhcpd_withgroup}" ]; then + err 1 "one of dhcpd_withuser and dhcpd_withgroup" \ + "must be set if dhcpd_chuser_enable is enabled" + fi + else + if checkyesno dhcpd_chuser_enable; then + warn "dhcpd_chuser_enable disabled -- not compiled in" + dhcpd_chuser_enable=NO + fi + fi +} + +check_jail () +{ + if checkyesno paranoia && checkyesno jail; then + if checkyesno dhcpd_jail_enable && + ! checkyesno dhcpd_chroot_enable; then + warn "dhcpd_chroot_enable implied by dhcpd_jail_enable" + dhcpd_chroot_enable=YES + fi + if checkyesno dhcpd_jail_enable && + [ -n "${dhcpd_hostname}" -a -z "${dhcpd_ipaddress}" ] || + [ -z "${dhcpd_hostname}" -a -n "${dhcpd_ipaddress}" ]; then + err 1 "both dhcpd_hostname and dhcpd_ipaddress" \ + "must be set if dhcpd_jail_enable is enabled" + fi + else + if checkyesno dhcpd_jail_enable; then + warn "dhcpd_jail_enable disabled -- not compiled in" + dhcpd_jail_enable=NO + fi + fi +} + +check_chroot () +{ + if checkyesno paranoia; then + if checkyesno dhcpd_chroot_enable; then + if [ -z "${dhcpd_rootdir}" ]; then + err 1 "dhcpd_rootdir must be set" \ + "if dhcpd_chroot_enable is enabled" + fi + if checkyesno dhcpd_devfs_enable && + checkyesno dhcpd_makedev_enable; then + err 1 "dhcpd_devfs_enable and dhcpd_makedev_enable" \ + "are mutually exclusive. enable only one!" + fi + if checkyesno dhcpd_devfs_enable && + ! ( type mount_devfs ) > /dev/null 2>&1; then + warn "dhcpd_devfs_enable disabled" \ + "-- not available" + dhcpd_devfs_enable=NO + fi + if checkyesno dhcpd_makedev_enable && + ! [ -x ${__dhcpd_devdir}/MAKEDEV ]; then + warn "dhcpd_makedev_enable disabled" \ + "-- not available" + dhcpd_makedev_enable=NO + fi + else + dhcpd_devfs_enable=NO + dhcpd_makedev_enable=NO + fi + else + if checkyesno dhcpd_chroot_enable; then + warn "dhcpd_chroot_enable disabled -- not compiled in" + dhcpd_chroot_enable=NO + fi + dhcpd_devfs_enable=NO + dhcpd_makedev_enable=NO + fi +} + +rcvar_chuser () +{ + if checkyesno paranoia && checkyesno dhcpd_chuser_enable; then + dhcpd_piddir=${__dhcpd_piddir}/${name} + dhcpd_leasesdir=${__dhcpd_leasesdir}/${name} + else + dhcpd_withuser= dhcpd_withgroup= + fi +} + +rcvar_jail () +{ + if ! checkyesno paranoia || ! checkyesno jail || + ! checkyesno dhcpd_jail_enable; then + dhcpd_hostname= dhcpd_ipaddress= + fi +} + +rcvar_chroot () +{ + if ! checkyesno paranoia || ! checkyesno dhcpd_chroot_enable; then + dhcpd_rootdir= + elif checkyesno paranoia && checkyesno dhcpd_chroot_enable; then + dhcpd_devdir=${__dhcpd_devdir} + dhcpd_etcdir=${__dhcpd_etcdir} + fi +} + +rcvar_pidnleases () +{ + if ! checkyesno dhcpd_chuser_enable; then + dhcpd_piddir=${__dhcpd_piddir} + dhcpd_leasesdir=${__dhcpd_leasesdir} + fi + dhcpd_pidfile=${dhcpd_piddir}/${name}.pid + dhcpd_leasesfile=${dhcpd_leasesdir}/${name}.leases + dhcpd_conffile=${dhcpd_conf} # for convenience only + dhcpd_confdir=$(dirname ${dhcpd_conffile}) +} + +rcvar_rooted () +{ + _dhcpd_rootdir=${dhcpd_rootdir} + _dhcpd_devdir=${dhcpd_rootdir}${dhcpd_devdir} + _dhcpd_etcdir=${dhcpd_rootdir}${dhcpd_etcdir} + _dhcpd_confdir=${dhcpd_rootdir}${dhcpd_confdir} + _dhcpd_includedir=${dhcpd_rootdir}${dhcpd_includedir} + _dhcpd_piddir=${dhcpd_rootdir}${dhcpd_piddir} + _dhcpd_leasesdir=${dhcpd_rootdir}${dhcpd_leasesdir} + _dhcpd_conffile=${dhcpd_rootdir}${dhcpd_conffile} + _dhcpd_pidfile=${dhcpd_rootdir}${dhcpd_pidfile} + _dhcpd_leasesfile=${dhcpd_rootdir}${dhcpd_leasesfile} +} + +setup_compat () +{ + local dhcpd_rcconf + + # suck in old configuration file and variables + # + dhcpd_rcconf=${dhcpd_confdir}/rc.isc-dhcpd.conf + + if [ -f ${dhcpd_rcconf} ]; then + warn "${dhcpd_rcconf} is obsolete, use /etc/rc.conf and/or" \ + "/etc/rc.conf.d/${name} instead." + . ${dhcpd_rcconf} + + if [ -n "${dhcpd_options}" -a -z "${rc_flags}" ]; then + warn "dhcpd_options is obsolete," \ + "use dhcpd_flags instead." + rc_flags=${dhcpd_options} + fi + fi +} + +setup_umask () +{ + if [ -n "${dhcpd_withumask}" ]; then + umask ${dhcpd_withumask} + fi +} + +setup_chroot () +{ + local _mdev _hconf _hosts _ltime _rconf + + _mdev=MAKEDEV + _hconf=host.conf + _hosts=hosts + _ltime=localtime + _rconf=resolv.conf + + if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then + if ! mounted ${_dhcpd_devdir}; then + safe_mkdir ${_dhcpd_devdir}/_ + # XXX /_ hack! so, .../dev is root owned. + fi + safe_mkdir ${_dhcpd_rootdir} ${_dhcpd_etcdir}/_ ${_dhcpd_confdir} + # XXX /_ hack! so, .../etc is root owned. + if checkyesno dhcpd_devfs_enable; then + safe_mount ${_dhcpd_devdir} + elif checkyesno dhcpd_makedev_enable; then + safe_copy ${dhcpd_devdir}/$_mdev ${_dhcpd_devdir}/$_mdev + safe_run 0 sh -c "cd ${_dhcpd_devdir} && ./$_mdev jail bpf4" + else + safe_copy ${dhcpd_devdir} ${_dhcpd_devdir} + fi + safe_copy ${dhcpd_conffile} ${_dhcpd_conffile} + safe_copy ${dhcpd_etcdir}/$_hconf ${_dhcpd_etcdir}/$_hconf + safe_copy ${dhcpd_etcdir}/$_hosts ${_dhcpd_etcdir}/$_hosts + safe_copy ${dhcpd_etcdir}/$_ltime ${_dhcpd_etcdir}/$_ltime + safe_copy ${dhcpd_etcdir}/$_rconf ${_dhcpd_etcdir}/$_rconf + # copy dhcpd_includedir if defined and available + if [ -d "${dhcpd_includedir}" ]; then + safe_mkdir ${_dhcpd_includedir} + safe_copy ${dhcpd_includedir} ${_dhcpd_includedir} + fi + fi +} + +setup_chuser () +{ + if checkyesno paranoia && { + checkyesno dhcpd_chuser_enable || checkyesno dhcpd_chroot_enable + }; then + safe_mkdir ${_dhcpd_piddir} ${_dhcpd_leasesdir} + fi +} + +setup_leases () +{ + safe_touch ${_dhcpd_leasesfile} +} + +setup_flags () +{ + if [ -n "${dhcpd_conf}" ]; then + rc_flags="${rc_flags} -cf ${dhcpd_conf}" + fi + if [ -n "${dhcpd_leasesfile}" ]; then + rc_flags="${rc_flags} -lf ${dhcpd_leasesfile}" + fi + if [ -n "${dhcpd_pidfile}" ]; then + rc_flags="${rc_flags} -pf ${dhcpd_pidfile}" + fi + if [ -n "${dhcpd_withuser}" ]; then + rc_flags="${rc_flags} -user ${dhcpd_withuser}" + fi + if [ -n "${dhcpd_withgroup}" ]; then + rc_flags="${rc_flags} -group ${dhcpd_withgroup}" + fi + if [ -n "${dhcpd_rootdir}" ]; then + rc_flags="${rc_flags} -chroot ${dhcpd_rootdir}" + fi + if [ -n "${dhcpd_hostname}" -a -n "${dhcpd_ipaddress}" ]; then + rc_flags="${rc_flags} -jail ${dhcpd_hostname} ${dhcpd_ipaddress}" + fi + rc_flags="${rc_flags} ${dhcpd_ifaces}" +} + +cleanup_chroot () +{ + if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then + safe_umount ${_dhcpd_devdir} + fi +} + +dhcpd_stop () +{ + if sh $0 forcestatus; then + sh $0 forcestop + fi +} + +remove_pid () +{ + if [ -e ${_dhcpd_pidfile} ]; then + warn "${_dhcpd_pidfile} still exists! -- removing anyway" + fi + safe_remove ${_dhcpd_pidfile} +} + +remove_leases () +{ + if [ -s ${_dhcpd_leasesfile} ]; then + warn "${_dhcpd_leasesfile} not empty -- not removed --" \ + "futher warning messages expected, don't care." + else + safe_remove ${_dhcpd_leasesfile} ${_dhcpd_leasesfile}~ + fi +} + +remove_chuser () +{ + if checkyesno paranoia && { + checkyesno dhcpd_chuser_enable || checkyesno dhcpd_chroot_enable + }; then + safe_rmdir ${_dhcpd_piddir} ${_dhcpd_leasesdir} + fi +} + +remove_chroot () +{ + if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then + safe_remove ${_dhcpd_conffile} ${_dhcpd_includedir} \ + ${_dhcpd_etcdir} + if checkyesno dhcpd_devfs_enable; then + safe_umount ${_dhcpd_devdir} + safe_rmdir ${_dhcpd_devdir}/_ # XXX /_ hack! + elif checkyesno dhcpd_jail_enable; then + if ! mounted ${_dhcpd_devdir}; then + safe_remove ${_dhcpd_devdir} + fi + else + safe_remove ${_dhcpd_devdir} + fi + safe_rmdir ${_dhcpd_confdir} ${_dhcpd_rootdir} # XXX /_ hack! + fi +} + +dhcpd_check () +{ + check_chuser + check_jail + check_chroot +} + +dhcpd_rcvar () +{ + rcvar_chuser + rcvar_jail + rcvar_chroot + rcvar_pidnleases + rcvar_rooted +} + +dhcpd_precmd () +{ + setup_compat + setup_umask + setup_chroot + setup_chuser + setup_leases + setup_flags +} + +dhcpd_postcmd () +{ + cleanup_chroot +} + +dhcpd_install () +{ + if checkyesno paranoia; then + safe_useradd "${dhcpd_withuser}" "${dhcpd_withgroup}" \ + "DHCP Daemon" + fi +} + +_dhcpd_uninstall () # user group root +{ + local _user _group _root + + _user=$1 _group=$2 _root=$3 + + if [ -n "${_user}" -o -n "${_group}" ]; then + dhcpd_chuser_enable=YES + dhcpd_withuser=${_user} + dhcpd_withgroup=${_group} + else + dhcpd_chuser_enable=NO + fi + if [ -n "${_root}" ]; then + dhcpd_chroot_enable=YES + dhcpd_rootdir=${_root} + else + dhcpd_chroot_enable=NO + fi + dhcpd_check + dhcpd_rcvar + dhcpd_uninstall +} + +dhcpd_uninstall () +{ + if checkyesno __dhcpd_uninstall; then + dhcpd_stop + remove_pid + remove_leases + remove_chuser + remove_chroot + else + local _user _group _root + + __dhcpd_uninstall=YES + + _user=${dhcpd_withuser} + _group=${dhcpd_withgroup} + _root=${dhcpd_rootdir} + + _dhcpd_uninstall "" "" "" + + if checkyesno paranoia; then + if [ -n "${_user}" -o -n "${_group}" ]; then + _dhcpd_uninstall "${_user}" "${_group}" "" + fi + if [ -n "${_root}" ]; then + _dhcpd_uninstall "" "" "${_root}" + fi + if [ -n "${_user}" -o -n "${_group}" ] && + [ -n "${_root}" ]; then + _dhcpd_uninstall "${_user}" "${_group}" "${_root}" + fi + fi + 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_rootdir=/var/db/${name} # root directory + +dhcpd_check +dhcpd_rcvar + +command=%%PREFIX%%/sbin/${name} +pidfile=${_dhcpd_pidfile} +required_files=${dhcpd_conf} +start_precmd=${name}_precmd +stop_postcmd=${name}_postcmd +install_cmd=dhcpd_install +uninstall_cmd=dhcpd_uninstall +extra_commands="install uninstall" + +run_rc_command "$1" diff --git a/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample b/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample deleted file mode 100644 index 97e56f5f9b24..000000000000 --- a/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample +++ /dev/null @@ -1,722 +0,0 @@ -#! /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" -# - -. %%RC_SUBR%% - -name=dhcpd -paranoia=%%PARANOIA%% # compiled in paranoia? -jail=%%JAIL%% # compiled in jail? - -load_rc_config $name - -# override these variables in /etc/rc.conf -dhcpd_enable=${dhcpd_enable:-"NO"} -dhcpd_flags=${dhcpd_flags:-} # -q -early_chroot # command option(s) -dhcpd_conf=${dhcpd_conf:-%%PREFIX%%/etc/${name}.conf} # configuration file -dhcpd_ifaces=${dhcpd_ifaces:-} # ethernet interface(s) -dhcpd_withumask=${dhcpd_withumask:-022} # file creation mask - -dhcpd_chuser_enable=${dhcpd_chuser_enable:-"%%PARANOIA%%"} # runs w/o privileges? -dhcpd_withuser=${dhcpd_withuser:-${name}} # user name to run as -dhcpd_withgroup=${dhcpd_withgroup:-${name}} # group name to run as - -dhcpd_chroot_enable=${dhcpd_chroot_enable:-"NO"} # runs chrooted? -dhcpd_devfs_enable=${dhcpd_devfs_enable:-"YES"} # devfs if available? -dhcpd_makedev_enable=${dhcpd_makedev_enable:-"NO"} # MAKEDEV instead of devfs? -dhcpd_rootdir=${dhcpd_rootdir:-/var/db/${name}} # directory to run in -dhcpd_includedir=${dhcpd_includedir:-} # directory for included config files - -# untested -dhcpd_jail_enable=${dhcpd_jail_enable:-"NO"} # runs imprisoned? -dhcpd_hostname=${dhcpd_hostname:-} # jail hostname -dhcpd_ipaddress=${dhcpd_ipaddress:-} # jail ip address - -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 - - _user=${dhcpd_withuser} - _group=${dhcpd_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 dhcpd_devfs_enable || - checkyesno dhcpd_jail_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 dhcpd_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 dhcpd_devfs_enable && - mounted ${_dir} && - ! safe_run ${_rc} umount ${_dir}; then - warn "unable to unmount ${_dir}" - _rc=1 - fi - return ${_rc} -} - -safe_useradd () -{ - local _user _group _home _shell _gecos - - _user=$1 _group=$2 _gecos=${3:-"& daemon"} - _home=${4:-/nonexistent} _shell=${5:-%%NOLOGIN%%} - - if [ -n "${_group}" ]; then - if pw group show ${_group} 2>/dev/null; then - echo "You already have a group \"${_group}\"," \ - "so I will use it." - elif pw groupadd ${_group} -h -; then - echo "Added group \"${_group}\"." - else - echo "Adding group \"${_group}\" failed..." - echo "Please create it, and try again." - exit 1 - fi - fi - if [ -n "${_user}" ]; then - if pw user show ${_user} 2>/dev/null; then - echo "You already have a user \"${_user}\"," \ - "so I will use it." - elif pw useradd ${_user} -g ${_group} -h - \ - -d ${_home} -s ${_shell} -c "${_gecos}"; then - echo "Added user \"${_user}\"." - else - echo "Adding user \"${_user}\" failed..." - echo "Please create it, and try again." - exit 1 - fi - fi -} - -check_chuser () -{ - if checkyesno paranoia; then - if checkyesno dhcpd_chuser_enable && - [ -z "${dhcpd_withuser}" -a -z "${dhcpd_withgroup}" ]; then - err 1 "one of dhcpd_withuser and dhcpd_withgroup" \ - "must be set if dhcpd_chuser_enable is enabled" - fi - else - if checkyesno dhcpd_chuser_enable; then - warn "dhcpd_chuser_enable disabled -- not compiled in" - dhcpd_chuser_enable=NO - fi - fi -} - -check_jail () -{ - if checkyesno paranoia && checkyesno jail; then - if checkyesno dhcpd_jail_enable && - ! checkyesno dhcpd_chroot_enable; then - warn "dhcpd_chroot_enable implied by dhcpd_jail_enable" - dhcpd_chroot_enable=YES - fi - if checkyesno dhcpd_jail_enable && - [ -n "${dhcpd_hostname}" -a -z "${dhcpd_ipaddress}" ] || - [ -z "${dhcpd_hostname}" -a -n "${dhcpd_ipaddress}" ]; then - err 1 "both dhcpd_hostname and dhcpd_ipaddress" \ - "must be set if dhcpd_jail_enable is enabled" - fi - else - if checkyesno dhcpd_jail_enable; then - warn "dhcpd_jail_enable disabled -- not compiled in" - dhcpd_jail_enable=NO - fi - fi -} - -check_chroot () -{ - if checkyesno paranoia; then - if checkyesno dhcpd_chroot_enable; then - if [ -z "${dhcpd_rootdir}" ]; then - err 1 "dhcpd_rootdir must be set" \ - "if dhcpd_chroot_enable is enabled" - fi - if checkyesno dhcpd_devfs_enable && - checkyesno dhcpd_makedev_enable; then - err 1 "dhcpd_devfs_enable and dhcpd_makedev_enable" \ - "are mutually exclusive. enable only one!" - fi - if checkyesno dhcpd_devfs_enable && - ! ( type mount_devfs ) > /dev/null 2>&1; then - warn "dhcpd_devfs_enable disabled" \ - "-- not available" - dhcpd_devfs_enable=NO - fi - if checkyesno dhcpd_makedev_enable && - ! [ -x ${__dhcpd_devdir}/MAKEDEV ]; then - warn "dhcpd_makedev_enable disabled" \ - "-- not available" - dhcpd_makedev_enable=NO - fi - else - dhcpd_devfs_enable=NO - dhcpd_makedev_enable=NO - fi - else - if checkyesno dhcpd_chroot_enable; then - warn "dhcpd_chroot_enable disabled -- not compiled in" - dhcpd_chroot_enable=NO - fi - dhcpd_devfs_enable=NO - dhcpd_makedev_enable=NO - fi -} - -rcvar_chuser () -{ - if checkyesno paranoia && checkyesno dhcpd_chuser_enable; then - dhcpd_piddir=${__dhcpd_piddir}/${name} - dhcpd_leasesdir=${__dhcpd_leasesdir}/${name} - else - dhcpd_withuser= dhcpd_withgroup= - fi -} - -rcvar_jail () -{ - if ! checkyesno paranoia || ! checkyesno jail || - ! checkyesno dhcpd_jail_enable; then - dhcpd_hostname= dhcpd_ipaddress= - fi -} - -rcvar_chroot () -{ - if ! checkyesno paranoia || ! checkyesno dhcpd_chroot_enable; then - dhcpd_rootdir= - elif checkyesno paranoia && checkyesno dhcpd_chroot_enable; then - dhcpd_devdir=${__dhcpd_devdir} - dhcpd_etcdir=${__dhcpd_etcdir} - fi -} - -rcvar_pidnleases () -{ - if ! checkyesno dhcpd_chuser_enable; then - dhcpd_piddir=${__dhcpd_piddir} - dhcpd_leasesdir=${__dhcpd_leasesdir} - fi - dhcpd_pidfile=${dhcpd_piddir}/${name}.pid - dhcpd_leasesfile=${dhcpd_leasesdir}/${name}.leases - dhcpd_conffile=${dhcpd_conf} # for convenience only - dhcpd_confdir=$(dirname ${dhcpd_conffile}) -} - -rcvar_rooted () -{ - _dhcpd_rootdir=${dhcpd_rootdir} - _dhcpd_devdir=${dhcpd_rootdir}${dhcpd_devdir} - _dhcpd_etcdir=${dhcpd_rootdir}${dhcpd_etcdir} - _dhcpd_confdir=${dhcpd_rootdir}${dhcpd_confdir} - _dhcpd_includedir=${dhcpd_rootdir}${dhcpd_includedir} - _dhcpd_piddir=${dhcpd_rootdir}${dhcpd_piddir} - _dhcpd_leasesdir=${dhcpd_rootdir}${dhcpd_leasesdir} - _dhcpd_conffile=${dhcpd_rootdir}${dhcpd_conffile} - _dhcpd_pidfile=${dhcpd_rootdir}${dhcpd_pidfile} - _dhcpd_leasesfile=${dhcpd_rootdir}${dhcpd_leasesfile} -} - -setup_compat () -{ - local dhcpd_rcconf - - # suck in old configuration file and variables - # - dhcpd_rcconf=${dhcpd_confdir}/rc.isc-dhcpd.conf - - if [ -f ${dhcpd_rcconf} ]; then - warn "${dhcpd_rcconf} is obsolete, use /etc/rc.conf and/or" \ - "/etc/rc.conf.d/${name} instead." - . ${dhcpd_rcconf} - - if [ -n "${dhcpd_options}" -a -z "${rc_flags}" ]; then - warn "dhcpd_options is obsolete," \ - "use dhcpd_flags instead." - rc_flags=${dhcpd_options} - fi - fi -} - -setup_umask () -{ - if [ -n "${dhcpd_withumask}" ]; then - umask ${dhcpd_withumask} - fi -} - -setup_chroot () -{ - local _mdev _hconf _hosts _ltime _rconf - - _mdev=MAKEDEV - _hconf=host.conf - _hosts=hosts - _ltime=localtime - _rconf=resolv.conf - - if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then - if ! mounted ${_dhcpd_devdir}; then - safe_mkdir ${_dhcpd_devdir}/_ - # XXX /_ hack! so, .../dev is root owned. - fi - safe_mkdir ${_dhcpd_rootdir} ${_dhcpd_etcdir}/_ ${_dhcpd_confdir} - # XXX /_ hack! so, .../etc is root owned. - if checkyesno dhcpd_devfs_enable; then - safe_mount ${_dhcpd_devdir} - elif checkyesno dhcpd_makedev_enable; then - safe_copy ${dhcpd_devdir}/$_mdev ${_dhcpd_devdir}/$_mdev - safe_run 0 sh -c "cd ${_dhcpd_devdir} && ./$_mdev jail bpf4" - else - safe_copy ${dhcpd_devdir} ${_dhcpd_devdir} - fi - safe_copy ${dhcpd_conffile} ${_dhcpd_conffile} - safe_copy ${dhcpd_etcdir}/$_hconf ${_dhcpd_etcdir}/$_hconf - safe_copy ${dhcpd_etcdir}/$_hosts ${_dhcpd_etcdir}/$_hosts - safe_copy ${dhcpd_etcdir}/$_ltime ${_dhcpd_etcdir}/$_ltime - safe_copy ${dhcpd_etcdir}/$_rconf ${_dhcpd_etcdir}/$_rconf - # copy dhcpd_includedir if defined and available - if [ -d "${dhcpd_includedir}" ]; then - safe_mkdir ${_dhcpd_includedir} - safe_copy ${dhcpd_includedir} ${_dhcpd_includedir} - fi - fi -} - -setup_chuser () -{ - if checkyesno paranoia && { - checkyesno dhcpd_chuser_enable || checkyesno dhcpd_chroot_enable - }; then - safe_mkdir ${_dhcpd_piddir} ${_dhcpd_leasesdir} - fi -} - -setup_leases () -{ - safe_touch ${_dhcpd_leasesfile} -} - -setup_flags () -{ - if [ -n "${dhcpd_conf}" ]; then - rc_flags="${rc_flags} -cf ${dhcpd_conf}" - fi - if [ -n "${dhcpd_leasesfile}" ]; then - rc_flags="${rc_flags} -lf ${dhcpd_leasesfile}" - fi - if [ -n "${dhcpd_pidfile}" ]; then - rc_flags="${rc_flags} -pf ${dhcpd_pidfile}" - fi - if [ -n "${dhcpd_withuser}" ]; then - rc_flags="${rc_flags} -user ${dhcpd_withuser}" - fi - if [ -n "${dhcpd_withgroup}" ]; then - rc_flags="${rc_flags} -group ${dhcpd_withgroup}" - fi - if [ -n "${dhcpd_rootdir}" ]; then - rc_flags="${rc_flags} -chroot ${dhcpd_rootdir}" - fi - if [ -n "${dhcpd_hostname}" -a -n "${dhcpd_ipaddress}" ]; then - rc_flags="${rc_flags} -jail ${dhcpd_hostname} ${dhcpd_ipaddress}" - fi - rc_flags="${rc_flags} ${dhcpd_ifaces}" -} - -cleanup_chroot () -{ - if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then - safe_umount ${_dhcpd_devdir} - fi -} - -dhcpd_stop () -{ - if sh $0 forcestatus; then - sh $0 forcestop - fi -} - -remove_pid () -{ - if [ -e ${_dhcpd_pidfile} ]; then - warn "${_dhcpd_pidfile} still exists! -- removing anyway" - fi - safe_remove ${_dhcpd_pidfile} -} - -remove_leases () -{ - if [ -s ${_dhcpd_leasesfile} ]; then - warn "${_dhcpd_leasesfile} not empty -- not removed --" \ - "futher warning messages expected, don't care." - else - safe_remove ${_dhcpd_leasesfile} ${_dhcpd_leasesfile}~ - fi -} - -remove_chuser () -{ - if checkyesno paranoia && { - checkyesno dhcpd_chuser_enable || checkyesno dhcpd_chroot_enable - }; then - safe_rmdir ${_dhcpd_piddir} ${_dhcpd_leasesdir} - fi -} - -remove_chroot () -{ - if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then - safe_remove ${_dhcpd_conffile} ${_dhcpd_includedir} \ - ${_dhcpd_etcdir} - if checkyesno dhcpd_devfs_enable; then - safe_umount ${_dhcpd_devdir} - safe_rmdir ${_dhcpd_devdir}/_ # XXX /_ hack! - elif checkyesno dhcpd_jail_enable; then - if ! mounted ${_dhcpd_devdir}; then - safe_remove ${_dhcpd_devdir} - fi - else - safe_remove ${_dhcpd_devdir} - fi - safe_rmdir ${_dhcpd_confdir} ${_dhcpd_rootdir} # XXX /_ hack! - fi -} - -dhcpd_check () -{ - check_chuser - check_jail - check_chroot -} - -dhcpd_rcvar () -{ - rcvar_chuser - rcvar_jail - rcvar_chroot - rcvar_pidnleases - rcvar_rooted -} - -dhcpd_precmd () -{ - setup_compat - setup_umask - setup_chroot - setup_chuser - setup_leases - setup_flags -} - -dhcpd_postcmd () -{ - cleanup_chroot -} - -dhcpd_install () -{ - if checkyesno paranoia; then - safe_useradd "${dhcpd_withuser}" "${dhcpd_withgroup}" \ - "DHCP Daemon" - fi -} - -_dhcpd_uninstall () # user group root -{ - local _user _group _root - - _user=$1 _group=$2 _root=$3 - - if [ -n "${_user}" -o -n "${_group}" ]; then - dhcpd_chuser_enable=YES - dhcpd_withuser=${_user} - dhcpd_withgroup=${_group} - else - dhcpd_chuser_enable=NO - fi - if [ -n "${_root}" ]; then - dhcpd_chroot_enable=YES - dhcpd_rootdir=${_root} - else - dhcpd_chroot_enable=NO - fi - dhcpd_check - dhcpd_rcvar - dhcpd_uninstall -} - -dhcpd_uninstall () -{ - if checkyesno __dhcpd_uninstall; then - dhcpd_stop - remove_pid - remove_leases - remove_chuser - remove_chroot - else - local _user _group _root - - __dhcpd_uninstall=YES - - _user=${dhcpd_withuser} - _group=${dhcpd_withgroup} - _root=${dhcpd_rootdir} - - _dhcpd_uninstall "" "" "" - - if checkyesno paranoia; then - if [ -n "${_user}" -o -n "${_group}" ]; then - _dhcpd_uninstall "${_user}" "${_group}" "" - fi - if [ -n "${_root}" ]; then - _dhcpd_uninstall "" "" "${_root}" - fi - if [ -n "${_user}" -o -n "${_group}" ] && - [ -n "${_root}" ]; then - _dhcpd_uninstall "${_user}" "${_group}" "${_root}" - fi - fi - fi -} - -rcvar=$(set_rcvar) -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_rootdir=/var/db/${name} # root directory - -dhcpd_check -dhcpd_rcvar - -command=%%PREFIX%%/sbin/${name} -pidfile=${_dhcpd_pidfile} -required_files=${dhcpd_conf} -start_precmd=${name}_precmd -stop_postcmd=${name}_postcmd -install_cmd=dhcpd_install -uninstall_cmd=dhcpd_uninstall -extra_commands="install uninstall" - -run_rc_command "$1" diff --git a/net/isc-dhcp3-server/files/isc-dhcrelay.in b/net/isc-dhcp3-server/files/isc-dhcrelay.in new file mode 100644 index 000000000000..db10841ff32a --- /dev/null +++ b/net/isc-dhcp3-server/files/isc-dhcrelay.in @@ -0,0 +1,57 @@ +#! /bin/sh +# +# $FreeBSD$ +# +# PROVIDE: dhcrelay +# REQUIRE: DAEMON +# +# 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"} +dhcrelay_flags=${dhcrelay_flags:-} # command option(s) +dhcrelay_servers=${dhcrelay_servers:-} # dhcrelay server(s) +dhcrelay_ifaces=${dhcrelay_ifaces:-} # ethernet interface(s) + +dhcrelay_precmd () +{ + local ifaces + + dhcrelay_rcconf=%%PREFIX%%/etc/rc.isc-dhcrelay.conf + + if [ -f ${dhcrelay_rcconf} ]; then + warn "${dhcrelay_rcconf} is obsolete, use /etc/rc.conf instead." + . ${dhcrelay_rcconf} + + if [ -n "${dhcrelay_options}" -a -z "${rc_flags}" ]; then + warn "dhcrelay_options is obsolete, use dhcrelay_flags instead." + rc_flags=${dhcrelay_options} + fi + fi + + if [ -z "${dhcrelay_servers}" ]; then + err 1 "no dhcrelay server(s) configured." + fi + + ifaces= + for iface in ${dhcrelay_ifaces}; do + ifaces="${ifaces} -i ${iface}" + done + + rc_flags="${rc_flags} ${ifaces} ${dhcrelay_servers}" +} + +. %%RC_SUBR%% + +name=dhcrelay +rcvar=${name}_enable + +command=%%PREFIX%%/sbin/${name} +pidfile=/var/run/${name}.pid +start_precmd=${name}_precmd + +load_rc_config ${name} +run_rc_command "$1" diff --git a/net/isc-dhcp3-server/files/isc-dhcrelay.sh.sample b/net/isc-dhcp3-server/files/isc-dhcrelay.sh.sample deleted file mode 100644 index 11c9b00b3133..000000000000 --- a/net/isc-dhcp3-server/files/isc-dhcrelay.sh.sample +++ /dev/null @@ -1,57 +0,0 @@ -#! /bin/sh -# -# $FreeBSD$ -# -# PROVIDE: dhcrelay -# REQUIRE: DAEMON -# -# 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"} -dhcrelay_flags=${dhcrelay_flags:-} # command option(s) -dhcrelay_servers=${dhcrelay_servers:-} # dhcrelay server(s) -dhcrelay_ifaces=${dhcrelay_ifaces:-} # ethernet interface(s) - -dhcrelay_precmd () -{ - local ifaces - - dhcrelay_rcconf=%%PREFIX%%/etc/rc.isc-dhcrelay.conf - - if [ -f ${dhcrelay_rcconf} ]; then - warn "${dhcrelay_rcconf} is obsolete, use /etc/rc.conf instead." - . ${dhcrelay_rcconf} - - if [ -n "${dhcrelay_options}" -a -z "${rc_flags}" ]; then - warn "dhcrelay_options is obsolete, use dhcrelay_flags instead." - rc_flags=${dhcrelay_options} - fi - fi - - if [ -z "${dhcrelay_servers}" ]; then - err 1 "no dhcrelay server(s) configured." - fi - - ifaces= - for iface in ${dhcrelay_ifaces}; do - ifaces="${ifaces} -i ${iface}" - done - - rc_flags="${rc_flags} ${ifaces} ${dhcrelay_servers}" -} - -. %%RC_SUBR%% - -name=dhcrelay -rcvar=$(set_rcvar) - -command=%%PREFIX%%/sbin/${name} -pidfile=/var/run/${name}.pid -start_precmd=${name}_precmd - -load_rc_config ${name} -run_rc_command "$1" diff --git a/net/isc-dhcp3-server/files/patch-server::dhcp.c b/net/isc-dhcp3-server/files/patch-server::dhcp.c deleted file mode 100644 index 94981458272e..000000000000 --- a/net/isc-dhcp3-server/files/patch-server::dhcp.c +++ /dev/null @@ -1,53 +0,0 @@ ---- server/dhcp.c.orig Wed Feb 22 23:43:27 2006 -+++ server/dhcp.c Mon May 22 01:39:59 2006 -@@ -2442,6 +2442,7 @@ - offered_lease_time = - state -> offered_expiry - cur_time; - -+ state -> expiry = 0; - putULong ((unsigned char *)&state -> expiry, - (unsigned long)offered_lease_time); - i = DHO_DHCP_LEASE_TIME; -@@ -2452,7 +2453,7 @@ - if (option_cache_allocate (&oc, MDL)) { - if (make_const_data (&oc -> expression, - (unsigned char *)&state -> expiry, -- sizeof state -> expiry, -+ 4, - 0, 0, MDL)) { - oc -> option = dhcp_universe.options [i]; - save_option (&dhcp_universe, -@@ -2463,6 +2464,7 @@ - - /* Renewal time is lease time * 0.5. */ - offered_lease_time /= 2; -+ state -> renewal = 0; - putULong ((unsigned char *)&state -> renewal, - (unsigned long)offered_lease_time); - i = DHO_DHCP_RENEWAL_TIME; -@@ -2474,7 +2476,7 @@ - if (make_const_data (&oc -> expression, - (unsigned char *) - &state -> renewal, -- sizeof state -> renewal, -+ 4, - 0, 0, MDL)) { - oc -> option = dhcp_universe.options [i]; - save_option (&dhcp_universe, -@@ -2486,6 +2488,7 @@ - /* Rebinding time is lease time * 0.875. */ - offered_lease_time += (offered_lease_time / 2 - + offered_lease_time / 4); -+ state -> rebind = 0; - putULong ((unsigned char *)&state -> rebind, - (unsigned)offered_lease_time); - i = DHO_DHCP_REBINDING_TIME; -@@ -2496,7 +2499,7 @@ - if (option_cache_allocate (&oc, MDL)) { - if (make_const_data (&oc -> expression, - (unsigned char *)&state -> rebind, -- sizeof state -> rebind, -+ 4, - 0, 0, MDL)) { - oc -> option = dhcp_universe.options [i]; - save_option (&dhcp_universe, diff --git a/net/isc-dhcp3-server/pkg-install b/net/isc-dhcp3-server/pkg-install index 8bafd2bed768..e620536d1cbd 100644 --- a/net/isc-dhcp3-server/pkg-install +++ b/net/isc-dhcp3-server/pkg-install @@ -9,10 +9,18 @@ case $2 in POST-INSTALL) - ${PKG_PREFIX}/etc/rc.d/isc-dhcpd.sh forceinstall + if [ ${PKG_PREFIX}/etc/rc.d/isc-dhcpd ]; then + ${PKG_PREFIX}/etc/rc.d/isc-dhcpd forceinstall + else + ${PKG_PREFIX}/etc/rc.d/isc-dhcpd.sh forceinstall + fi ;; DEINSTALL) - ${PKG_PREFIX}/etc/rc.d/isc-dhcpd.sh forceuninstall + if [ ${PKG_PREFIX}/etc/rc.d/isc-dhcpd ]; then + ${PKG_PREFIX}/etc/rc.d/isc-dhcpd forceuninstall + else + ${PKG_PREFIX}/etc/rc.d/isc-dhcpd.sh forceuninstall + fi ;; POST-DEINSTALL|PRE-INSTALL) ;; diff --git a/net/isc-dhcp3-server/pkg-plist b/net/isc-dhcp3-server/pkg-plist index 3daff57c0e42..e1028012ff4e 100644 --- a/net/isc-dhcp3-server/pkg-plist +++ b/net/isc-dhcp3-server/pkg-plist @@ -1,8 +1,9 @@ @comment $FreeBSD$ +@unexec %D/etc/rc.d/isc-dhcpd.sh forcestop 2>/dev/null || true +@unexec %D/etc/rc.d/isc-dhcpd forcestop 2>/dev/null || true bin/omshell %%LDAP%%bin/dhcpd-conf-to-ldap.pl etc/dhcpd.conf.sample -etc/rc.d/isc-dhcpd.sh sbin/dhcpd %%LDAP%%%%SCHEMA_DIR%%/dhcp.schema %%LDAP%%@dirrm %%SCHEMA_DIR%% -- cgit v1.2.3