From 3ad482078b906a07a10b86dbd915d0b0a0b494c0 Mon Sep 17 00:00:00 2001 From: "Leon M. Busch-George" Date: Sun, 15 Oct 2023 21:33:15 -0600 Subject: [PATCH 1/2] isc-dhcp: adapt to new ipcalc paradigm With #12925, 'BROADCAST' will no longer be set if there is no local broadcast address (rather than holding the global broadcast address). Prepare for the merge but stay compatible with the old version of ipcalc. Signed-off-by: Leon M. Busch-George --- net/isc-dhcp/files/dhcpd.init | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/isc-dhcp/files/dhcpd.init b/net/isc-dhcp/files/dhcpd.init index 967ba83da..0caffb8a8 100755 --- a/net/isc-dhcp/files/dhcpd.init +++ b/net/isc-dhcp/files/dhcpd.init @@ -374,7 +374,9 @@ gen_dhcp_subnet() { echo " range $START $END;" fi echo " option subnet-mask $netmask;" - if [ "$BROADCAST" != "0.0.0.0" ] ; then + # check for 0.0.0.0 until all active releases of ipcalc.sh omit it + # for small networks: + if [ -n "$BROADCAST" ] && [ "$BROADCAST" != "0.0.0.0" ] ; then echo " option broadcast-address $BROADCAST;" fi if [ "$dynamicdhcp" -eq 0 ] ; then @@ -443,7 +445,7 @@ dhcpd_add() { dhcp_ifs="$dhcp_ifs $ifname" - eval "$(ipcalc.sh $subnet $start $limit)" + ipcalc $subnet $start $limit config_get netmask "$cfg" "netmask" "$NETMASK" config_get leasetime "$cfg" "leasetime" From dd2daafc6e2110b3816b5d81b2fa8de043b74824 Mon Sep 17 00:00:00 2001 From: "Leon M. Busch-George" Date: Sun, 15 Oct 2023 21:35:14 -0600 Subject: [PATCH 2/2] isc-dhcp: refuse to add empty DHCP range ipcalc.sh no longer outputs invalid ranges and fails with an error code in such cases. React to the error. Signed-off-by: Leon M. Busch-George --- net/isc-dhcp/files/dhcpd.init | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/isc-dhcp/files/dhcpd.init b/net/isc-dhcp/files/dhcpd.init index 0caffb8a8..111201009 100755 --- a/net/isc-dhcp/files/dhcpd.init +++ b/net/isc-dhcp/files/dhcpd.init @@ -445,7 +445,10 @@ dhcpd_add() { dhcp_ifs="$dhcp_ifs $ifname" - ipcalc $subnet $start $limit + if ! ipcalc "$subnet" "$start" "$limit"; then + echo "invalid range params: $subnet start: $start limit $limit" >&2 + return 1 + fi config_get netmask "$cfg" "netmask" "$NETMASK" config_get leasetime "$cfg" "leasetime"