net/isc-dhcp44-server: Fix checkconfig command.

This adds an undocumented -Q flag which cancels out any -q option that
may be present in dhcpd_flags, avoiding the need for a fragile sed
command.  It also adds a comment explaining why we are running the
check twice and what the -q and -Q are for.

PR:		281701
This commit is contained in:
Dag-Erling Smørgrav 2024-10-02 12:37:30 +02:00
parent be18158f3c
commit 6725d10536
3 changed files with 22 additions and 11 deletions

View file

@ -19,7 +19,7 @@ USES= cpe gmake
CPE_VENDOR= isc
PORTREVISION_SERVER= 1
PORTREVISION_SERVER= 2
PORTREVISION_CLIENT= 1
PORTREVISION_RELAY= 1

View file

@ -499,16 +499,15 @@ dhcpd_restartprecmd ()
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
setup_flags
# Run dhcpcd -t quietly to check for errors. If this fails,
# run it again unquietly so the errors are shown to the user,
# then error out. The -q and -Q flags need to be at the end
# to override contradictory flags in ${rc_flags}.
if ! ${command} -t ${rc_flags} -q; then
${command} -t ${rc_flags} -Q
err 1 "Configuration file sanity check failed"
fi
}
rcvar=${name}_enable

View file

@ -0,0 +1,12 @@
--- server/dhcpd.c.orig 2022-09-28 14:39:15 UTC
+++ server/dhcpd.c
@@ -492,6 +492,9 @@ main(int argc, char **argv) {
cftest = 1;
lftest = 1;
log_perror = -1;
+ } else if (!strcmp (argv [i], "-Q")) {
+ quiet = 0;
+ quiet_interface_discovery = 0;
} else if (!strcmp (argv [i], "-q")) {
quiet = 1;
quiet_interface_discovery = 1;