From 8e2a7e8a28d893c287afc69538e7fdb30002ba86 Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Fri, 22 Feb 2008 09:24:35 +0000 Subject: Do not allow enabling of DHCP server on dynamic IP interfaces (fixed in HEAD in last commit) added a couple TODO items to fix later Single interface support Appliance Project --- etc/rc.initial.setlanip | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'etc/rc.initial.setlanip') diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip index 066334d..ea269c9 100755 --- a/etc/rc.initial.setlanip +++ b/etc/rc.initial.setlanip @@ -119,14 +119,20 @@ $config['interfaces'][$interface]['subnet'] = $intbits; if($interface <> "wan" || !$config['interfaces']['lan']) { - do { - $good = false; - $upperifname = strtoupper($interface); - echo "\n" . gettext("Do you want to enable the DHCP server on {$upperifname}? [y|n]") . " "; - $yn = strtolower(chop(fgets($fp))); - if ($yn[0] == "y" or $yn[0] == "n") - $good = true; - } while (!$good); + /* only allow DHCP server to be enabled when static IP is + configured on this interface */ + /* TODO: is this inadequate because the new config isn't written + out yet at this point? */ + if (is_ipaddr($config['interfaces']['$interface']['ipaddr'])) { + do { + $good = false; + $upperifname = strtoupper($interface); + echo "\n" . gettext("Do you want to enable the DHCP server on {$upperifname}? [y|n]") . " "; + $yn = strtolower(chop(fgets($fp))); + if ($yn[0] == "y" or $yn[0] == "n") + $good = true; + } while (!$good); + } } else { $yn = "n"; } @@ -155,6 +161,9 @@ $config['dhcpd'][$interface]['range']['from'] = $dhcpstartip; $config['dhcpd'][$interface]['range']['to'] = $dhcpendip; } else { + /* TODO - this line is causing a "Fatal error: Cannot unset + string offsets in /etc/rc.initial.setlanip" on below line + number */ unset($config['dhcpd'][$interface]['enable']); } -- cgit v1.1