Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jun 2004 00:50:28 GMT
From:      Cyrille Lefevre <cyrille.lefevre@laposte.net>
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   Re: ports/68357: Maintainer update: net/isc-dhcp3 (startup script rewritten)
Message-ID:  <200406300050.i5U0oS6F030314@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR ports/68357; it has been noted by GNATS.

From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: Oliver Eikemeier <eikemeier@fillmore-labs.com>
Cc: freebsd gnats <freebsd-gnats-submit@freebsd.org>,
	Oliver Eikemeier <eik@freebsd.org>, Tom Rhodes <trhodes@freebsd.org>,
	David@mail.gits.dyndns.org, Du@mail.gits.dyndns.org,
	SERRE-TELMON <dduserretelmon@informatique-securite.net>,
	Jonathan@mail.gits.dyndns.org, Weiss <tomonage2@gmx.de>
Subject: Re: ports/68357: Maintainer update: net/isc-dhcp3 (startup script rewritten)
Date: Wed, 30 Jun 2004 02:37:42 +0200 (CEST)

 On Jun 29, 2004 10:44:21 pm +0200, Oliver Eikemeier wrote:
 > Cyrille Lefevre wrote:
 > > Makefile
 > > 	the install script isn't called at make install time !
 > [...]
 > >  post-install: strip-binary-files install-startup-files \
 > >  	      install-doc-files install-sample-files \
 > >  	      create-conf-files create-data-files \
 > > -	      display-message
 > > +	      configure-package display-message
 > 
 > Nothing guarantees you that install-startup-files is executed before 
 > configure-package. If you depend on a certain order, either put the 
 > steps in one target (preferred, because it is what you are trying to 
 > express), or use .ORDER
 
 so, I have to fix some other ports... :)
 for instance, I implement .ORDER
 
 > Be aware that using .ORDER might conflict with upcoming hacks in 
 > bsd.*.mk, like the current gnome hack for pre-patch.
 
 do you have any pointers ?
 
 in the meantime, someone identified a problem in the startup script
 (lsmod() added), I've also identified some other bugs (those identified
 as fixed below) and completed the uninstallation process.
 
 PS : hope I've fixed all the major bugs (and possibly the minor ones :)
 
 Makefile
 	configure-package added to post-install
 	.ORDER added
 files/isc-dhcpd.sh.sample
 	some debug() added
 	precious() test inverted
 	lsmod() added
 	safe_chmod() fixed (don't chown .../dev if mounted)
 	safe_mkdir() fixed (don't create .../dev if mounted)
 	check_chuser() fixed (-z "${var}" instead of -z ${var})
 	setup_umask() fixed (dhcpd_umask -> dhcpd_withumask)
 	dhcpd_stop() fixed (sh $0 force... instead of $0 ...)
 	_dhcpd__uninstall() added
 	dhcpd_uninstall() recursively called to handle all the
 	combinations of dhcpd_chuser_enable and dhcpd_chroot_enable
 	$__dhcpd_uninstall added
 	$_dhcpd_piddir and $_dhcpd_leaddir -> $__dhcpd_*
 
 Index: Makefile
 ===================================================================
 RCS file: /home/ncvs/ports/net/isc-dhcp3-server/Makefile,v
 retrieving revision 1.98
 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.98 Makefile
 --- Makefile	26 Jun 2004 14:32:40 -0000	1.98
 +++ Makefile	30 Jun 2004 00:16:33 -0000
 @@ -42,6 +42,7 @@
  CONFIGURE_ARGS=	--subsys ${SUBSYS}
  ALL_TARGET=	all.${SUBSYS}
  INSTALL_TARGET=	install.${SUBSYS}
 +SCRIPTS_ENV+=	PKG_PREFIX=${PREFIX}
  
  .if ${SUBSYS} == client
  MAN5=		dhclient.conf.5 dhclient.leases.5
 @@ -209,10 +210,14 @@
  # Post-install
  #
  
 -post-install: strip-binary-files install-startup-files \
 -	      install-doc-files install-sample-files \
 -	      create-conf-files create-data-files \
 -	      display-message
 +POST-INSTALL= parallel-post-install configure-package display-message
 +.ORDER: ${POST-INSTALL}
 +post-install: ${POST-INSTALL}
 +
 +parallel-post-install: \
 +	strip-binary-files install-startup-files \
 +	install-doc-files install-sample-files \
 +	create-conf-files create-data-files
  
  strip-binary-files:
  .for f in ${BIN_FILES}
 @@ -255,6 +260,9 @@
  	@${TOUCH} ${DATADIR}/${f}
  .endif
  .endfor
 +
 +configure-package:
 +	@${SETENV} ${SCRIPTS_ENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
  
  display-message:
  .if ${SUBSYS} != devel
 Index: files/isc-dhcpd.sh.sample
 ===================================================================
 RCS file: /home/ncvs/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample,v
 retrieving revision 1.6
 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.6 isc-dhcpd.sh.sample
 --- files/isc-dhcpd.sh.sample	26 Jun 2004 14:32:41 -0000	1.6
 +++ files/isc-dhcpd.sh.sample	30 Jun 2004 00:19:48 -0000
 @@ -44,7 +44,10 @@
  	shift
  
  	if [ "${_rc}" -eq 0 ]; then
 +		debug safe_run: "$@"
  		"$@" || _rc=1
 +	else
 +		warn safe_run: "$@"
  	fi
  	return ${_rc}
  }
 @@ -53,11 +56,30 @@
  {
  	local _entry _rc
  
 -	_rc=1
 +	_rc=0
  	for _entry; do
  		# do nothing if /var/run or /var/db
 -		echo ${_entry} | egrep -q '^//*(var//*(run|db)/*)?$' && _rc=0
 +		echo ${_entry} | egrep -q '^//*(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}
  }
  
 @@ -72,12 +94,12 @@
  	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} &&
 -			   ! ls -ld ${_entry} 2> /dev/null |
 -			     awk -v u=${_user} -v g=${_group} '{
 -				exit ((u && $3 != u) || (g && $4 != g))
 -			     }' &&
 +			   ! lsmod ${_user} ${_group} ${_entry} &&
  			   ! safe_run ${_rc} chown ${_usergroup} ${_entry}; then
  				warn "unable to change permissions of ${_entry}"
  				_rc=1
 @@ -111,7 +133,8 @@
  	_rc=0
  	for _dir; do
  		if [ -d ${_dir} ] &&
 -		   ! precious ${_dir}; then
 +		   ! precious ${_dir} &&
 +		   ! mounted ${_dir}; then
  			if safe_run ${_rc} rmdir ${_dir}; then
  				safe_run ${_rc} safe_rmdir ${_dir%/*} || _rc=1
  			else
 @@ -179,6 +202,7 @@
  	    BEGIN { n = ARGC; ARGC = 2 }
  	    { for (i = 2; i != n; i++) if ($3 == ARGV[i]) exit 1 }
  	' - "$@" || _rc=0
 +	debug mounted: "$@" rc=${_rc}
  	return ${_rc}
  }
  
 @@ -250,7 +274,7 @@
  {
  	if checkyesno paranoia; then
  		if checkyesno dhcpd_chuser_enable &&
 -		   [ -z ${dhcpd_withuser} -a -z ${dhcpd_withgroup} ]; then
 +		   [ -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
 @@ -303,8 +327,8 @@
  rcvar_chuser ()
  {
  	if checkyesno paranoia && checkyesno dhcpd_chuser_enable; then
 -		dhcpd_piddir=${_dhcpd_piddir}/${name}
 -		dhcpd_leasesdir=${_dhcpd_leasesdir}/${name}
 +		dhcpd_piddir=${__dhcpd_piddir}/${name}
 +		dhcpd_leasesdir=${__dhcpd_leasesdir}/${name}
  	else
  		dhcpd_withuser= dhcpd_withgroup=
  	fi
 @@ -328,8 +352,8 @@
  rcvar_pidnleases ()
  {
  	if ! checkyesno dhcpd_chuser_enable; then
 -		dhcpd_piddir=${_dhcpd_piddir}
 -		dhcpd_leasesdir=${_dhcpd_leasesdir}
 +		dhcpd_piddir=${__dhcpd_piddir}
 +		dhcpd_leasesdir=${__dhcpd_leasesdir}
  	fi
  	dhcpd_pidfile=${dhcpd_piddir}/${name}.pid
  	dhcpd_leasesfile=${dhcpd_leasesdir}/${name}.leases
 @@ -372,8 +396,8 @@
  
  setup_umask ()
  {
 -	if [ -n "${dhcpd_umask}" ]; then
 -		umask ${dhcpd_umask}
 +	if [ -n "${dhcpd_withumask}" ]; then
 +		umask ${dhcpd_withumask}
  	fi
  }
  
 @@ -435,8 +459,8 @@
  
  dhcpd_stop ()
  {
 -	if $0 status; then
 -		$0 stop
 +	if sh $0 forcestatus; then
 +		sh $0 forcestop
  	fi
  }
  
 @@ -515,21 +539,71 @@
  	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 ()
  {
 -	dhcpd_stop
 -	remove_pid
 -	remove_leases
 -	remove_chuser
 -	remove_chroot
 +	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_piddir=/var/run			# pid file directory
 -_dhcpd_leasesdir=/var/db			# leases file directory
 -#_dhcpd_rootdir=/var/db/${name}		# root directory
 +__dhcpd_uninstall="NO"			# internal use only
 +__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
 
 CC David Du SERRE-TELMON  and Jonathan Weiss
 
 Cyrille Lefevre
 -- 
 mailto:cyrille.lefevre@laposte.net



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406300050.i5U0oS6F030314>