ports/162447: net/isc-dhcp41-server: starting with rc-script fails

Hilko Meyer Hilko.Meyer at gmx.de
Sat Nov 12 00:00:40 UTC 2011


The following reply was made to PR ports/162447; it has been noted by GNATS.

From: Hilko Meyer <Hilko.Meyer at gmx.de>
To: Douglas Thrift <douglas at douglasthrift.net>
Cc: bug-followup at FreeBSD.org
Subject: Re: ports/162447: net/isc-dhcp41-server: starting with rc-script fails
Date: Sat, 12 Nov 2011 00:57:33 +0100

 ----=_djdrb75k8jt6f308j24merm59c6nhmvoo4.MFSBCHJLHS
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: quoted-printable
 
 Douglas Thrift schrieb:
 >Hello,
 >
 >It does not look like you have attached the correct patch? Could you
 >please reply with the correct patch?
 
 Hi,
 
 I looked at the problem again and I think I know what happens. The
 relevant parts of the rc-script are:
 
 start_precmd=3Ddhcpd_precmd
 restart_precmd=3D"dhcpd_checkconfig"
 
 dhcpd_precmd ()
 {
 	setup_umask
 	setup_chroot
 	setup_chuser
 	setup_leases
 	setup_flags
 }
 dhcpd_checkconfig ()
 {
         local rc_flags_mod
         setup_flags
 	rc_flags_mod=3D"$rc_flags"
         # Eliminate '-q' flag if it is present
 	case "$rc_flags" in
 	*-q*)	rc_flags_mod=3D`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
 }
 
 I used
 > /usr/local/etc/rc.d/isc-dhcpd restart
 when dhcpd wasn't running and the chroot was empty. If I understand it
 correctly it can't work, because in the rc-script dhcpd_checkconfig ()
 is executed before dhcpd_precmd () where the chroot is created. But if
 dhcpd is called with the -chroot option it looks in the chroot for the
 config file.
 
 So, I think the solution is to strip out the '-chroot' with an extended
 sed expression so that dhcpd -t ${rc_flags_mod} will always test the
 config file that will be copied to the chroot. I've attached a patch
 with a modified sed expression. Tested here. Please review with care. My
 sed fu isn't too strong. ;-)
 
 Another thing I noticed is that dhcpd_checkconfig is only called by
 'isc-dhcpd restart', not by 'isc-dhcpd start'. Moving the call of
 dhcpd_checkconfig to dhcpd_precmd. I've attached a second patch
 with this. Position in dhcpd_precmd was chosen arbitrary. If
 dhcpd_checkconfig is called after setup_chroot it isn't necessary to
 change the sed expression to fix my problem. Nevertheless I think both
 fixes should be combined.
 
 bye,
 Hilko
 
 ----=_djdrb75k8jt6f308j24merm59c6nhmvoo4.MFSBCHJLHS
 Content-Type: application/octet-stream; name=isc-dhcpd-diff.1
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename=isc-dhcpd-diff.1
 
 LS0tIGlzYy1kaGNwZC5vcmlnCTIwMTEtMTEtMTEgMTk6MjY6MDcuMDAwMDAwMDAwICswMTAwCisr
 KyBpc2MtZGhjcGQuMQkyMDExLTExLTExIDE5OjI4OjI0LjAwMDAwMDAwMCArMDEwMApAQCAtNDkz
 LDcgKzQ5Myw3IEBACiAJcmNfZmxhZ3NfbW9kPSIkcmNfZmxhZ3MiCiAgICAgICAgICMgRWxpbWlu
 YXRlICctcScgZmxhZyBpZiBpdCBpcyBwcmVzZW50CiAJY2FzZSAiJHJjX2ZsYWdzIiBpbgotCSot
 cSopCXJjX2ZsYWdzX21vZD1gZWNobyAiJHtyY19mbGFnc30iIHwgc2VkIC1FZSAncy8oXi1xIHwg
 LXEgfCAtcSQpLy8nYCA7OworCSotcSopCXJjX2ZsYWdzX21vZD1gZWNobyAiJHtyY19mbGFnc30i
 IHwgc2VkIC1FZSAncy8oXi1xIHwgLXEgfCAtcSR8LWNocm9vdCBbXC9hLXowLTldKykvL2cnYCA7
 OwogCWVzYWMKICAgICAgICAgaWYgISAke2NvbW1hbmR9IC10IC1xICR7cmNfZmxhZ3NfbW9kfTsg
 dGhlbgogICAgICAgICAgICAgICAgIGVyciAxICJgJHtjb21tYW5kfSAtdCAke3JjX2ZsYWdzX21v
 ZH1gIENvbmZpZ3VyYXRpb24gZmlsZSBzYW5pdHkgY2hlY2sgZmFpbGVkIgo=
 
 ----=_djdrb75k8jt6f308j24merm59c6nhmvoo4.MFSBCHJLHS
 Content-Type: application/octet-stream; name=isc-dhcpd-diff.2
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename=isc-dhcpd-diff.2
 
 LS0tIGlzYy1kaGNwZC5vcmlnCTIwMTEtMTEtMTEgMTk6MjY6MDcuMDAwMDAwMDAwICswMTAwCisr
 KyBpc2MtZGhjcGQuMgkyMDExLTExLTExIDE5OjI5OjA5LjAwMDAwMDAwMCArMDEwMApAQCAtNDc5
 LDYgKzQ3OSw3IEBACiAJc2V0dXBfY2h1c2VyCiAJc2V0dXBfbGVhc2VzCiAJc2V0dXBfZmxhZ3MK
 KwlkaGNwZF9jaGVja2NvbmZpZwogfQogCiBkaGNwZF9wb3N0Y21kICgpCkBAIC01MTgsNyArNTE5
 LDYgQEAKIGV2YWwgInJlcXVpcmVkX2ZpbGVzPVwkeyR7bmFtZX1fY29uZn0iCiBzdGFydF9wcmVj
 bWQ9ZGhjcGRfcHJlY21kCiBzdG9wX3Bvc3RjbWQ9ZGhjcGRfcG9zdGNtZAotcmVzdGFydF9wcmVj
 bWQ9ImRoY3BkX2NoZWNrY29uZmlnIgogdW5pbnN0YWxsX2NtZD1kaGNwZF91bmluc3RhbGwKIGV4
 dHJhX2NvbW1hbmRzPSJ1bmluc3RhbGwiCiAK
 
 ----=_djdrb75k8jt6f308j24merm59c6nhmvoo4.MFSBCHJLHS--



More information about the freebsd-ports-bugs mailing list