Date: Tue, 14 Sep 2004 18:11:54 +0200 From: Cyrille Lefevre <cyrille.lefevre@laposte.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Goncalves Dominique <djdomics@wanadoo.fr> Subject: ports/71732: net/isc-dhcp3-servre (4.x devfs fix) Message-ID: <20040914161151.GA2357@gits.dyndns.org> Resent-Message-ID: <200409141630.i8EGUOLZ073152@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 71732 >Category: ports >Synopsis: net/isc-dhcp3-servre (4.x devfs fix) >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Tue Sep 14 16:30:24 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Cyrille Lefevre >Release: FreeBSD 6.0-CURRENT i386 >Organization: ACME >Environment: System: FreeBSD gits 6.0-CURRENT FreeBSD 6.0-CURRENT #6: Thu Sep 2 02:04:23 CEST 2004 root@gits:/disk1/freebsd/current/obj/disk3/freebsd/current/src/sys/CUSTOM i386 >Description: please, apply PR#71030 first, then this one, thanks. Makefile: PORTREVISOIN bumped files/isc-dhcpd.sh.sample: devfs check added pkg-message: dhcpd_devfs_enable added. reported by Goncalves Dominique <djdomics@wanadoo.fr>. >How-To-Repeat: mount -t devfs doesn't exists under 4.x. >Fix: diff -ruN -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ /tmp/ports/net/isc-dhcp3-server/Makefile /usr/ports/net/isc-dhcp3-server/Makefile --- Makefile.orig Tue Sep 14 17:23:21 2004 +++ Makefile Tue Sep 14 17:54:02 2004 @@ -8,7 +8,7 @@ PORTNAME= dhcp PORTVERSION= 3.0.1.r14 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= net MASTER_SITES= ${MASTER_SITE_ISC} MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history diff -ruN -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ /tmp/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample /usr/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample --- files/isc-dhcpd.sh.sample.orig Fri Aug 20 13:52:33 2004 +++ files/isc-dhcpd.sh.sample Tue Sep 14 17:42:14 2004 @@ -29,6 +29,7 @@ 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_rootdir=${dhcpd_rootdir:-/var/db/${name}} # directory to run in # untested @@ -58,8 +59,8 @@ _rc=0 for _entry; do - # do nothing if /var/run or /var/db - echo ${_entry} | egrep -q '^//*(var//*(run|db)/*)?$' || _rc=1 + # 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} @@ -139,7 +140,7 @@ safe_run ${_rc} safe_rmdir ${_dir%/*} || _rc=1 else warn "unable to remove directory ${_dir}" - rc=1 + _rc=1 fi fi done @@ -162,16 +163,24 @@ return ${_rc} } -safe_remove () # file... +safe_remove () # entry... { - local _file _rc + local _entry _rc _rc=0 - for _file; do - if [ -f ${_file} ] && - ! safe_run ${_rc} rm -f ${_file}; then - warn "unable to remove file ${_file}" - _rc=1 + 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} @@ -184,12 +193,26 @@ _src=$1 _dst=$2 _rc=0 - if ! safe_run ${_rc} safe_remove ${_dst} || - ! safe_run ${_rc} cp -p ${_src} ${_dst}; then - err 1 "unable to copy file ${_src} to ${_dst}" + 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 - safe_run ${_rc} safe_chmog ${_dst} || _rc=1 return ${_rc} } @@ -198,10 +221,12 @@ local _rc _rc=1 - mount -t devfs | awk ' - BEGIN { n = ARGC; ARGC = 2 } - { for (i = 2; i != n; i++) if ($3 == ARGV[i]) exit 1 } - ' - "$@" || _rc=0 + if checkyesno dhcpd_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} } @@ -213,7 +238,8 @@ _dir=$1 _rc=0 - if ! mounted ${_dir} && + if checkyesno dhcpd_devfs_enable && + ! mounted ${_dir} && ! safe_run ${_rc} mount -t devfs devfs ${_dir}; then err 1 "unable to mount ${_dir}" _rc=1 @@ -228,7 +254,8 @@ _dir=$1 _rc=0 - if mounted ${_dir} && + if checkyesno dhcpd_devfs_enable && + mounted ${_dir} && ! safe_run ${_rc} umount ${_dir}; then warn "unable to unmount ${_dir}" _rc=1 @@ -311,16 +338,25 @@ check_chroot () { if checkyesno paranoia; then - if checkyesno dhcpd_chroot_enable && - [ -z "${dhcpd_rootdir}" ]; then - err 1 "dhcpd_rootdir" \ - "must be set if dhcpd_chroot_enable is enabled" + 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 ! ( type mount_devfs ) > /dev/null 2>&1; then + warn "dhcpd_devfs_enable disabled" \ + "-- not available" + dhcpd_devfs_enable=NO + fi + else + dhcpd_devfs_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 fi } @@ -346,6 +382,8 @@ { if ! checkyesno paranoia || ! checkyesno dhcpd_chroot_enable; then dhcpd_rootdir= + elif checkyesno paranoia && checkyesno dhcpd_chroot_enable; then + dhcpd_devdir=${__dhcpd_devdir} fi } @@ -364,7 +402,7 @@ rcvar_rooted () { _dhcpd_rootdir=${dhcpd_rootdir} - _dhcpd_devdir=${dhcpd_rootdir}/dev + _dhcpd_devdir=${dhcpd_rootdir}${dhcpd_devdir} _dhcpd_confdir=${dhcpd_rootdir}${dhcpd_confdir} _dhcpd_piddir=${dhcpd_rootdir}${dhcpd_piddir} _dhcpd_leasesdir=${dhcpd_rootdir}${dhcpd_leasesdir} @@ -404,8 +442,13 @@ setup_chroot () { if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then - safe_mkdir ${_dhcpd_rootdir} ${_dhcpd_devdir} ${_dhcpd_confdir} - safe_mount ${_dhcpd_devdir} + safe_mkdir ${_dhcpd_rootdir} ${_dhcpd_devdir}/_ ${_dhcpd_confdir} + safe_rmdir ${_dhcpd_devdir}/_ # /_, so, .../dev is root owned. + if checkyesno dhcpd_devfs_enable; then + safe_mount ${_dhcpd_devdir} + else + safe_copy ${dhcpd_devdir} ${_dhcpd_devdir} + fi safe_copy ${dhcpd_conffile} ${_dhcpd_conffile} fi } @@ -495,8 +538,13 @@ { if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then safe_remove ${_dhcpd_conffile} - safe_umount ${_dhcpd_devdir} - safe_rmdir ${_dhcpd_confdir} ${_dhcpd_devdir} ${_dhcpd_rootdir} + if checkyesno dhcpd_devfs_enable; then + safe_umount ${_dhcpd_devdir} + safe_rmdir ${_dhcpd_devdir} + else + safe_remove ${_dhcpd_devdir} + fi + safe_rmdir ${_dhcpd_confdir} ${_dhcpd_rootdir} fi } @@ -601,6 +649,7 @@ load_rc_config ${name} __dhcpd_uninstall="NO" # internal use only +__dhcpd_devdir=/dev # devices directory __dhcpd_piddir=/var/run # pid file directory __dhcpd_leasesdir=/var/db # leases file directory #__dhcpd_rootdir=/var/db/${name} # root directory diff -ruN -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ /tmp/ports/net/isc-dhcp3-server/pkg-message /usr/ports/net/isc-dhcp3-server/pkg-message --- pkg-message.orig Tue Sep 14 17:27:45 2004 +++ pkg-message Tue Sep 14 16:38:15 2004 @@ -17,6 +17,7 @@ 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" # uses devfs if available? dhcpd_rootdir="/var/db/dhcpd" # directory to run in dhcpd_flags="-early_chroot" # needs full root >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040914161151.GA2357>